Bruker.API.CommonFunctions.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /*
  2. Bruker.API.CommonTypes.h
  3. Header File for Bruker Common-Interface
  4. Microsoft Visual Studio 2015
  5. */
  6. #pragma once
  7. #ifndef BrukerAPICommonFunctionsH
  8. #define BrukerAPICommonFunctionsH
  9. #include <stddef.h>
  10. #include <stdint.h>
  11. #include <tchar.h>
  12. #include <iostream>
  13. #include <sstream>
  14. #include <string>
  15. namespace BrukerDll
  16. {
  17. struct TOpenClientOptions;
  18. struct TRTAPISpectrumHeaderRec;
  19. struct TRTCalibResults;
  20. struct TRTCalibSettings;
  21. struct TRTDetectorRanges;
  22. struct TRTDetectorStatus;
  23. struct TRTHardwareConfiguration;
  24. struct TRTSpectrometerStatus;
  25. #pragma pack(push, 1) // structure to describe a point, should be compatible to Windows.Point
  26. struct TPoint {
  27. int32_t X;
  28. int32_t Y;
  29. };
  30. #pragma pack(pop)
  31. #pragma pack(push, 1)
  32. struct TRTSpectrumHeaderRec {
  33. uint8_t IdentifierLength;
  34. char Identifier[25]; // 'Rontec XRay spectrum'
  35. int32_t Version; // Version information
  36. int32_t Size; // Size in byte
  37. double DateTime; // Delphi 5.0 version of date and time
  38. int32_t ChannelCount; //
  39. int32_t ChannelOffset; // First channel index
  40. double CalibrationAbs; // Energy of first channel
  41. double CalibrationLin; // keV per channel
  42. double SigmaAbs; // Sigma^2 energy calibration
  43. double SigmaLin;
  44. // additional data compared to normal Roentec header
  45. int32_t RealTime; // real measure time in ms
  46. int32_t LifeTime; // life time in ms
  47. };
  48. #pragma pack(pop)
  49. typedef TRTSpectrumHeaderRec* PRTSpectrumHeaderRec;
  50. #pragma pack(push, 1)
  51. struct TRTCalibSettings {
  52. int32_t Version; // Version of record structure, should be '1' at the moment
  53. int32_t Element1;
  54. char* Line1;
  55. double Energy1;
  56. int32_t Element2;
  57. char* Line2;
  58. double Energy2;
  59. int32_t MaxTime; // Maximum time to calibrate in ms, '0' indicates to use a internal statistics to decide to stop
  60. #ifdef BRUKERAPIESPRITH
  61. bool ShowProgress; // Show progress information
  62. #endif
  63. };
  64. #pragma pack(pop)
  65. typedef TRTCalibSettings* PRTCalibSettings;
  66. #pragma pack(push, 1)
  67. struct TRTCalibResults {
  68. int32_t Version;
  69. double CalibLin, CalibAbs, FWHM, Fano;
  70. };
  71. #pragma pack(pop)
  72. typedef TRTCalibResults* PRTCalibResults;
  73. #pragma pack(push, 1)
  74. struct TRTDetectorStatus {
  75. int32_t Version; // Version of structure, useful for later extensions
  76. int32_t Status; // -1=not present, 0=present but inactive, 1=active
  77. uint32_t CountRate; // Current input count rate in cps
  78. int32_t Temperature; // Current temperature in °C
  79. uint32_t CoolingMode; // Cooling mode (0=off, 1=on, 2=max. 3=heating, 4=unknown)
  80. };
  81. #pragma pack(pop)
  82. #pragma pack(push, 1)
  83. struct TRTSpectrometerStatus {
  84. int32_t Version; // Version of structure, useful for later extensions
  85. TRTDetectorStatus DetectorStatus[4/*# range 0..3*/];// Detector information
  86. uint32_t Status; // 0=not detected, 1=standby, 2=interlock, 3=stopped, 4=running
  87. bool Ready;
  88. };
  89. #pragma pack(pop)
  90. #pragma pack(push, 1)
  91. struct TRTDetectorRanges {
  92. int32_t MaxEnergy[8/*# range 0..7*/];
  93. int32_t PulseThroughPut[8/*# range 0..7*/];
  94. int32_t EnergyIndexCount;
  95. int32_t PulseIndexCount;
  96. };
  97. #pragma pack(pop)
  98. typedef TRTDetectorRanges* PRTDetectorRanges;
  99. #pragma pack(push, 1)
  100. struct TRTHardwareConfiguration {
  101. int32_t Detector[4]; // [0..3] is SPU
  102. bool EBSD;
  103. bool Raster;
  104. int32_t XrayTube;
  105. };
  106. #pragma pack(pop)
  107. typedef TRTHardwareConfiguration* PRTHardwareConfiguration;
  108. #pragma pack(push, 1)
  109. struct TOpenClientOptions {
  110. int32_t Version;
  111. int32_t GUIMode;
  112. bool StartNew;
  113. uint8_t IdentifierLength;
  114. char TCPHost[64]; // from version 2
  115. uint16_t TCPPort; // from version 2
  116. };
  117. #pragma pack(pop)
  118. typedef TOpenClientOptions* POpenClientOptions;
  119. enum TAPILogType {
  120. allError,
  121. allWarning,
  122. allInfo
  123. };
  124. // noch zu klären
  125. // TAPILogTypes = set of TAPILogType;
  126. typedef TPoint TPointArray[];
  127. typedef TPointArray* PPointArray;
  128. typedef void* TPointerArray[];
  129. typedef void** PPointerArray;
  130. // Error constants generated from client program
  131. const int32_t IFC_ERROR_IN_EXECUTION = -1;
  132. const int32_t IFC_ERROR_WRONG_PARAMETER = -2;
  133. const int32_t IFC_ERROR_SPECTRUM_BUFFER_EMPTY = -3;
  134. const int32_t IFC_ERROR_PARAMETER_MISSED = -4;
  135. const int32_t IFC_ERROR_TOO_MANY_PARAMETERS = -5;
  136. const int32_t IFC_ERROR_USER_TERMINATED = -6;
  137. const int32_t IFC_ERROR_TIMEOUT = -7;
  138. const int32_t IFC_ERROR_UNKNOWN_VALUE_NAME = -8;
  139. const int32_t IFC_ERROR_WRONG_VALUE_TYPE = -9;
  140. const int32_t IFC_ERROR_WRONG_LICENCE = -10;
  141. const int32_t IFC_ERROR_RESULT_BUFFER_INSUFFICIENT = -11;
  142. const int32_t IFC_ERROR_HARDWARE_LOCKED = -12;
  143. const int32_t IFC_ERROR_SEQUENCE = -13;
  144. const int32_t IFC_WARNING_WRONG_ELEMENT = 1;
  145. const int32_t IFS_ERROR_PARAMETER_MISSED = -51; // returned by RTIFCServer.dll 24.2.2011 '11' -> '51'
  146. const int32_t IFS_ERROR_FUNCTION_NOT_IMPLEMENTED = -52; // returned by RTIFCServer.dll 24.2.2011 '11' -> '52'
  147. const int32_t IFS_ERROR_FUNTION_EXCEPTED = -53;
  148. // Errors coming from OpenClient()
  149. const int32_t CONN_ERROR_UNKNOWN = -21;
  150. const int32_t CONN_ERROR_INTERFACE_NOT_CONNECTED = -22;
  151. const int32_t CONN_ERROR_PARAMETER_MISSED = -23;
  152. const int32_t CONN_ERROR_ANSWER_TIMEOUT = -24;
  153. const int32_t CONN_ERROR_SERVER_NOT_RESPONDING = -25;
  154. const int32_t CONN_ERROR_RESULT_MISSED = -26;
  155. const int32_t CONN_ERROR_NO_INTERFACE = -27;
  156. const int32_t CONN_ERROR_INVALID_LOGIN = -28;
  157. const int32_t CONN_ERROR_NO_CONNECTION_TO_SERVER = -29;
  158. const int32_t CONN_ERROR_SERVER = -30;
  159. const int32_t CONN_ERROR_ACTION_ABORTED = -31;
  160. // Error constants generated from Bruker.API.*.dll
  161. const int32_t ERROR_WRONG_PARAMETER = -101;
  162. const int32_t ERROR_FILE_NOT_EXIST = -102;
  163. const int32_t ERROR_NO_CONNECTION = -103;
  164. const int32_t ERROR_NO_ANSWER = -104;
  165. const int32_t ERROR_CAN_NOT_START_PROCESS = -105;
  166. const int32_t ERROR_INVALID_RESULT_DATA = -106;
  167. const int32_t ERROR_SETTINGS_NOT_FOUND = -107;
  168. const int32_t ERROR_NO_SERVER_CONNECTION = -108; // no direct call to server possible (used in '..Direct' calls
  169. const int32_t ERROR_IN_EXECUTION = -109;
  170. const int32_t ERROR_IFC_BUSY = -110;
  171. // State constants generated from Bruker.API.*.dll
  172. const int32_t STATE_WAS_RUNNING_BEFORE = -201;
  173. bool LoadCommonFunctions(const LPCTSTR LibFile);
  174. // Convert int32_t to String
  175. std::string IntToString(int32_t number);
  176. // Convert Double to String
  177. std::string DoubleToString(double number);
  178. //----------------------------------------------------------------------------------
  179. // Interface functions of Bruker.API.*.DLL
  180. //----------------------------------------------------------------------------------
  181. /// <summary>Set active language for interface</summary>
  182. /// <param name="Language">Language identifier, 'ge' for german, any other for english</param>
  183. int32_t SetLanguage(char* Language);
  184. /// <summary>Query all known servers which can be used by API</summary>
  185. /// <param name="pServerList">Buffer for list of available server names</param>
  186. /// <param name = "BufSize">Initial size of this buffer</param>
  187. int32_t QueryServers(char* pServerList, int32_t BufSize);
  188. /// <summary>Query all running client programs for a given server</summary>
  189. /// <param name="pServer">name of the server to be queried</param>
  190. /// <param name = "pClientBuf">Buffer for list of available clients</param>
  191. /// <param name = "BufSize">Initial size of this buffer</param>
  192. int32_t QueryUser(char* pServer, char* pClientBuf, int32_t BufSize);
  193. /// <summary>Start Esprit and login automatically. Connection is done via Windows messaging, so Esprit must be installed on the same computer</summary>
  194. /// <param name="Password">Password of user with UserName</param>
  195. /// <param name="GUI">Whether to start the user interface or not</param>
  196. /// <param name="CID">Reference connection identifier, which must be used in all following API calls</param>
  197. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  198. int32_t OpenClient(char* pServer, char* pUser, char* pPassword, bool StartNew, bool GUI, uint32_t& CID);
  199. /// <summary>Start Esprit and login automatically. Connection is done via Windows messaging, so Esprit must be installed on the same computer</summary>
  200. /// <param name="Password">Password of user with UserName</param>
  201. /// <param name="Options">Structure with connection options</param>
  202. /// <param name="CID">Reference connection identifier, which must be used in all following API calls</param>
  203. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  204. int32_t OpenClientEx(char* pServer, char* pUser, char* pPassword, const TOpenClientOptions& Options, uint32_t& CID);
  205. /// <summary>Login to a running Esprit. Connection is done via TCP, so Esprit can be installed on any computer which is accessible via TCP/IP</summary>
  206. /// <param name="Password">Password of user with UserName</param>
  207. /// <param name="Host">IP address of the computer with Esprit</param>
  208. /// <param name="Port">IP port used by Esprit (default port is 5328), Esprit must be running before one can use this function</param>
  209. /// <param name="Options">Structure with connection options</param>
  210. /// <param name="CID">Reference connection identifier, which must be used in all following API calls</param>
  211. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  212. int32_t OpenClientTCP(char* pServer, char* pUser, char* pPassword, char* pHost, uint16_t Port, const TOpenClientOptions Options, uint32_t& CID);
  213. /// <summary>Query some information about a specific connection</summary>
  214. /// <param name="pInfo">pointer to string to be filled from API with some useful information</param>
  215. /// <param name="BufSize">Size of this buffer</param>
  216. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  217. int32_t QueryInfo(uint32_t CID, char* pInfo, int32_t BufSize);
  218. /// <summary>Close corrent API connection, Esprit remains running, CID cannot be used anymore after this call</summary>
  219. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  220. int32_t CloseConnection(uint32_t CID);
  221. /// <summary>Shutdown Esprit, CID cannot be used anymore after this call</summary>
  222. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  223. int32_t CloseClient(uint32_t CID);
  224. /// <summary>Returns description string for error values</summary>
  225. /// <param name="aError">error value returned from an API call</param>
  226. /// <param name="pErrorStr">buffer to string provided by caller, to be filled from API</param>
  227. /// <param name="BufSize">in: Size of this buffer, out: size used</param>
  228. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  229. int32_t GetDebugErrorString(uint32_t CID, int32_t aError, char* pErrorStr, int32_t& BufSize);
  230. /// <summary>Writes description string for error values to log</summary>
  231. /// <param name="aError">Error value returned from an API call</param>
  232. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  233. int32_t WriteDebugErrorStringToLog(uint32_t CID, int32_t aError);
  234. /// <summary>Is a specific client connection ok?</summary>
  235. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  236. int32_t CheckConnection(uint32_t CID);
  237. /// <summary>Combines output of several spectrometers into one virtual spectrometer (to increase pulse rate for example)</summary>
  238. /// <param name="Devices">bit combination of spectrometers to combine</param>
  239. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  240. int32_t CombineSpectrometer(uint32_t CID, int32_t Devices);
  241. /// <summary></summary>
  242. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  243. /// <param name="Status">Structure with status information from spectrometers and connected detectors</param>
  244. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  245. int32_t GetSpectrometerStatus(uint32_t CID, int32_t SPU, TRTSpectrometerStatus& Status);
  246. /// <summary></summary>
  247. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  248. /// <param name="Det">Number of detector (1 in most cases)</param>
  249. /// <param name="aCoolingMode">Cooling mode (0=off, 1=on, 2=max. 3=heating, 4=unknown)</param>
  250. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  251. int32_t SetDetectorCoolingMode(uint32_t CID, int32_t SPU, int32_t Det, int32_t aCoolingMode);
  252. /// <summary></summary>
  253. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  254. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  255. int32_t ResetSpectrometerInterlock(uint32_t CID, int32_t SPU);
  256. /// <summary></summary>
  257. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  258. /// <param name="RealTime">Measure time in ms (0 means endless measurement)</param>
  259. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  260. int32_t StartSpectrumMeasurement(uint32_t CID, int32_t Device, uint32_t RealTime);
  261. /// <summary></summary>
  262. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  263. /// <param name="LifeTime">Life time in ms (>0)</param>
  264. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  265. int32_t StartSpectrumLifeTimeMeasurement(uint32_t CID, int32_t Device, uint32_t LifeTime);
  266. /// <summary></summary>
  267. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  268. /// <param name="StartEnergy">Lower spectrum region borders for counter measurement (in keV)</param>
  269. /// <param name="EndEnergy">Higher spectrum region borders for counter measurement (in keV)</param>
  270. /// <param name="Counts">Counter value for automatic measurement stop</param>
  271. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  272. int32_t StartSpectrumCounterMeasurement(uint32_t CID, int32_t SPU, double StartEnergy, double EndEnergy, uint32_t Counts);
  273. /// <summary></summary>
  274. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  275. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  276. int32_t StopSpectrumMeasurement(uint32_t CID, int32_t Device);
  277. /// <summary>Read status of ongoing spectrum aquisition</summary>
  278. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  279. /// <param name="Running">Aquisition active or not</param>
  280. /// <param name="State">State of aquisition in % (100 % means ready)</param>
  281. /// <param name="PulseRate">
  282. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  283. int32_t GetSpectrumMeasureState(uint32_t CID, int32_t Device, bool& Running, double& State, double& PulseRate);
  284. /// <summary>Read status of ongoing spectrum aquisition</summary>
  285. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  286. /// <param name="Running">Aquisition active or not</param>
  287. /// <param name="State">State of aquisition in % (100 % means ready)</param>
  288. /// <param name="PulseRate">current input pulse rate in cps</param>
  289. /// <param name="RealTime">current measure time in ms</param>
  290. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  291. int32_t GetSpectrumMeasureStateEx(uint32_t CID, int32_t Device, bool& Running, double& State, double& PulseRate, int32_t& RealTime);
  292. /// <summary>Read current spectrum from spectrometer to buffer</summary>
  293. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  294. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  295. int32_t ReadSpectrum(uint32_t CID, int32_t Device);
  296. /// <summary>Read current spectrometer configuration</summary>
  297. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  298. /// <param name="MaxEnergyIndex">Index of selected max energy setting</param>
  299. /// <param name="PulseThroughputIndex">Index of selected max throughput setting</param>
  300. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  301. int32_t GetSpectrometerConfiguration(uint32_t CID, int32_t SPU, uint32_t& MaxEnergyIndex, uint32_t& PulseThroughputIndex);
  302. /// <summary>Read current detector configuration</summary>
  303. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  304. /// <param name="Det">Number of detector (1 in most cases)</param>
  305. /// <param name="MaxEnergyIndex">Index of selected max energy setting</param>
  306. /// <param name="PulseThroughputIndex">Index of selected max throughput setting</param>
  307. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  308. int32_t GetSpectrometerConfigurationEx(uint32_t CID, int32_t SPU, int32_t Det, uint32_t& MaxEnergyIndex, uint32_t& PulseThroughputIndex);
  309. /// <summary>Set configuration for a given detector</summary>
  310. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  311. /// <param name="Det">Number of detector (1 in most cases)</param>
  312. /// <param name="MaxEnergyIndex">Index of selected max energy setting</param>
  313. /// <param name="PulseThroughputIndex">Index of selected max throughput setting</param>
  314. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  315. int32_t SetSpectrometerConfiguration(uint32_t CID, int32_t SPU, int32_t Det, const uint32_t MaxEnergyIndex, const uint32_t PulseThroughputIndex);
  316. /// <summary>Switch detectors into 'active' mode for a given spectrometer</summary>
  317. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  318. /// <param name="Detectors">Active Detectors as bitmask (1 shl 0, etc.)</param>
  319. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  320. int32_t SetActiveDetectors(uint32_t CID, int32_t SPU, const uint32_t Detectors);
  321. /// <summary>Read active detectors of a given spectrometer</summary>
  322. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  323. /// <param name="Detectors">Active Detectors as bitmask (1 shl 0, etc.)</param>
  324. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  325. int32_t GetActiveDetectors(uint32_t CID, int32_t SPU, uint32_t& Detectors);
  326. /// <summary></summary>
  327. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  328. /// <param name="Detectors">Available Detectors as bitmask (1 shl 0, etc.)</param>
  329. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  330. int32_t GetAvailableDetectors(uint32_t CID, int32_t SPU, uint32_t& Detectors);
  331. /// <summary>Ask for available WDS detetcors</summary>
  332. /// <param name="SPU">Number of spectrometer (1 in most cases)</param>
  333. /// <param name="Detectors">Available WDS detectors as bitmask (1 shl 0, etc.)
  334. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  335. int32_t GetAvailableWDSDetectors(uint32_t CID, int32_t SPU, uint32_t& Detectors);
  336. /// <summary></summary>
  337. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  338. int32_t GetHardwareConfiguration(uint32_t CID, TRTHardwareConfiguration& aHardwareConfiguration);
  339. /// <summary>Perform spectrometer eneryg/channel calibration</summary>
  340. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  341. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  342. int32_t CalibrateSpectrometer(uint32_t CID, int32_t Device, bool ShowProgress, PRTCalibSettings Settings, PRTCalibResults Results);
  343. /// <summary>Read a named parameter from spectrometer</summary>
  344. /// <param name="Device">Number of spectrometer (1 in most cases)</param></param>
  345. /// <param name="ParamName : Name of the parameter to read</param>
  346. // Current implemented names: 'MaxEnergy', 'PulseThroughput', 'DetectorTemperature' as 'Integer' or 'Double'</param>
  347. /// <param name="ParamType">Type of the parameter to read (Byte,Boolean,Word,Integer,Double,Memory)</param>
  348. /// <param name="Buffer">Pointer to variable of that type</param>
  349. /// <param name="BufSize">if ParamType is Memory than BufSize if size of the memory block described by 'Buffer'</param>
  350. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  351. int32_t GetSpectrometerParam(uint32_t CID, int32_t Device, char* ParamName, char* ParamType, void* Buffer, int32_t BufSize);
  352. /// <summary>Reads the amount of available spectrometers</summary>
  353. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  354. int32_t GetSpectrometerCount(uint32_t CID, int32_t& Value);
  355. /// <summary>Gets SpectrometerRanges (Pulserate and EnergyRange)</summary>
  356. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  357. int32_t GetSpectrometerRanges(uint32_t CID, int32_t SPU, int32_t Det, TRTDetectorRanges& aDetectorSettings);
  358. /// <summary>Read full parameter block of current spectrometer params (needed to create full Bruker spectrum)</summary>
  359. int32_t GetSpectrometerParams(uint32_t CID, int32_t SPU, void* Buffer, int32_t& BufSize);
  360. /// <summary></summary>
  361. /// <param name="Buffer">Number of buffer (1..n for spectrometer, 0 for loaded spectrum)
  362. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  363. int32_t GetSpectrum(uint32_t CID, int32_t Buffer, PRTSpectrumHeaderRec pSpectrumBuf, int32_t BufSize);
  364. /// <summary>Quantify spectrum in given buffer, returns</summary>
  365. /// <param name="Buffer">Number of buffer (1..n for spectrometer, 0 for loaded spectrum)</param>
  366. /// </param name="pMethodName">Name of the method file, this file must exist</param>
  367. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  368. int32_t QuantifySpectrum(uint32_t CID, int32_t Buffer, char* pMethodName, char* pParams, char* pResultBuf, int32_t ResultBufSize);
  369. /// <summary>Sends a RCL 2.2 command to spectrometer and returns the answer (see RCL 2.2 description of commands)</summary>
  370. /// <param name="Device">Number of spectrometer (1 in most cases)</param></param>
  371. /// <param name="Command">Pointer to zero terminated command string</param>
  372. /// <param name="Answer">Pointer buffer for zero terminated answer string</param>
  373. /// <param name="AnswerBufSize">Size of this buffer</param>
  374. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  375. int32_t SendRCLCommand(uint32_t CID, int32_t Device, char* pCommand, char* pAnswer, int32_t AnswerBufSize);
  376. /// <summary>Sends a RCL 2.2 command to spectrometer, does not wait for answer (see RCL 2.2 description of commands)</summary>
  377. /// <param name="Device">Number of spectrometer (1 in most cases)</param></param>
  378. /// <param name="Command">Pointer to zero terminated command string</param>
  379. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  380. int32_t SendRCLCommandOnly(uint32_t CID, int32_t Device, char* Command);
  381. /// <summary>Receives the answer of the above function</summary>
  382. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  383. /// <param name="Answer">Pointer buffer for zero terminated answer string</param>
  384. /// <param name="AnswerBufSize">Size of this buffer</param>
  385. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  386. int32_t ReceiveRCLAnswer(uint32_t CID, int32_t Device, char* Answer, int32_t AnswerBufSize);
  387. /// <summary>Interupts hardware communication to specified device until 'UnlockSpectrometer' is called</summary>
  388. /// <param name="Device">Number of spectrometer (1 in most cases)
  389. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  390. int32_t LockSpectrometer(uint32_t CID, int32_t Device);
  391. /// <summary></summary>
  392. /// <param name="Device">Number of spectrometer (1 in most cases)</param>
  393. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  394. int32_t UnlockSpectrometer(uint32_t CID, int32_t Device);
  395. /// <summary>Load spectrum from file to buffer</summary>
  396. /// <param name="pFilename">Complete filename for spectrum (normally with *.spx extension)</param>
  397. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  398. int32_t LoadSpectrum(uint32_t CID, char* pFileName);
  399. /// <summary>Send spectrum back to 'loaded' buffer</summary>
  400. /// <param name="Spectrum">Bruker spectrum buffer</param>
  401. /// <param name="BufferSize">size of spectrum buffer</param>
  402. // Remarks : if one wants to use that function one has to build a complete Bruker spectrum with
  403. // functions 'GetSpectrum', 'GetSpectrometerParams' and 'CreateSpectrum'
  404. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  405. int32_t PutSpectrum(uint32_t CID, void* Spectrum, int32_t BufSize);
  406. /// <summary>Save spectrum buffer to file</summary>
  407. /// <param name="pFilename">Complete filename for spectrum (normally with *.spx extension)</param>
  408. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  409. int32_t SaveSpectrum(uint32_t CID, int32_t Buffer, char* pFileName);
  410. /// <summary>Create a complete Bruker spectrum from</summary>
  411. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  412. int32_t CreateSpectrum(char* SpectrometerParams, PRTSpectrumHeaderRec SpectrumData, char* ResultData, int32_t& ResultSize);
  413. /// <summary></summary>
  414. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  415. int32_t GetCorrectedSpectrum(char* SpectrometerParams, PRTSpectrumHeaderRec Spectrum, double* ResultData);
  416. /// <summary>Show spectrum in Esprit UI</summary>
  417. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  418. int32_t ShowSpectrum(uint32_t CID, int32_t Buffer, char* Name);
  419. /// <summary>Delete spectrum from presentation in UI</summary>
  420. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  421. int32_t DeleteSpectrum(uint32_t CID, char* aName);
  422. /// <summary>Create and return a graphic for spectrum presentation</summary>
  423. /// <param name="Buffer">Buffer index (0 for loaded spectrum buffer, > 0 for spectrometer buffers)</param>
  424. /// <param name="Width">Requested graphic width</param>
  425. /// <param name="Height">Requested graphic Height</param>
  426. /// <param name="Format">Requested grapghic format (bmp, png, jpeg, tif)</param>
  427. /// <param name="ResultBuf">should be able to save the whole image</param>
  428. /// <param name="ResultBufSize">input is maximum, output is really used</param>
  429. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  430. int32_t GetSpectrumGraphic(uint32_t CID, int32_t Buffer, int32_t Width, int32_t Height, char* Format, void* ResultBuf, uint32_t& ResultBufSize);
  431. /// <summary>Get a list of avaliable hardware profiles from client</summary>
  432. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  433. int32_t GetHardwareProfiles(uint32_t CID, char* pProfiles, int32_t BufSize);
  434. /// <summary>Set a specific hardware profile</summary>
  435. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  436. int32_t SetHardwareProfile(uint32_t CID, char* pProfile);
  437. /// <summary>Get a list of avaliable quantification methods</summary>
  438. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  439. int32_t GetQuantificationMethods(uint32_t CID, bool AutomaticOnly, char* pMethods, int32_t BufSize);
  440. /// <summary>Get a list of predefined elements from a given quant method</summary>
  441. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  442. int32_t GetQuantificationMethodElements(uint32_t CID, char* MethodName, char* ElementBuffer, int32_t BufSize);
  443. /// <summary>Call method editor for a given quant method</summary>
  444. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  445. int32_t EditQuantificationMethod(uint32_t CID, char* MethodName);
  446. /// <summary>Loads a method and saves it again. purpose: rename, conversion from mtd into mtdx</summary>
  447. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  448. int32_t CopyQuantificationMethod(uint32_t CID, char* MethodName, char* TargetName, bool ToProfile);
  449. /// <summary>Get a channel region for desired element and X ray line</summary>
  450. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  451. int32_t GetRegionForElement(uint32_t CID, int32_t Buffer, char* Params, char* ResultBuf, int32_t ResultBufSize);
  452. // Xray tube functions
  453. /// <summary></summary>
  454. /// <param name="HighVoltage">tube voltate [Volt]</param>
  455. /// <param name="Current">tube current [µA]</param>
  456. /// <param name="FilterIndex">index of selected filter</param>
  457. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  458. int32_t XRayTubeSetConfiguration(uint32_t CID, int32_t Tube, uint32_t HighVoltage, uint32_t Current, uint32_t FilterIndex);
  459. /// <summary></summary>
  460. /// <param name="HighVoltage">tube voltate [Volt]</param>
  461. /// <param name="Current">tube current [µA]</param>
  462. /// <param name="FilterIndex">index of selected filter</param>
  463. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  464. int32_t XRayTubeGetState(uint32_t CID, int32_t Tube, uint32_t& HighVoltage, uint32_t& Current, uint32_t& FilterIndex, bool& ShutterOpen);
  465. /// <summary></summary>
  466. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  467. int32_t XRayTubeOpenShutter(uint32_t CID, int32_t Tube);
  468. /// <summary></summary>
  469. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  470. int32_t XRayTubeCloseShutter(uint32_t CID, int32_t Tube);
  471. /// <summary></summary>
  472. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  473. int32_t XRayTubeHVOn(uint32_t CID, int32_t Tube, int32_t DestHV, int32_t DestCurrent, bool HVOn);
  474. /// <summary></summary>
  475. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  476. int32_t XRaySetActiveTube(uint32_t CID, int32_t Tube);
  477. /// <summary></summary>
  478. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  479. int32_t XRayGetActiveTube(uint32_t CID, int32_t& Tube);
  480. /// <summary></summary>
  481. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  482. int32_t SetImageExportParameter(uint32_t CID, int32_t ExportImageWidth, bool ExportWithOverlay);
  483. // Hypermap functions, function 'HyMapStart' is specific for Esprit/M4
  484. /// <summary></summary>
  485. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  486. int32_t HyMapStop(uint32_t CID, bool WaitForFrameEnd);
  487. /// <summary></summary>
  488. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  489. int32_t HyMapClearDatabase(uint32_t CID);
  490. /// <summary>Query status of a hypermap measurement</summary>
  491. /// <param name="Running">acquisition active or not</param>
  492. /// <param name="MeasureState">state of acquisition in %</param>
  493. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  494. int32_t HyMapGetState(uint32_t CID, bool& Running, double& MeasureState);
  495. /// <summary>Query status of a hypermap measurement</summary>
  496. /// <param name="Running">acquisition active or not</param>
  497. /// <param name="MeasureState">state of acquisition in %</param>
  498. /// <param name="CurrentLine">line which is currently scanned (0...map height-1)</param>
  499. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  500. int32_t HyMapGetStateEx(uint32_t CID, bool& Running, double& MeasureState, int32_t& CurrentLine);
  501. /// <summary>Query spectrum from a specific X/Y location in the map</summary>
  502. /// <param name="X">X coordinate</param>
  503. /// <param name="Y">Y coordinate</param>
  504. /// <param name="Corrected">Correct the spectrum for detector artefacts or not</param>
  505. /// <param name="SpectrumBuffer">pointer to memory, must have space for one full spectrum</param>
  506. /// <param name="BufferSize">preallocated size of the spectrum buffer, recommended is a size of 64kB</param>
  507. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  508. int32_t HyMapGetXYSpectrum(uint32_t CID, int32_t X, int32_t Y, bool Corrected, PRTSpectrumHeaderRec SpectrumBuffer, int32_t BufferSize);
  509. /// <summary>Query spectra from a specific location in the map</summary>
  510. /// <param name="X">X coordinate</param>
  511. /// <param name="Y">Y coordinate</param>
  512. /// <param name="Count">Number of spectra with increasing X coordinate on line Y</param>
  513. /// <param name="Corrected">Correct the spectrum for detector artefacts or not</param>
  514. /// <param name="SpectrumBuffer">pointer to array of pointers for spectra, must have space for 'Count' pointers, each with allocated space for a full spectrum</param>
  515. /// <param name="BufferSize">preallocated size of the spectrum buffer</param>
  516. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  517. int32_t HyMapGetLineSpectra(uint32_t CID, int32_t X, int32_t Y, int32_t Count, bool Corrected, PPointerArray SpectrumBuffer, int32_t BufferSize);
  518. /// <summary>Query spectra from a specific location in the map, spectra are transmitted compressed internally. Funcction is much faster than "HyMapGetLineSpectra"</summary>
  519. /// <param name="X">X coordinate</param>
  520. /// <param name="Y">Y coordinate</param>
  521. /// <param name="Count">Number of spectra with increasing X coordinate on line Y</param>
  522. /// <param name="Corrected">Correct the spectrum for detector artefacts or not</param>
  523. /// <param name="SpectrumBuffer">pointer to array of pointers for spectra, must have space for 'Count' pointers, each with allocated space for a full spectrum</param>
  524. /// <param name="BufferSize">preallocated size of the spectrum buffer</param>
  525. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  526. int32_t HyMapGetCompressedLineSpectra(uint32_t CID, int32_t X, int32_t Y, int32_t Count, bool Corrected, PPointerArray SpectrumBuffer, int32_t BufferSize);
  527. /// <summary></summary>
  528. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  529. int32_t HyMapQuantifySpectra(uint32_t CID, PPointArray Points, int32_t PointCount, int32_t Binning, char* MethodName, char* Params, char* ResultBuf, int32_t ResultBufSize);
  530. /// <summary></summary>
  531. /// <param name="aFileName">file name</param>
  532. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  533. int32_t HyMapSaveToFile(uint32_t CID, char* aFileName);
  534. /// <summary>Load a hypermap file (*.bcf)</summary>
  535. /// <param name="aFileName">file name</param>
  536. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  537. int32_t HyMapLoadFromFile(unsigned _int32 CID, char* aFileName, int32_t& Width, int32_t& Height, int32_t& DetCount, int32_t& ImgCount);
  538. /// <summary></summary>
  539. /// <param name="SpectrumBuffer">pointer to memory, must have space for one full spectrum</param>
  540. /// <param name="BufferSize">size of the above buffer</param>
  541. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  542. int32_t HyMapGetMaxPixelSpectrum(uint32_t CID, PRTSpectrumHeaderRec SpectrumBuffer, int32_t BufferSize);
  543. #ifdef BRUKERAPIESPRITH
  544. int32_t HyMapQuantifyMaxPixelSpectrum(uint32_t CID, char* MethodName, char* Params, char* ResultBuf, int32_t ResultBufSize);
  545. #endif
  546. /// <summary></summary>
  547. /// <param name="pMethodName">name of method to be used</param>
  548. /// <param name="pElementBuffer">buffer to get a list of atomic numbers as result of element identification</param>
  549. /// <param name="ElementBufSize">size of element buffer</param>
  550. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  551. int32_t HyMapAutoIdent(uint32_t CID, char* pMethodName, char* pElementBuffer, int32_t ElementBufSize);
  552. /// <summary></summary>
  553. /// <param name="Format">Requested graphic format (bmp, png, jpeg, tif)</param>
  554. /// <param name="ImgChannel">the plane to be shown</param>
  555. /// <param name="Buffer">should be able to save the whole image</param>
  556. /// <param name="Buffersize">input is maximum, output is really used</param>
  557. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  558. int32_t HyMapGetImage(uint32_t CID, char* Format, int32_t ImgChannel, void* Buffer, uint32_t& BufferSize);
  559. /// <summary></summary>
  560. /// <param name="ElementIndex">index of the elemen to be shown</param>
  561. /// <param name="Buffer">should be able to save the whole image</param>
  562. /// <param name="Buffersiz">input is maximum, output is really used</param>
  563. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  564. int32_t HyMapGetElementData(uint32_t CID, int32_t ElementIndex, void* Buffer, uint32_t& BufferSize);
  565. /// <summary></summary>
  566. /// <param name="Format">Requested graphic format (bmp, png, jpeg, tif)</param>
  567. /// <param name="ElementIndex">the plane to be shown</param>
  568. /// <param name="Buffer">should be able to save the whole image</param>
  569. /// <param name="Buffersize">input is maximum, output is really used</param>
  570. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  571. int32_t HyMapGetElementImage(uint32_t CID, char* Format, int32_t ElementIndex, void* Buffer, uint32_t& BufferSize);
  572. /// <summary></summary>
  573. /// <param name="Format">Requested graphic format (bmp, png, jpeg, tif)</param>
  574. /// <param name="Buffer">should be able to save the whole image</param>
  575. /// <param name="Buffersize">input is maximum, output is really used</param>
  576. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  577. int32_t HyMapGetMixedMapImage(uint32_t CID, char* Format, void* Buffer, uint32_t& BufferSize);
  578. /// <summary></summary>
  579. /// <param name="ImgChannel">Image channel</param>
  580. /// <param name="aFileName">file name</param>
  581. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  582. int32_t HyMapSaveImage(uint32_t CID, int32_t ImgChannel, char* aFileName);
  583. /// <summary></summary>
  584. /// <param name="ElementIndex">Plane to be shown</param>
  585. /// <param name="aFileName">file name</param>
  586. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  587. int32_t HyMapSaveElementImage(uint32_t CID, int32_t ElementIndex, char* aFileName);
  588. /// <summary></summary>
  589. /// <param name="aFileName">file name</param>
  590. /// <returns>Function call sucessful or not (0 = success, otherwise error)</returns>
  591. int32_t HyMapSaveMixedMapImage(uint32_t CID, char* aFileName);
  592. }
  593. #endif // BrukerAPICommonFunctionsH