Bruker.API.CommonFunctions.cs 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. using System;
  2. using System.IO;
  3. using System.Runtime.InteropServices;
  4. using System.Windows.Forms;
  5. namespace Bruker.API
  6. {
  7. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
  8. public struct TRTHardwareConfiguration
  9. {
  10. [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I4, SizeConst = 4)]
  11. public int[] EDSDetector; // [0..3] is SPU
  12. [MarshalAs(UnmanagedType.I1)]
  13. public bool EBSD; // EBSD present
  14. [MarshalAs(UnmanagedType.I1)]
  15. public bool Raster; // Scan engine present
  16. public int XrayTubes; // Number of Xray tubes
  17. }
  18. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  19. public struct TRTSpectrumHeaderRec
  20. {
  21. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=25)] public string Identifier; // 'Rontec XRay spectrum'
  22. public int Version; // Version information
  23. public int Size; // Size in byte
  24. public double DateTime; // Delphi 5.0 version of date and time
  25. public int ChannelCount; //
  26. public int ChannelOffset; // First channel index
  27. public double CalibrationAbs; // Energy of first channel
  28. public double CalibrationLin; // keV per channel
  29. public double SigmaAbs; // Sigma^2 energy calibration
  30. public double SigmaLin;
  31. public int RealTime; // real measure time in ms
  32. public int LifeTime; // life time in ms
  33. }
  34. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  35. public struct TRTCalibSettings
  36. {
  37. public int Version; // Version of record structure, should be '1' at the moment
  38. public int Element1;
  39. public string Line1;
  40. public double Energy1;
  41. public int Element2;
  42. public string Line2;
  43. public double Energy2;
  44. public int MaxTime; // Maximum time to calibrate in ms, '0' indicates to use a internal statistics to decide to stop
  45. public bool ShowProgress; // Show progress information
  46. }
  47. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  48. public struct TRTCalibResults
  49. {
  50. public int Version; // Version of record structure, should be '1' at the moment
  51. public double CalibLin; // Channel with in keV
  52. public double CalibAbs; // Energy offset in keV
  53. public double FWHM; // Mn FWHM in keV
  54. public double Fano; // Fano factor
  55. }
  56. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  57. public struct TRTSpectrometerRanges
  58. {
  59. [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I4, SizeConst = 8)]
  60. public int[] MaxEnergy;
  61. [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I4, SizeConst = 8)]
  62. public int[] PulseThroughPut;
  63. public int EnergyIndexCount;
  64. public int PulseIndexCount;
  65. }
  66. // structure to describe Quantax start options in 'OpenClientEx'
  67. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  68. public struct TOpenClientOptions
  69. {
  70. public int Version; // Version of record structure, should be '1' at the moment
  71. public int GUIMode; // '0'=no GUI, '1'=full GUI, '2'=reduced GUI (spectrum chart only)
  72. public bool StartNew; // start new instance of Quantax
  73. }
  74. // structure for Delphi's TPoint
  75. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  76. public struct TPoint
  77. {
  78. public int X;
  79. public int Y;
  80. }
  81. // structure for Delphi's TPointArray
  82. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  83. public struct TPointArray
  84. {
  85. public TPoint[] Points;
  86. }
  87. // structure for Delphi's TPointerArray
  88. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  89. public struct TPointerArray
  90. {
  91. public TRTSpectrumHeaderRec[] Pointers;
  92. }
  93. /// <summary>
  94. /// BrukerException-Class
  95. /// </summary>
  96. public class BrukerException : Exception
  97. {
  98. public BrukerException(string message) : base(message) { }
  99. }
  100. /// <summary>
  101. /// CommonFunctions-Class
  102. /// </summary>
  103. public class CommonFunctions
  104. {
  105. #if WIN32
  106. const string rtdll = "Bruker.API.Esprit.DLL";
  107. #else
  108. const string rtdll = "Bruker.API.Esprit64.DLL";
  109. #endif
  110. // Error constants generated from client program
  111. public const int IFC_ERROR_IN_EXECUTION = -1;
  112. public const int IFC_ERROR_WRONG_PARAMETER = -2;
  113. public const int IFC_ERROR_SPECTRUM_BUFFER_EMPTY = -3;
  114. public const int IFC_ERROR_PARAMETER_MISSED = -4;
  115. public const int IFC_ERROR_TOO_MANY_PARAMETERS = -5;
  116. public const int IFC_ERROR_USER_TERMINATED = -6;
  117. public const int IFC_ERROR_TIMEOUT = -7;
  118. public const int IFC_ERROR_UNKNOWN_VALUE_NAME = -8;
  119. public const int IFC_ERROR_WRONG_VALUE_TYPE = -9;
  120. public const int IFC_ERROR_WRONG_LICENCE = -10;
  121. public const int IFC_ERROR_RESULT_BUFFER_INSUFFICIENT= -11;
  122. public const int IFC_ERROR_HARDWARE_LOCKED = -12;
  123. public const int IFC_ERROR_PARAMETER_MISSED_1 = -51;
  124. public const int IFC_ERROR_FUNCTION_NOT_IMPLEMENTED = -52;
  125. // Errors coming from OpenClient()
  126. public const int CONN_ERROR_UNKNOWN = -21;
  127. public const int CONN_ERROR_INTERFACE_NOT_CONNECTED = -22;
  128. public const int CONN_ERROR_PARAMETER_MISSED = -23;
  129. public const int CONN_ERROR_ANSWER_TIMEOUT = -24;
  130. public const int CONN_ERROR_SERVER_NOT_RESPONDING = -25;
  131. public const int CONN_ERROR_RESULT_MISSED = -26;
  132. public const int CONN_ERROR_NO_INTERFACE = -27;
  133. public const int CONN_ERROR_INVALID_LOGIN = -28;
  134. public const int CONN_ERROR_NO_CONNECTION_TO_SERVER = -29;
  135. public const int CONN_ERROR_SERVER = -30;
  136. public const int CONN_ERROR_ACTION_ABORTED = -31;
  137. // Error constants generated from Bruker.API.XXX.dll
  138. public const int ERROR_WRONG_PARAMETER = -101;
  139. public const int ERROR_FILE_NOT_EXIST = -102;
  140. public const int ERROR_NO_CONNECTION = -103;
  141. public const int ERROR_NO_ANSWER = -104;
  142. public const int ERROR_CAN_NOT_START_PROCESS = -105;
  143. public const int ERROR_INVALID_RESULT_DATA = -106;
  144. public const int ERROR_SETTINGS_NOT_FOUND = -107;
  145. public const int ERROR_NO_SERVER_CONNECTION = -108; // no direct call to server possible (used in '..Direct' calls
  146. public const int ERROR_IN_EXECUTION = -109;
  147. // State constants generated from Bruker.API.XXX.dll
  148. public const int STATE_WAS_RUNNING_BEFORE = -201;
  149. //Element Names
  150. public static string[] ElementName = { "null", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al",
  151. "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co",
  152. "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb",
  153. "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs",
  154. "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm",
  155. "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi",
  156. "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk",
  157. "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg",
  158. "Cn", "Uut", "Fl", "Uup", "Lv", "Uus", "Uuo" };
  159. /// <summary>
  160. /// Handler for BrukerApiReturnValues
  161. /// if BrukerApiReturnValue <> 0, an BrukerException will be generated.
  162. /// </summary>
  163. /// <param name="BrukerApiCallReturnValue">the Return Value of BrukerApi-Function-Call </param>
  164. /// <returns>BrukerApiCallReturnValue</returns>
  165. public static int HandleReturnValue(int BrukerApiCallReturnValue)
  166. {
  167. if (BrukerApiCallReturnValue == -1)
  168. throw new BrukerException("Bruker.API: IFC_ERROR_IN_EXECUTION");
  169. else if (BrukerApiCallReturnValue == -2)
  170. throw new BrukerException("Bruker.API: IFC_ERROR_WRONG_PARAMETER");
  171. else if (BrukerApiCallReturnValue == -3)
  172. throw new BrukerException("Bruker.API: IFC_ERROR_SPECTRUM_BUFFER_EMPTY");
  173. else if (BrukerApiCallReturnValue == -4)
  174. throw new BrukerException("Bruker.API: FC_ERROR_PARAMETER_MISSED");
  175. else if (BrukerApiCallReturnValue == -5)
  176. throw new BrukerException("Bruker.API: IFC_ERROR_TOO_MANY_PARAMETERS");
  177. else if (BrukerApiCallReturnValue == -6)
  178. throw new BrukerException("Bruker.API: IFC_ERROR_USER_TERMINATED");
  179. else if (BrukerApiCallReturnValue == -7)
  180. throw new BrukerException("Bruker.API: IFC_ERROR_TIMEOUT");
  181. else if (BrukerApiCallReturnValue == -8)
  182. throw new BrukerException("Bruker.API: IFC_ERROR_UNKNOWN_VALUE_NAME");
  183. else if (BrukerApiCallReturnValue == -9)
  184. throw new BrukerException("Bruker.API: IFC_ERROR_WRONG_VALUE_TYPE");
  185. else if (BrukerApiCallReturnValue == -10)
  186. throw new BrukerException("Bruker.API: IFC_ERROR_WRONG_LICENCE");
  187. else if (BrukerApiCallReturnValue == -11)
  188. throw new BrukerException("Bruker.API: IFC_ERROR_RESULT_BUFFER_INSUFFICIENT");
  189. else if (BrukerApiCallReturnValue == -12)
  190. throw new BrukerException("Bruker.API: IFC_ERROR_HARDWARE_LOCKED");
  191. else if (BrukerApiCallReturnValue == -51)
  192. throw new BrukerException("Bruker.API: IFC_ERROR_PARAMETER_MISSED_1");
  193. else if (BrukerApiCallReturnValue == -52)
  194. throw new BrukerException("Bruker.API: IFC_ERROR_FUNCTION_NOT_IMPLEMENTED");
  195. else if (BrukerApiCallReturnValue == -21)
  196. throw new BrukerException("Bruker.API: CONN_ERROR_UNKNOWN");
  197. else if (BrukerApiCallReturnValue == -22)
  198. throw new BrukerException("Bruker.API: CONN_ERROR_INTERFACE_NOT_CONNECTED");
  199. else if (BrukerApiCallReturnValue == -23)
  200. throw new BrukerException("Bruker.API: CONN_ERROR_PARAMETER_MISSED");
  201. else if (BrukerApiCallReturnValue == -24)
  202. throw new BrukerException("Bruker.API: CONN_ERROR_ANSWER_TIMEOUT");
  203. else if (BrukerApiCallReturnValue == -25)
  204. throw new BrukerException("Bruker.API: CONN_ERROR_SERVER_NOT_RESPONDING");
  205. else if (BrukerApiCallReturnValue == -26)
  206. throw new BrukerException("Bruker.API: CONN_ERROR_RESULT_MISSED");
  207. else if (BrukerApiCallReturnValue == -27)
  208. throw new BrukerException("Bruker.API: CONN_ERROR_NO_INTERFACE");
  209. else if (BrukerApiCallReturnValue == -28)
  210. throw new BrukerException("Bruker.API: CONN_ERROR_INVALID_LOGIN");
  211. else if (BrukerApiCallReturnValue == -29)
  212. throw new BrukerException("Bruker.API: CONN_ERROR_NO_CONNECTION_TO_SERVER");
  213. else if (BrukerApiCallReturnValue == -30)
  214. throw new BrukerException("Bruker.API: CONN_ERROR_SERVER");
  215. else if (BrukerApiCallReturnValue == -31)
  216. throw new BrukerException("Bruker.API: CONN_ERROR_ACTION_ABORTED");
  217. else if (BrukerApiCallReturnValue == -101)
  218. throw new BrukerException("Bruker.API: ERROR_WRONG_PARAMETER");
  219. else if (BrukerApiCallReturnValue == -102)
  220. throw new BrukerException("Bruker.API: ERROR_FILE_NOT_EXIST");
  221. else if (BrukerApiCallReturnValue == -103)
  222. throw new BrukerException("Bruker.API: ERROR_NO_CONNECTION");
  223. else if (BrukerApiCallReturnValue == -104)
  224. throw new BrukerException("Bruker.API: ERROR_NO_ANSWER");
  225. else if (BrukerApiCallReturnValue == -105)
  226. throw new BrukerException("Bruker.API: ERROR_CAN_NOT_START_PROCESS");
  227. else if (BrukerApiCallReturnValue == -106)
  228. throw new BrukerException("Bruker.API: ERROR_INVALID_RESULT_DATA");
  229. else if (BrukerApiCallReturnValue == -107)
  230. throw new BrukerException("Bruker.API: ERROR_SETTINGS_NOT_FOUND");
  231. else if (BrukerApiCallReturnValue == -108)
  232. throw new BrukerException("Bruker.API: ERROR_NO_SERVER_CONNECTION");
  233. else if (BrukerApiCallReturnValue == -109)
  234. throw new BrukerException("ERROR_IN_EXECUTION");
  235. else if (BrukerApiCallReturnValue == -201)
  236. throw new BrukerException("Bruker.API: STATE_WAS_RUNNING_BEFORE");
  237. else if (BrukerApiCallReturnValue != 0)
  238. throw new BrukerException("Bruker.API: Unknown Bruker Error #" + BrukerApiCallReturnValue.ToString());
  239. return BrukerApiCallReturnValue;
  240. }
  241. public static string RclCommand(int Device, string Command)
  242. {
  243. string s = "".PadRight(1000);
  244. int r = SendRCLCommand(FCID, Device, Command, ref s, 1000);
  245. return s;
  246. }
  247. //----------------------------------------------------------------------------------
  248. // Interface functions of Bruker.API.XXX library
  249. //----------------------------------------------------------------------------------
  250. /// <summary>
  251. /// Set log level for internal API logging
  252. /// 0 : no logging
  253. /// 1 : Error logging
  254. /// 2 : Warning logging
  255. /// 3 : All logging
  256. /// </summary>
  257. /// <param name="Value"></param>
  258. /// <returns>Error code (0 = no error)</returns>
  259. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  260. public static extern int SetLogLevel(
  261. int Value);
  262. /// <summary>
  263. /// Ask for log data, transfered log data are removed from internal API log after this call
  264. /// </summary>
  265. /// <param name="Language"></param>
  266. /// <returns>Error code (0 = no error)</returns>
  267. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  268. public static extern int GetLogData(
  269. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Buffer,
  270. ref uint BufferSize);
  271. /// <summary>
  272. /// Clear API log data
  273. /// </summary>
  274. /// <returns>Error code (0 = no error)</returns>
  275. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  276. public static extern int ClearLogData();
  277. /// <summary>
  278. /// Save API log data to file
  279. /// </summary>
  280. /// <param name="FileName"></param>
  281. /// <returns>Error code (0 = no error)</returns>
  282. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  283. public static extern int SaveLogData(
  284. [MarshalAs(UnmanagedType.LPWStr)] string FileName);
  285. /// <summary>
  286. /// Set active language for interface, 'ge' for german, any other for english
  287. /// </summary>
  288. /// <param name="Language"></param>
  289. /// <returns>Error code (0 = no error)</returns>
  290. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  291. public static extern int SetLanguage(
  292. string Language);
  293. /// <summary>
  294. /// Query all known servers for which can be used by client program
  295. /// </summary>
  296. /// <param name="pServerList"></param>
  297. /// <param name="BufSize"></param>
  298. /// <returns>Error code (0 = no error)</returns>
  299. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  300. public static extern int QueryServers(
  301. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pServerList,
  302. int BufSize);
  303. /// <summary>
  304. /// Query all running client programs for connected servers
  305. /// </summary>
  306. /// <param name="pServer"></param>
  307. /// <param name="pClientBuf"></param>
  308. /// <param name="BufSize"></param>
  309. /// <returns>Error code (0 = no error)</returns>
  310. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  311. public static extern int QueryUser(
  312. string pServer,
  313. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pClientBuf,
  314. int BufSize);
  315. /// <summary>
  316. /// Start Quantax program and login automatically
  317. /// </summary>
  318. /// <param name="pServer">Server name</param>
  319. /// <param name="pUser">User name</param>
  320. /// <param name="pPassword">Password of user with User Name</param>
  321. /// <param name="StartNew"></param>
  322. /// <param name="GUI">Whether to start the user interface or not</param>
  323. /// <param name="CID">Connection Id</param>
  324. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  325. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  326. public static extern int OpenClient(
  327. string pServer,
  328. string pUser,
  329. string pPassword,
  330. bool StartNew,
  331. bool GUI,
  332. ref uint CID);
  333. /// <summary>
  334. /// Start Quantax programm and login automatically
  335. /// </summary>
  336. /// <param name="pServer">Server name</param>
  337. /// <param name="pUser">User Name</param>
  338. /// <param name="pPassword">Password of User with User Name</param>
  339. /// <param name="Options">TOpenClientOptions Structur</param>
  340. /// <param name="CID">Connection Id</param>
  341. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  342. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  343. public static extern int OpenClientEx(
  344. string pServer,
  345. string pUser,
  346. string pPassword,
  347. ref TOpenClientOptions Options,
  348. ref uint CID);
  349. /// <summary>
  350. /// Start Quantax programm and login automatically
  351. /// </summary>
  352. /// <param name="pServer">Server name</param>
  353. /// <param name="pUser">User Name</param>
  354. /// <param name="pPassword">Password of User with User Name</param>
  355. /// <param name="Options">TOpenClientOptions Structur</param>
  356. /// <param name="CID">Connection Id</param>
  357. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  358. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  359. public static extern int OpenClientTCP(
  360. string pServer,
  361. string pUser,
  362. string pPassword,
  363. string pHost,
  364. ushort pPort,
  365. ref TOpenClientOptions Options,
  366. ref uint CID);
  367. /// <summary>
  368. /// query some information about a specific connection
  369. /// </summary>
  370. /// <param name="CID">Connection Id</param>
  371. /// <param name="pInfo">StringBuffer (contains informations about connection</param>
  372. /// <param name="BufSize">Size of Buffer</param>
  373. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  374. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  375. public static extern int QueryInfo(
  376. uint CID,
  377. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pInfo,
  378. int BufSize);
  379. /// <summary>
  380. /// Close corrent connection
  381. /// </summary>
  382. /// <param name="CID">Connection Id</param>
  383. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  384. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  385. public static extern int CloseConnection(
  386. uint CID);
  387. /// <summary>
  388. /// Stop Quantax
  389. /// </summary>
  390. /// <param name="CID">Connection Id</param>
  391. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  392. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  393. public static extern int CloseClient(
  394. uint CID);
  395. /// <summary>
  396. /// Is a specific client connection ok?
  397. /// </summary>
  398. /// <param name="CID">Connection Id</param>
  399. /// <returns>0, if connection ok, otherwise error-no</returns>
  400. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  401. public static extern int CheckConnection(
  402. uint CID);
  403. /// <summary>
  404. /// Combine Spectrometer
  405. /// </summary>
  406. /// <param name="CID">Connection Id</param>
  407. /// <param name="Devices">bit combination of spectrometers to combine</param>
  408. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  409. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  410. public static extern int CombineSpectrometer(
  411. uint CID,
  412. int Devices);
  413. /// <summary>
  414. /// Starts Realtime Measurement
  415. /// </summary>
  416. /// <param name="CID">Connection Id</param>
  417. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  418. /// <param name="RealTime">Measure time in ms ( 0 means endless measurement )</param>
  419. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  420. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  421. public static extern int StartSpectrumMeasurement(
  422. uint CID,
  423. int Device,
  424. int RealTime);
  425. /// <summary>
  426. /// Starts Lifetime Measurement
  427. /// </summary>
  428. /// <param name="CID">Connection Id</param>
  429. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  430. /// <param name="LifeTime">Life time in ms ( > 0 )</param>
  431. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  432. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  433. public static extern int StartSpectrumLifeTimeMeasurement(
  434. uint CID,
  435. int Device,
  436. int LifeTime);
  437. /// <summary>
  438. /// Starts Counter Measuremnet
  439. /// </summary>
  440. /// <param name="CID">Connection Id</param>
  441. /// <param name="SPU">Number of spectrometer ( 1 in most cases )</param>
  442. /// <param name="StartEnergy">Spectrum region low border for counter measurement (in keV)</param>
  443. /// <param name="EndEnergy">Spectrum region high border for counter measurement (in keV)</param>
  444. /// <param name="Counts">Counter value for automatic measurement stop</param>
  445. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  446. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  447. public static extern int StartSpectrumCounterMeasurement(
  448. uint CID,
  449. int SPU,
  450. double StartEnergy,
  451. double EndEnergy,
  452. int Counts);
  453. /// <summary>
  454. /// Stops current Measurement
  455. /// </summary>
  456. /// <param name="CID">Connection Id</param>
  457. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  458. /// <returns>Function call sucessful or not ( 0 = success, otherwise error ) </returns>
  459. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  460. public static extern int StopSpectrumMeasurement(
  461. uint CID,
  462. int Device);
  463. /// <summary>
  464. /// Read some values about current aquisition
  465. /// </summary>
  466. /// <param name="CID">Connection Id</param>
  467. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  468. /// <param name="Running">Aquisition active or not</param>
  469. /// <param name="State">State of aquisition in % ( 100 % means ready )</param>
  470. /// <param name="PulseRate"></param>
  471. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  472. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  473. public static extern int GetSpectrumMeasureState(
  474. uint CID,
  475. int Device,
  476. ref bool Running,
  477. ref double State,
  478. ref double PulseRate);
  479. /// <summary>
  480. /// Read some more values about current aquisition
  481. /// </summary>
  482. /// <param name="CID">Connection Id</param>
  483. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  484. /// <param name="Running">Aquisition active or not</param>
  485. /// <param name="State">State of aquisition in % ( 100 % means ready )</param>
  486. /// <param name="PulseRate">current input pulse rate in cps</param>
  487. /// <param name="RealTime">current measure time in ms</param>
  488. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  489. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  490. public static extern int GetSpectrumMeasureStateEx(
  491. uint CID,
  492. int Device,
  493. ref bool Running,
  494. ref double State,
  495. ref double PulseRate,
  496. ref int RealTime);
  497. /// <summary>
  498. /// Read current spectrum from spectrometer to buffer
  499. /// </summary>
  500. /// <param name="CID">Connection Id</param>
  501. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  502. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  503. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  504. public static extern int ReadSpectrum(
  505. uint CID,
  506. int Device);
  507. /// <summary>
  508. /// Get Spectrometer Configuration
  509. /// </summary>
  510. /// <param name="CID">Connection Id</param>
  511. /// <param name="SPU"></param>
  512. /// <param name="MaxEnergy"></param>
  513. /// <param name="PulseThroughput"></param>
  514. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  515. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  516. public static extern int GetSpectrometerConfiguration(
  517. uint CID,
  518. int SPU,
  519. ref uint MaxEnergy,
  520. ref uint PulseThroughput);
  521. /// <summary>
  522. /// Get Spectrometer Configuration
  523. /// </summary>
  524. /// <param name="CID">Connection Id</param>
  525. /// <param name="SPU"></param>
  526. /// <param name="Det">Detector-Number</param>
  527. /// <param name="MaxEnergy"></param>
  528. /// <param name="PulseThroughput"></param>
  529. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  530. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  531. public static extern int GetSpectrometerConfigurationEx(
  532. uint CID,
  533. int SPU,
  534. int Det,
  535. ref uint MaxEnergy,
  536. ref uint PulseThroughput);
  537. /// <summary>
  538. /// Sets Spectrometer Configuration
  539. /// </summary>
  540. /// <param name="CID">Connection Id</param>
  541. /// <param name="SPU"></param>
  542. /// <param name="Det">Detector-Number</param>
  543. /// <param name="MaxEnergy"></param>
  544. /// <param name="PulseThroughput"></param>
  545. /// <returns></returns>
  546. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  547. public static extern int SetSpectrometerConfiguration(
  548. uint CID,
  549. int SPU,
  550. int Det,
  551. uint MaxEnergyIndex,
  552. uint PulseThroughputIndex);
  553. /// <summary>
  554. /// Sets active Detectors
  555. /// </summary>
  556. /// <param name="CID"></param>
  557. /// <param name="SPU"></param>
  558. /// <param name="Detectors">Active Detectors as bitmask (1 shl 0, etc.)</param>
  559. /// <returns></returns>
  560. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  561. public static extern int SetActiveDetectors(
  562. uint CID,
  563. int SPU,
  564. int Detectors);
  565. /// <summary>
  566. /// Get active Detectors
  567. /// </summary>
  568. /// <param name="CID"></param>
  569. /// <param name="SPU"></param>
  570. /// <param name="Detectors">Active Detectors as bitmask (1 shl 0, etc.)</param>
  571. /// <returns></returns>
  572. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  573. public static extern int GetActiveDetectors(
  574. uint CID,
  575. int SPU,
  576. out int Detectors);
  577. /// <summary>
  578. /// Get active Detectors
  579. /// </summary>
  580. /// <param name="CID"></param>
  581. /// <param name="SPU"></param>
  582. /// <param name="Detectors">Available Detectors as bitmask (1 shl 0, etc.)</param>
  583. /// <returns></returns>
  584. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  585. public static extern int GetAvailableDetectors(
  586. uint CID,
  587. int SPU,
  588. out int Detectors);
  589. /// <summary>
  590. /// Get active Detectors
  591. /// </summary>
  592. /// <param name="CID"></param>
  593. /// <param name="SPU"></param>
  594. /// <param name="Detectors">Available WDS Detectors as bitmask (1 shl 0, etc.)</param>
  595. /// <returns></returns>
  596. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  597. public static extern int GetAvailableWDSDetectors(
  598. uint CID,
  599. int SPU,
  600. out int Detectors);
  601. /// <summary>
  602. /// Get Hardware Configuration
  603. /// </summary>
  604. /// <param name="CID"></param>
  605. /// <param name="aHardwareConfiguration"></param>
  606. /// <returns></returns>
  607. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  608. public static extern int GetHardwareConfiguration(
  609. uint CID,
  610. out TRTHardwareConfiguration aHardwareConfiguration);
  611. /// <summary>
  612. /// Calibrates the Spectrometer
  613. /// </summary>
  614. /// <param name="CID">Connection Id</param>
  615. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  616. /// <param name="ShowProgress"></param>
  617. /// <param name="Settings"></param>
  618. /// <param name="Results"></param>
  619. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  620. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  621. public static extern int CalibrateSpectrometer(
  622. uint CID,
  623. int Device,
  624. bool ShowProgress,
  625. TRTCalibSettings Settings,
  626. TRTCalibResults Results);
  627. /// <summary>
  628. /// Get Spectrometer Parameter
  629. /// </summary>
  630. /// <param name="CID">Connection Id</param>
  631. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  632. /// <param name="ParamName">
  633. /// Name of the parameter to read
  634. /// Current implemented names: 'MaxEnergy', 'PulseThroughput', 'DetectorTemperature' as 'longint' or 'Double'
  635. /// </param>
  636. /// <param name="ParamType">Type of the parameter to read (Byte,Boolean,Word,longint,Double,Memory)</param>
  637. /// <param name="Buffer">Pointer to variable of that type</param>
  638. /// <param name="BufSize">if ParamType is Memory than BufSize if size of the memory block described by 'Buffer'</param>
  639. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  640. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  641. public static extern int GetSpectrometerParam(
  642. uint CID,
  643. int Device,
  644. string ParamName,
  645. string ParamType,
  646. object Buffer,
  647. int BufSize);
  648. /// <summary>
  649. /// Read full parameter block of current spectrometer params (needed to create full Bruker spectrum)
  650. /// </summary>
  651. /// <param name="CID">Connection Id</param>
  652. /// <param name="SPU"></param>
  653. /// <param name="Buffer"></param>
  654. /// <param name="BufSize"></param>
  655. /// <returns></returns>
  656. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  657. public static extern int GetSpectrometerParams(
  658. uint CID,
  659. int SPU,
  660. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Buffer,
  661. ref int BufSize);
  662. /// <summary>
  663. ///
  664. /// </summary>
  665. /// <param name="CID">Connection Id</param>
  666. /// <param name="Buffer">Buffer index ( 0 for loaded spectrum buffer, > 0 for spectrometer buffers )</param>
  667. /// <param name="pSpectrumBuf"></param>
  668. /// <param name="BufSize"></param>
  669. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  670. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  671. public static extern int GetSpectrum(
  672. uint CID,
  673. int Buffer,
  674. TRTSpectrumHeaderRec pSpectrumBuf,
  675. int BufSize);
  676. /// <summary>
  677. /// Quantifies Spectrum
  678. /// </summary>
  679. /// <param name="CID">Connection Id</param>
  680. /// <param name="Buffer">Number of spectrometer ( 1 in most cases )</param>
  681. /// <param name="pMethodName"></param>
  682. /// <param name="pParams"></param>
  683. /// <param name="pResultBuf"></param>
  684. /// <param name="ResultBufSize"></param>
  685. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  686. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  687. public static extern int QuantifySpectrum(
  688. uint CID,
  689. int Buffer,
  690. string pMethodName,
  691. string pParams,
  692. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pResultBuf,
  693. int ResultBufSize);
  694. /// <summary>
  695. /// Sends a RCL 2.2 command to spectrometer and returns the answer( see RCL 2.2 description of commands )
  696. /// </summary>
  697. /// <param name="CID">Connection Id</param>
  698. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  699. /// <param name="pCommand"></param>
  700. /// <param name="pAnswer"></param>
  701. /// <param name="AnswerBufSize"></param>
  702. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  703. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  704. public static extern int SendRCLCommand(
  705. uint CID,
  706. int Device,
  707. string pCommand,
  708. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pAnswer,
  709. int AnswerBufSize);
  710. /// <summary>
  711. /// Sends a RCL 2.2 command to spectrometer, does not wait for answer ( see RCL 2.2 description of commands )
  712. /// </summary>
  713. /// <param name="CID">Connection Id</param>
  714. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  715. /// <param name="Command"></param>
  716. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  717. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  718. public static extern int SendRCLCommandOnly(
  719. uint CID,
  720. int Device,
  721. string Command);
  722. /// <summary>
  723. /// Receives the answer of the SendRCLCommandOnly function
  724. /// </summary>
  725. /// <param name="CID">Connection Id</param>
  726. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  727. /// <param name="Answer"></param>
  728. /// <param name="AnswerBufSize"></param>
  729. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  730. //
  731. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  732. public static extern int ReceiveRCLAnswer(
  733. uint CID,
  734. int Device,
  735. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Answer,
  736. int AnswerBufSize);
  737. /// <summary>
  738. /// Interupts QM100's communication to specified device until 'UnlockSpectrometer' is called
  739. /// </summary>
  740. /// <param name="CID">Connection Id</param>
  741. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  742. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  743. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  744. public static extern int LockSpectrometer(
  745. uint CID,
  746. int Device);
  747. /// <summary>
  748. /// Starts QM100's communication to specified device after 'LockSpectrometer' was called
  749. /// </summary>
  750. /// <param name="CID">Connection Id</param>
  751. /// <param name="Device">Number of spectrometer ( 1 in most cases )</param>
  752. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  753. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  754. public static extern int UnlockSpectrometer(
  755. uint CID,
  756. int Device);
  757. /// <summary>
  758. /// Load spectrum from file to buffer
  759. /// </summary>
  760. /// <param name="CID">Connection Id</param>
  761. /// <param name="pFileName">Complete filename for spectrum ( normally with *.spx extension )</param>
  762. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  763. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  764. public static extern int LoadSpectrum(
  765. uint CID,
  766. string pFileName);
  767. /// <summary>
  768. /// Send spectrum back to 'loaded' buffer
  769. /// if one wants to use that function one has to build a complete Bruker spectrum with
  770. /// functions 'GetSpectrum', 'GetSpectrometerParams' and 'CreateSpectrum'
  771. /// </summary>
  772. /// <param name="CID">Connection Id</param>
  773. /// <param name="Spectrum">Bruker spectrum buffer</param>
  774. /// <param name="BufSize">size of spectrum buffer</param>
  775. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  776. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  777. public static extern int PutSpectrum(
  778. uint CID,
  779. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Spectrum,
  780. int BufSize);
  781. /// <summary>
  782. /// Save spectrum buffer to file
  783. /// </summary>
  784. /// <param name="CID">Connection Id</param>
  785. /// <param name="Buffer"></param>
  786. /// <param name="pFileName">Complete filename for spectrum ( normally with *.spx extension )</param>
  787. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  788. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  789. public static extern int SaveSpectrum(
  790. uint CID,
  791. int Buffer,
  792. string pFileName);
  793. /// <summary>
  794. /// Create a complete Bruker spectrum from
  795. /// </summary>
  796. /// <param name="SpectrometerParams"></param>
  797. /// <param name="SpectrumData"></param>
  798. /// <param name="ResultData"></param>
  799. /// <param name="ResultSize"></param>
  800. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  801. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  802. public static extern int CreateSpectrum(
  803. string SpectrometerParams,
  804. TRTSpectrumHeaderRec SpectrumData,
  805. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ResultData,
  806. ref int ResultSize);
  807. /// <summary>
  808. /// Get Corrected Spectrum
  809. /// </summary>
  810. /// <param name="SpectrometerParams"></param>
  811. /// <param name="Spectrum"></param>
  812. /// <param name="ResultData"></param>
  813. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  814. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  815. public static extern int GetCorrectedSpectrum(
  816. string SpectrometerParams,
  817. TRTSpectrumHeaderRec Spectrum,
  818. double ResultData);
  819. /// <summary>
  820. /// Shows Spectrum
  821. /// </summary>
  822. /// <param name="CID">Connection Id</param>
  823. /// <param name="Buffer"></param>
  824. /// <param name="Name"></param>
  825. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  826. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  827. public static extern int ShowSpectrum(
  828. uint CID,
  829. int Buffer,
  830. string Name);
  831. /// <summary>
  832. /// Delete Spectrum
  833. /// </summary>
  834. /// <param name="CID">Connection Id</param>
  835. /// <param name="aName"></param>
  836. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  837. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  838. public static extern int DeleteSpectrum(
  839. uint CID,
  840. string aName);
  841. /// <summary>
  842. /// Get a list of avaliable hardware profiles from client
  843. /// </summary>
  844. /// <param name="CID">Connection Id</param>
  845. /// <param name="pProfiles"></param>
  846. /// <param name="BufSize"></param>
  847. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  848. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  849. public static extern int GetHardwareProfiles(
  850. uint CID,
  851. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pProfiles,
  852. int BufSize);
  853. /// <summary>
  854. /// Set a specific hardware profile
  855. /// </summary>
  856. /// <param name="CID">Connection Id</param>
  857. /// /// <param name="pProfiles"></param>
  858. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  859. // Set a specific hardware profile
  860. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  861. public static extern int SetHardwareProfile(
  862. uint CID,
  863. string pProfile);
  864. /// <summary>
  865. /// Get a list of avaliable quantification methods
  866. /// </summary>
  867. /// <param name="CID">Connection Id</param>
  868. /// <param name="AutomaticOnly"></param>
  869. /// <param name="pMethods"></param>
  870. /// <param name="BufSize"></param>
  871. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  872. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  873. public static extern int GetQuantificationMethods(
  874. uint CID,
  875. bool AutomaticOnly,
  876. [MarshalAs(UnmanagedType.VBByRefStr)] ref string pMethods,
  877. int BufSize);
  878. /// <summary>
  879. /// Get a list of predefined elements from a given quant method
  880. /// </summary>
  881. /// <param name="CID">Connection Id</param>
  882. /// <param name="MethodName"></param>
  883. /// <param name="ElementBuffer"></param>
  884. /// <param name="BufSize"></param>
  885. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  886. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  887. public static extern int GetQuantificationMethodElements(
  888. uint CID,
  889. string MethodName,
  890. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ElementBuffer,
  891. int BufSize);
  892. /// <summary>
  893. /// Call method editor for a given quant method
  894. /// </summary>
  895. /// <param name="CID">Connection Id</param>
  896. /// <param name="MethodName"></param>
  897. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  898. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  899. public static extern int EditQuantificationMethod(
  900. uint CID,
  901. string MethodName);
  902. /// <summary>
  903. /// Get a channel region for desired element and X ray line
  904. /// </summary>
  905. /// <param name="CID">Connection Id</param>
  906. /// <param name="Buffer"></param>
  907. /// <param name="Params"></param>
  908. /// <param name="ResultBuf"></param>
  909. /// <param name="ResultBufSize"></param>
  910. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  911. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  912. public static extern int GetRegionForElement(
  913. uint CID,
  914. int Buffer,
  915. string Params,
  916. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ResultBuf,
  917. int ResultBufSize);
  918. // Xray tube functions
  919. /// <summary>
  920. /// XRay Tube Set Configuration
  921. /// </summary>
  922. /// <param name="CID">Connection Id</param>
  923. /// <param name="Tube"></param>
  924. /// <param name="HighVoltage">tube voltage [Volt]</param>
  925. /// <param name="Current">tube current [µA]</param>
  926. /// <param name="FilterIndex">index of selected filter</param>
  927. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  928. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  929. public static extern int XRayTubeSetConfiguration(
  930. uint CID,
  931. int Tube,
  932. int HighVoltage,
  933. int Current,
  934. int FilterIndex);
  935. /// <summary>
  936. /// XRay Tube Get State
  937. /// </summary>
  938. /// <param name="CID">Connection Id</param>
  939. /// <param name="Tube"></param>
  940. /// <param name="HighVoltage">tube voltate [Volt]</param>
  941. /// <param name="Current">tube current [µA]</param>
  942. /// <param name="FilterIndex">index of selected filter</param>
  943. /// <param name="ShutterOpen"></param>
  944. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  945. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  946. public static extern int XRayTubeGetState(
  947. uint CID,
  948. int Tube,
  949. out int HighVoltage,
  950. out int Current,
  951. out int FilterIndex,
  952. out bool ShutterOpen);
  953. /// <summary>
  954. /// XRay Tube Open Shutter
  955. /// </summary>
  956. /// <param name="CID">Connection Id</param>
  957. /// <param name="Tube"></param>
  958. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  959. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  960. public static extern int XRayTubeOpenShutter(
  961. uint CID,
  962. int Tube);
  963. /// <summary>
  964. /// XRay Tube Close Shutter
  965. /// </summary>
  966. /// <param name="CID">Connection Id</param>
  967. /// <param name="Tube"></param>
  968. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  969. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  970. public static extern int XRayTubeCloseShutter(
  971. uint CID,
  972. int Tube);
  973. /// <summary>
  974. /// XRay Set active tube
  975. /// </summary>
  976. /// <param name="CID">Connection Id</param>
  977. /// <param name="Tube"></param>
  978. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  979. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  980. public static extern int XRaySetActiveTube(
  981. uint CID,
  982. int Tube);
  983. /// <summary>
  984. /// XRay Get active tube
  985. /// </summary>
  986. /// <param name="CID">Connection Id</param>
  987. /// <param name="Tube"></param>
  988. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  989. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  990. public static extern int XRaySetActiveTube(
  991. uint CID,
  992. out int Tube);
  993. // Hypermap functions, function 'HyMapStart' is specific for Esprit/M4
  994. /// <summary>
  995. /// Hypermap Stop
  996. /// </summary>
  997. /// <param name="CID">Connection Id</param>
  998. /// <param name="WaitForFrameEnd"></param>
  999. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1000. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1001. public static extern int HyMapStop(
  1002. uint CID,
  1003. bool WaitForFrameEnd);
  1004. /// <summary>
  1005. /// Clear Hypermap database structure
  1006. /// </summary>
  1007. /// <param name="CID">Connection Id</param>
  1008. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1009. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1010. public static extern int HyMapClearDatabase(
  1011. uint CID);
  1012. /// <summary>
  1013. /// Gets Hypermap State
  1014. /// </summary>
  1015. /// <param name="CID">Connection Id</param>
  1016. /// <param name="Running">acquisition active or not</param>
  1017. /// <param name="MeasureState">state of acquisition in %</param>
  1018. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1019. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1020. public static extern int HyMapGetState(
  1021. uint CID,
  1022. ref bool Running,
  1023. ref double MeasureState);
  1024. /// <summary>
  1025. /// Gets more Informations about Hypermap State
  1026. /// </summary>
  1027. /// <param name="CID">Connection Id</param>
  1028. /// <param name="Running">acquisition active or not</param>
  1029. /// <param name="MeasureState">state of acquisition in %</param>
  1030. /// <param name="CurrentLine">line which is currently scanned (0...map height-1)</param>
  1031. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1032. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1033. public static extern int HyMapGetStateEx(
  1034. uint CID,
  1035. ref bool Running,
  1036. ref double MeasureState,
  1037. ref int CurrentLine);
  1038. /// <summary>
  1039. /// Hypermap Get XY-Spectrum
  1040. /// </summary>
  1041. /// <param name="CID">Connection Id</param>
  1042. /// <param name="X"></param>
  1043. /// <param name="Y"></param>
  1044. /// <param name="Corrected"></param>
  1045. /// <param name="SpectrumBuffer">SpectrumBuffer : pointer to memory, must have space for one full spectrum</param>
  1046. /// <param name="BufferSize"></param>
  1047. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1048. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1049. public static extern int HyMapGetXYSpectrum(
  1050. uint CID,
  1051. int X,
  1052. int Y,
  1053. bool Corrected,
  1054. TRTSpectrumHeaderRec SpectrumBuffer,
  1055. int BufferSize);
  1056. /// <summary>
  1057. /// Hypermap GetLineSpectra
  1058. /// </summary>
  1059. /// <param name="CID">Connection Id</param>
  1060. /// <param name="X"></param>
  1061. /// <param name="Y"></param>
  1062. /// <param name="Count"></param>
  1063. /// <param name="Corrected"></param>
  1064. /// <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>
  1065. /// <param name="BufferSize"></param>
  1066. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1067. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1068. public static extern int HyMapGetLineSpectra(
  1069. uint CID,
  1070. int X,
  1071. int Y,
  1072. int Count,
  1073. bool Corrected,
  1074. TPointerArray SpectrumBuffer,
  1075. ref int BufferSize);
  1076. /// <summary>
  1077. /// Hypermap GetCompressedLineSpectra
  1078. /// </summary>
  1079. /// <param name="CID">Connection Id</param>
  1080. /// <param name="X"></param>
  1081. /// <param name="Y"></param>
  1082. /// <param name="Count"></param>
  1083. /// <param name="Corrected"></param>
  1084. /// <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>
  1085. /// <param name="BufferSize"></param>
  1086. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1087. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1088. public static extern int HyMapCompressedGetLineSpectra(
  1089. uint CID,
  1090. int X,
  1091. int Y,
  1092. int Count,
  1093. bool Corrected,
  1094. TPointerArray SpectrumBuffer,
  1095. ref int BufferSize);
  1096. /// <summary>
  1097. /// Hypermap Quantifiy Spectra
  1098. /// </summary>
  1099. /// <param name="CID">Connection Id</param>
  1100. /// <param name="Points"></param>
  1101. /// <param name="PointCount"></param>
  1102. /// <param name="Binning"></param>
  1103. /// <param name="MethodName"></param>
  1104. /// <param name="Params"></param>
  1105. /// <param name="ResultBuf"></param>
  1106. /// <param name="ResultBufSize"></param>
  1107. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1108. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1109. public static extern int HyMapQuantifySpectra(
  1110. uint CID,
  1111. TPointArray Points,
  1112. int PointCount,
  1113. int Binning,
  1114. string MethodName,
  1115. string Params,
  1116. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ResultBuf,
  1117. int ResultBufSize);
  1118. /// <summary>
  1119. /// Hapermap Save to File
  1120. /// </summary>
  1121. /// <param name="CID">Connection Id</param>
  1122. /// <param name="aFileName">file name</param>
  1123. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1124. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1125. public static extern int HyMapSaveToFile(
  1126. uint CID,
  1127. string aFileName);
  1128. /// <summary>
  1129. /// Hypermap Load from File
  1130. /// </summary>
  1131. /// <param name="CID">Connection Id</param>
  1132. /// <param name="aFileName">file name</param>
  1133. /// <param name="Width"></param>
  1134. /// <param name="Height"></param>
  1135. /// <param name="DetCount"></param>
  1136. /// <param name="ImgCount"></param>
  1137. /// <returns>Function call sucessful or not ( 0 = success, otherwise error )</returns>
  1138. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1139. public static extern int HyMapLoadFromFile(
  1140. uint CID,
  1141. string aFileName,
  1142. out int Width,
  1143. out int Height,
  1144. out int DetCount,
  1145. out int ImgCount);
  1146. /// <summary>
  1147. /// Extract a mixed map image
  1148. /// </summary>
  1149. /// <param name="Format">Image format which shell be used for image buffer creation, can be 'bmp','png','tif','jpg'</param>
  1150. /// <param name="Buffer">Memory buffer provided by caller, must be large enough to handle image data</param>
  1151. /// <param name="BufferSize">Maximum size of buffer available, returns size which really used</param>
  1152. /// <returns></returns>
  1153. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1154. public static extern int HyMapGetMixedMapImage(
  1155. uint CID,
  1156. string Format,
  1157. IntPtr Buffer,
  1158. ref int BufferSize);
  1159. /// <summary>
  1160. /// Extract an element image for a predefined element
  1161. /// </summary>
  1162. /// <param name="Format">Image format which shell be used for image buffer creation, can be 'bmp','png','tif','jpg'</param>
  1163. /// <param name="ElementIndex">Index into list of previously defined elements from 'InitializeSpectrumDatabaseElementIntensities'</param>
  1164. /// <param name="Buffer">Memory buffer provided by caller, must be large enough to handle image data</param>
  1165. /// <param name="BufferSize">Maximum size of buffer available, returns size which really used</param>
  1166. /// <returns></returns>
  1167. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  1168. public static extern int HyMapGetElementImage(
  1169. uint CID,
  1170. string Format,
  1171. int ElementIndex,
  1172. object Buffer,
  1173. ref int BufferSize);
  1174. public static uint FCID = 0;
  1175. public static string Servername = "Lokaler Server";
  1176. public static string Username = "edx";
  1177. public static string Password = "edx";
  1178. public static string TCPHost = "127.0.0.1";
  1179. public static int TCPPort = 5328;
  1180. }
  1181. }