Bruker.API.Esprit.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /*
  2. Bruker.API.Esprit.h
  3. Header File for Bruker Esprit-Interface
  4. Microsoft Visual Studio 2015
  5. */
  6. #pragma once
  7. #include <stddef.h>
  8. #include <tchar.h>
  9. #include "Bruker.API.CommonFunctions.h"
  10. #include "Bruker.API.CommonStructures.h"
  11. namespace BrukerDll
  12. {
  13. struct TFeatureData;
  14. struct TRTEBSDCalibSettings;
  15. struct TRTElementRegion;
  16. struct TRTHyMapProfileSettings;
  17. struct TRTImageInfoEx;
  18. struct TSegment;
  19. #pragma pack(push, 1)
  20. struct TRTEBSDCalibSettings {
  21. int32_t TiltAngle;
  22. int32_t TiltAzimuthAngle;
  23. int32_t ScanRotation;
  24. int32_t WD;
  25. int32_t DetectorAxis;
  26. int32_t DetectorTilt;
  27. int32_t PhosphorSize;
  28. };
  29. #pragma pack(pop)
  30. typedef TRTEBSDCalibSettings* PRTEBSDCalibSettings;
  31. #pragma pack(push, 1)
  32. struct TRTImageInfoEx {
  33. int32_t Magnification;
  34. double PixelSizeX; // µm per Pixel
  35. double PixelSizeY;
  36. double HighVoltage; // kV
  37. double WorkingDistance; // mm
  38. };
  39. #pragma pack(pop)
  40. typedef TRTImageInfoEx* PRTImageInfoEx;
  41. #pragma pack(push, 1) // describes 1 scan feature
  42. struct TFeatureData {
  43. int32_t SegmentCount;
  44. PSegmentList Segments;
  45. };
  46. #pragma pack(pop)
  47. typedef TFeatureData* PFeatureDataList;
  48. bool LoadEspritAPI(char* csAPILibFile);
  49. //----------------------------------------------------------------------------------
  50. // Interface functions of Bruker.API.Esprit.DLL
  51. //----------------------------------------------------------------------------------
  52. // Ask for SGU/SCU/SBU device connection status
  53. // Status: 0 = connected, 1 = wait for reconnection, 2 = reconnecting
  54. // TimeLeftForReconnection in ms
  55. int32_t HardwareConnectionGetStatus(uint32_t CID, int32_t& Status, boolean& WasInterrupted, int32_t& TimeLeftForReconnection);
  56. // Reset connection error flag 'WasInterrupted' from above once detected
  57. int32_t HardwareConnectionResetErrorFlag(uint32_t CID);
  58. // Initialize connection reset procedure, this will trigger a 'watchdogged' hardware reset in SCU/SGU
  59. int32_t HardwareConnectionReset(uint32_t CID);
  60. // Reset scan hardware, device will have default configuration afterwards, so be sure to re-configure it correctly
  61. int32_t ImageReset(uint32_t CID);
  62. // Read current image device configuration
  63. int32_t ImageGetConfiguration(uint32_t CID, uint32_t& Width, uint32_t& Height, uint32_t& Average, bool& Ch1, bool& Ch2);
  64. // Write current image device configuration
  65. int32_t ImageSetConfiguration(uint32_t CID, uint32_t Width, uint32_t Height, uint32_t Average, bool Ch1, bool Ch2);
  66. // Use external scan engine which triggers our scan generator trough an external signal
  67. int32_t ImageSetExternalScan(uint32_t CID, bool UseExternalScan);
  68. // Aquire new image and read image data
  69. int32_t ImageAquireImage(uint32_t CID, int32_t Ch, bool ShowProgress, void* Buffer, int32_t& BufSize, PRTImageInfoEx ImgInfo);
  70. // Aquire new image and read image data
  71. // Options : Bit combination of the following values
  72. // cImgAcq_ShowProgress = 1;
  73. // cImgAcq_UpdateSEMData = 2;
  74. int32_t ImageAquireImageEx(uint32_t CID, int32_t Ch, void* Buffer, uint32_t Options, int32_t& BufSize, PRTImageInfoEx ImgInfo);
  75. // Read the image field width from scan settings and SEM magnification, microns unit
  76. int32_t ImageGetFieldWidth(uint32_t CID, double& FieldWidth);
  77. // Set drift correction vector
  78. int32_t ImageSetExternalDriftCorrection(uint32_t CID, double ShiftX, double ShiftY);
  79. int32_t ImageGetDriftCorrectionActive(uint32_t CID, bool& Active);
  80. int32_t ImageGetLatestKnownScanPosition(uint32_t CID, int& X, int& Y);
  81. int32_t ImageGetScannedSegmentsCount(uint32_t CID, __int64& aCount);
  82. // Set electron beam position in image
  83. int32_t ImageSetPoint(uint32_t CID, uint32_t X, uint32_t Y);
  84. // functions to deal with point lists
  85. // CID : connection identifier
  86. // SPU : spectrometer index (1..n)
  87. // SegmentCount,
  88. // LineSegments : description of points to measure
  89. // RealTime: : acquisition time in ms
  90. int32_t StartPointListMeasurement(uint32_t CID, int32_t SPU, uint32_t SegmentCount, PSegmentList LineSegments, uint32_t RealTime);
  91. // CID : connection identifier
  92. // Index : spectrum index (1..n)
  93. // SpectrumBuf : buffer to hold complete spectrum with header (around 20kB), must be allocated by caller
  94. // BufSize : size of spectrum buffer
  95. int32_t GetPointListSpectrum(uint32_t CID, int32_t Index, PRTSpectrumHeaderRec SpectrumBuf, int32_t BufSize);
  96. int32_t QuantifyPointListSpectrum(uint32_t CID, int32_t Index, char* MethodName, char* Params, char* ResultBuf, int32_t ResultBufSize, PRTSpectrumHeaderRec SpectrumBuf, int32_t BufSize);
  97. // CID : connection identifier
  98. // Index : spectrum index (1..n)
  99. // FileName : filename to save to
  100. int32_t SavePointListSpectrum(uint32_t CID, int32_t Buffer, char* FileName);
  101. ///////////////////////////////////////////////////////////
  102. // functions to deal with object lists ///
  103. ///////////////////////////////////////////////////////////
  104. int32_t StartFeatureListMeasurement(uint32_t CID, int32_t SPU, uint32_t FeatureCount, PFeatureDataList Features, __int16* PixelTimes);
  105. int32_t GetFeatureListSpectrum(uint32_t CID, int32_t Index, PRTSpectrumHeaderRec SpectrumBuf, int32_t BufSize);
  106. int32_t QuantifyFeatureListSpectrum(uint32_t CID, int32_t Index, char* MethodName, char* Params, char* ResultBuf, int32_t ResultBufSize, PRTSpectrumHeaderRec SpectrumBuf, int32_t BufSize);
  107. int32_t SaveFeatureListSpectrum(uint32_t CID, int32_t Buffer, char* FileName);
  108. ///////////////////////////////////////////////////////////
  109. /// functions to communicate with SEM ///
  110. ///////////////////////////////////////////////////////////
  111. int32_t SetSEMData(uint32_t CID, double Magnification, double HighVoltage, double WorkingDistance);
  112. int32_t GetSEMData(uint32_t CID, double& Magnification, double& HighVoltage, double& WorkingDistance);
  113. int32_t SetSEMParameter(uint32_t CID, char* Params, char* ValueIDs, double* Values);
  114. int32_t GetSEMParameter(uint32_t CID, char* Params, char* ValueIDs, double* Values);
  115. int32_t GetSEMBCData(uint32_t CID, double& Brightness, double& Contrast);
  116. int32_t SetSEMBCData(uint32_t CID, double Brightness, double Contrast);
  117. int32_t GetSEMProbeCurrent(uint32_t CID, double& ProbeCurrent);
  118. int32_t SetSEMProbeCurrent(uint32_t CID, double ProbeCurrent);
  119. int32_t GetSEMSpotSize(uint32_t CID, double& SpotSize);
  120. int32_t SetSEMSpotSize(uint32_t CID, double SpotSize);
  121. int32_t SetSEMDetector(uint32_t CID, int Channel, char* DetectorName);
  122. int32_t GetSEMDetector(uint32_t CID, int Channel, char* DetectorName, int32_t BufSize);
  123. int32_t SetSEMStageData(uint32_t CID, double XPos, double YPos, double ZPos, double Tilt, double Rotation);
  124. int32_t GetSEMStageData(uint32_t CID, double& XPos, double& YPos, double& ZPos, double& Tilt, double& Rotation);
  125. int32_t GetSEMStageRange(uint32_t CID, double& Xmin, double& Xmax, double& Ymin, double& Ymax, double& Zmin, double& Zmax, double& Tmin, double& Tmax, double& Rmin, double& Rmax);
  126. int32_t GetSEMStageState(uint32_t CID, int32_t& State);
  127. int32_t GetSEMCapabilities(uint32_t CID, char* Capabilities, int32_t BufSize);
  128. int32_t GetSEMInfo(uint32_t CID, char* Info, int32_t BufSize);
  129. int32_t SetSEMExternalOn(uint32_t CID);
  130. int32_t SetSEMExternalOff(uint32_t CID);
  131. int32_t ResetSEMCommunication(uint32_t CID);
  132. int32_t SwitchSEMOff(uint32_t CID, bool HVOff, bool BeamCurrentOff, bool BeamBlank);
  133. ///////////////////////////////////////////////////////////
  134. /// Move EDS detector ///
  135. ///////////////////////////////////////////////////////////
  136. // Detector : Detector to be moved ( 1 in most cases )
  137. // Position : Position to move to ( 1 = Park position, 2 = Acquisition position )
  138. int32_t EDSSetDetectorPosition(uint32_t CID, int32_t Detector, int32_t Position);
  139. // Detector : Detector to ask for position ( 1 in most cases )
  140. // Position : Current position ( 1 = Park position, 2 = Acquisition position )
  141. int32_t EDSGetDetectorPosition(uint32_t CID, int32_t Detector, int32_t& Position);
  142. ///////////////////////////////////////////////////////////
  143. /// Mapping functions ///
  144. ///////////////////////////////////////////////////////////
  145. // PixelTime : Dwell time per Pixel in microseconds
  146. // RealTime : Acquisition time in s, RealTime=0 does exactly 1 scan
  147. int32_t HyMapStart(uint32_t CID, int32_t SPU, uint32_t PixelTime, uint32_t RealTime);
  148. // PixelTime : Dwell time per Pixel in microseconds
  149. // RealTime : Acquisition time in s, RealTime=0 does exactly 1 scan
  150. // Region : Image region to be mapped
  151. int32_t HyMapStartEx(uint32_t CID, int32_t SPU, uint32_t PixelTime, uint32_t RealTime, TFeatureData Region);
  152. // PixelTime : Dwell time per Pixel in microseconds
  153. // RealTime : Acquisition time in s, RealTime=0 does exactly 1 scan
  154. // Region : Image region to be mapped
  155. // Profile : XML serialized profile
  156. int32_t HyMapStartWithProfile(uint32_t CID, int32_t SPU, uint32_t PixelTime, TFeatureData Region, char* Profile);
  157. // MapSettings : Map settings
  158. // Profile : XML serialized profile
  159. // BufSize : Size of buffer
  160. int32_t HyMapCreateProfile(const TRTHyMapProfileSettings& MapSettings, char* Profile, int32_t& BufSize);
  161. // DataFileName: complete name of existing mapping data file
  162. // Profile : XML serialized EDS map profile
  163. int32_t SetDataAndProfileToUI(uint32_t CID, char* DataFileName, char* Profile);
  164. ///////////////////////////////////////////////////////////
  165. /// EBSD functions ///
  166. ///////////////////////////////////////////////////////////
  167. // Retrieve the list of predefined acquisition setups
  168. // Profiles : buffer to store the list information
  169. // BufSize : Size of buffer
  170. int32_t EBSDGetAcquisitionProfiles(uint32_t CID, char* Profiles, int32_t BufSize);
  171. // Load a predefined acquisition setup
  172. // Profile : buffer with profile name to select
  173. int32_t EBSDSelectAcquisitionProfile(uint32_t CID, char* Profile);
  174. // Start EBSD acquisition with selected setup
  175. int32_t EBSDStartAcquisition(uint32_t CID);
  176. // Start EBSD acquisition with defined profile data
  177. int32_t EBSDStartAcquisitionWithProfile(uint32_t CID, char* Profile);
  178. // Stop EBSD acquisition
  179. int32_t EBSDStopAcquisition(uint32_t CID);
  180. // Retrieve EBSD acquisition state
  181. // CurrentLine : current acquisition Y -position
  182. // PercentReady: Current state of Acquisition in %
  183. // IndexingPercentReady : Current State of Indexing in %
  184. // AcquisitionRunning : Is just giving the running state of the Acquisition
  185. // IndexingRunning : Is just giving the running state of the Indexing
  186. int32_t EBSDGetAcquisitionState(uint32_t CID, int32_t& CurrentLine, int32_t& PercentReady, int32_t& IndexingPercentReady, bool& AcquisitionRunning, bool& IndexingRunning);
  187. // Save EBSD acquisition data to file in Bruker format
  188. // FileName : File name for the file to store information (*.bcf)
  189. // WithEdx : Saves EDX Data
  190. // WithPatterns: Saves Patterns
  191. int32_t EBSDSaveToFile(uint32_t CID, char* FileName, bool WithEdx, bool WithPatterns);
  192. // BaseFileName: Base file name for the result files to export (map images?
  193. // ExportOptions: Integer representation of export options (Phase=2,IPFX=3,IPFY=4,IPFZ=5,Euler=6)
  194. int32_t EBSDExportData(uint32_t CID, char* BaseFileName, int32_t ExportOptions);
  195. // Buffer:Pointer
  196. // BufferSize:integer
  197. // ExportOptions: longint representation of export options (Phase=2,IPFX=3,IPFY=4,IPFZ=5,Euler=6)
  198. int32_t EBSDExportDataBuffer(uint32_t CID, void* Buffer, int& BufferSize, int ExportOptions);
  199. // BaseFileName: Base file name for the result list (ctf-file) to export
  200. int32_t EBSDExportResults(uint32_t CID, char* BaseFileName);
  201. // Retrieve EBSD detector position
  202. // Position : Detector position in mm
  203. int32_t EBSDGetDetectorPosition(uint32_t CID, double& Position);
  204. // Move EBSD detector to specified position
  205. // Position : Detector position in mm
  206. // Speed : Detector speed in mm/s:
  207. int32_t EBSDSetDetectorPosition(uint32_t CID, double Position, double Speed);
  208. // Acquire pattern images, Buffer returns bitmap stream structure
  209. int32_t EBSDImageAcquireEx(uint32_t CID, void* Buffer, int& BufSize, int PosX, int PosY);
  210. int32_t EBSDImageAcquireWithPC(uint32_t CID, void* Buffer, int& BufSize, int PosX, int PosY, int NFrameAvg, double& PCX, double& PCY, double& PCL);
  211. // Acquire pattern images, Buffer returns raw data
  212. int32_t EBSDImageAcquireRawDataFromPosition(uint32_t CID, void* Buffer, int& BufSize, int PosX, int PosY, int& Width, int& Height, int& PixelBytes);
  213. int32_t EBSDImageAcquireRawDataFromPositionWithPC(uint32_t CID, void* Buffer, int& BufSize, int PosX, int PosY, int NFrameAvg, double& PCX, double& PCY, double& PCL, int& Width, int& Height, int& PixelBytes);
  214. // Acquire pattern images for multiple points, Buffer returns Bitmap image buffer
  215. int32_t EBSDPointListImageAcquireWithPC(uint32_t CID, void* Buffer, int& BufSize, uint32_t PointCount, PMultiPointList Points, int NFrameAvg, double& PCX, double& PCY, double& PCL, int& Width, int& Height, int& PixelBytes);
  216. // Acquire pattern images for multiple points, Buffer returns raw data buffer
  217. int32_t EBSDPointListImageAcquireRawDataWithPC(uint32_t CID, void* Buffer, int& BufSize, uint32_t PointCount, PMultiPointList Points, int NFrameAvg, double& PCX, double& PCY, double& PCL, int& Width, int& Height, int& PixelBytes);
  218. // Settings include:
  219. // TiltAngle of the Detector
  220. // TiltAzimuthAngle of the Detector;
  221. // ScanRotation
  222. // WD
  223. // DetectorAxis
  224. // DetectorTilt
  225. // PhosphorSize
  226. int32_t EBSDStartCalibration(uint32_t CID, PRTEBSDCalibSettings Settings);
  227. // Stop EBSD Calibration
  228. int32_t EBSDStopCalibration(uint32_t CID);
  229. //CurrentLine : not yet in use
  230. //PercentReady : Calibration state in %
  231. //Running : Running state of calibration
  232. int32_t EBSDGetCalibrationState(uint32_t CID, int32_t& CurrentLine, int32_t& PercentReady, bool& Running);
  233. int32_t EBSDSaveEBSPImageFromPosition(uint32_t CID, char* aBaseFilename, int32_t X, int32_t Y);
  234. int32_t EBSDSetExposureTime(uint32_t CID, int32_t ExposureTime);
  235. int32_t EBSDGetExposureTime(uint32_t CID, int32_t& ExposureTime);
  236. //Width: Current camera width
  237. //Height: Current camera height
  238. int32_t EBSDGetImageConfiguration(uint32_t CID, int32_t& Width, int32_t& Height);
  239. int32_t EBSDSetGain(uint32_t CID, int32_t Value);
  240. int32_t EBSDGetGain(uint32_t CID, int32_t& Value);
  241. int32_t EBSDGetTilt(uint32_t CID, double& Value);
  242. //Count : returns the amount of image format (binning)
  243. int32_t EBSDGetAvailablePatternFormatCount(uint32_t CID, int32_t& Count);
  244. //FormatIndex: Seletion index of image format
  245. //Width: Camera Width
  246. //Height: Camera Height
  247. int32_t EBSDGetAvailablePatternFormat(uint32_t CID, const int32_t FormatIndex, int32_t& Width, int32_t& Height);
  248. //FormatIndex: The choosen Index for Camera Format
  249. int32_t EBSDSetPatternFormat(uint32_t CID, const int32_t FormatIndex);
  250. //Value: true (16bit Mode), false (8 bit Mode)
  251. int32_t EBSDSetPattern16bitMode(uint32_t CID, const bool Value);
  252. int32_t EBSDGetEstimatedMappingTime(uint32_t CID, int32_t& Time);
  253. //PointList: array of points to be measured
  254. //PointCount: number of points to be measured
  255. int32_t EBSDStartAcquisitionFromPointList(uint32_t CID, PPointArray PointList, int32_t pointcount);
  256. //PointResults: all results of the measured map
  257. //pointcount: number of available results
  258. //Call with PointResults == NULL and pointcount==0 to get number of results (for reserving sufficient space)
  259. int32_t EBSDGetPointResults(uint32_t CID, PEBSDIndexingResultArray PointResults, int32_t & pointcount);
  260. }