Bruker.API.EspritFunctions.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Bruker.API
  4. {
  5. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  6. public struct TRTImageInfoEx
  7. {
  8. public int Magnification;
  9. public double PixelSizeX; // mü pro Pixel
  10. public double PixelSizeY;
  11. public double HighVoltage; // kV
  12. public double WorkingDistance; // mm
  13. }
  14. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  15. public struct TSegment
  16. {
  17. public int Y;
  18. public int XStart;
  19. public int XCount;
  20. }
  21. // TSegmentList = array[0..8192] of TSegment;
  22. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  23. public struct TSegmentList
  24. {
  25. public TSegment[] Segments;
  26. }
  27. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  28. public struct TFeatureData // describes 1 scan feature
  29. {
  30. public int SegmentCount;
  31. public TSegmentList Segments;
  32. }
  33. // TFeatureDataList = array[0..0] of TFeatureData;
  34. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  35. public struct TFeatureDataList
  36. {
  37. public TFeatureData[] FeatureDatas;
  38. }
  39. [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
  40. public struct TRTEBSDCalibSettings
  41. {
  42. public int TiltAngle;
  43. public int TiltAzimuthAngle;
  44. public int ScanRotation;
  45. public int WD;
  46. public int DetectorAxis;
  47. public int DetectorTilt;
  48. public int PhosphorSize;
  49. }
  50. public class EspritFunctions
  51. {
  52. #if WIN32
  53. const string rtdll = "Bruker.API.Esprit.DLL";
  54. #else
  55. const string rtdll = "Bruker.API.Esprit64.DLL";
  56. #endif
  57. /// <summary>
  58. /// Read current image device configuration
  59. /// </summary>
  60. /// <param name="CID">Connection Id</param>
  61. /// <param name="Width"></param>
  62. /// <param name="Height"></param>
  63. /// <param name="Average"></param>
  64. /// <param name="Ch1"></param>
  65. /// <param name="Ch2"></param>
  66. /// <returns>Function call sucessful or not( 0 = success, otherwise error)</returns>
  67. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  68. public static extern int ImageGetConfiguration(
  69. uint CID,
  70. ref int Width,
  71. ref int Height,
  72. ref int Average,
  73. ref bool Ch1,
  74. ref bool Ch2);
  75. /// <summary>
  76. /// Write current image device configuration
  77. /// </summary>
  78. /// <param name="CID">Connection Id</param>
  79. /// <param name="Width"></param>
  80. /// <param name="Height"></param>
  81. /// <param name="Average"></param>
  82. /// <param name="Ch1"></param>
  83. /// <param name="Ch2"></param>
  84. /// <returns>Function call sucessful or not( 0 = success, otherwise error)</returns>
  85. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  86. public static extern int ImageSetConfiguration(
  87. uint CID,
  88. int Width,
  89. int Height,
  90. int Average,
  91. bool Ch1,
  92. bool Ch2);
  93. /// <summary>
  94. /// Use external scan engine which triggers our scan generator trough an external signal
  95. /// </summary>
  96. /// <param name="CID">Connection Id</param>
  97. /// <param name="UseExternalScan"></param>
  98. /// <returns>Function call sucessful or not( 0 = success, otherwise error)</returns>
  99. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  100. public static extern int ImageSetExternalScan(
  101. uint CID,
  102. bool UseExternalScan);
  103. /// <summary>
  104. /// Aquire new image and read image data
  105. /// </summary>
  106. /// <param name="CID">Connection Id</param>
  107. /// <param name="Ch"></param>
  108. /// <param name="ShowProgress"></param>
  109. /// <param name="Buffer"></param>
  110. /// <param name="BufSize"></param>
  111. /// <param name="ImgInfo"></param>
  112. /// <returns>Function call sucessful or not( 0 = success, otherwise error)</returns>
  113. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  114. public static extern int ImageAquireImage(
  115. uint CID,
  116. int Ch,
  117. bool ShowProgress,
  118. object Buffer,
  119. ref int BufSize,
  120. TRTImageInfoEx ImgInfo);
  121. /// <summary>
  122. /// Aquire new image and read image data (extended)
  123. /// </summary>
  124. /// <param name="CID">Connection Id</param>
  125. /// <param name="Ch"></param>
  126. /// <param name="Buffer"></param>
  127. /// <param name="Options">
  128. /// Bit combination of the following values
  129. /// cImgAcq_ShowProgress = 1;
  130. /// cImgAcq_UpdateSEMData = 2;
  131. /// </param>
  132. /// <param name="BufSize"></param>
  133. /// <param name="ImgInfo"></param>
  134. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  135. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  136. public static extern int ImageAquireImageEx(
  137. uint CID,
  138. int Ch,
  139. object Buffer,
  140. int Options,
  141. ref int BufSize,
  142. TRTImageInfoEx ImgInfo);
  143. /// <summary>
  144. /// Read the image field width from scan settings and SEM magnification, microns unit
  145. /// </summary>
  146. /// <param name="CID">Connection Id</param>
  147. /// <param name="FieldWidth"></param>
  148. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  149. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  150. public static extern int ImageGetFieldWidth(
  151. uint CID,
  152. ref double FieldWidth);
  153. /// <summary>
  154. /// Set electron beam position in image
  155. /// </summary>
  156. /// <param name="CID">Connection Id</param>
  157. /// <param name="X"></param>
  158. /// <param name="Y"></param>
  159. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  160. //
  161. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  162. public static extern int ImageSetPoint(
  163. uint CID,
  164. int X,
  165. int Y);
  166. // functions to deal with point lists
  167. /// <summary>
  168. /// Start PointList Measurement
  169. /// </summary>
  170. /// <param name="CID">connection identifier</param>
  171. /// <param name="SPU">spectrometer index (1..n)</param>
  172. /// <param name="SegmentCount"></param>
  173. /// <param name="LineSegments">description of points to measure</param>
  174. /// <param name="RealTime">acquisition time in ms</param>
  175. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  176. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  177. public static extern int StartPointListMeasurement(
  178. uint CID,
  179. int SPU,
  180. int SegmentCount,
  181. TSegmentList LineSegments,
  182. int RealTime);
  183. /// <summary>
  184. /// Start PointList Measurement direct
  185. /// </summary>
  186. /// <param name="CID">connection identifier</param>
  187. /// <param name="SPU">spectrometer index (1..n)</param>
  188. /// <param name="SegmentCount"></param>
  189. /// <param name="LineSegments">description of points to measure</param>
  190. /// <param name="RealTime">acquisition time in ms</param>
  191. /// <param name="IsFirst"></param>
  192. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  193. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  194. public static extern int StartPointListMeasurementDirect(
  195. uint CID,
  196. int SPU,
  197. int SegmentCount,
  198. TSegmentList LineSegments,
  199. int RealTime,
  200. bool IsFirst);
  201. /// <summary>
  202. /// Get PointList Spectrum
  203. /// </summary>
  204. /// <param name="CID">connection identifier</param>
  205. /// <param name="Index">spectrum index (1..n)</param>
  206. /// <param name="SpectrumBuf">buffer to hold complete spectrum with header (around 20kB), must be allocated by caller</param>
  207. /// <param name="BufSize">size of spectrum buffer</param>
  208. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  209. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  210. public static extern int GetPointListSpectrum(
  211. uint CID,
  212. int Index,
  213. TRTSpectrumHeaderRec SpectrumBuf,
  214. int BufSize);
  215. /// <summary>
  216. /// Get PointList Spectrum direct
  217. /// </summary>
  218. /// <param name="CID">connection identifier</param>
  219. /// <param name="Index">spectrum index (1..n)</param>
  220. /// <param name="SpectrumBuf">buffer to hold complete spectrum with header (around 20kB), must be allocated by caller</param>
  221. /// <param name="BufSize">size of spectrum buffer</param>
  222. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  223. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  224. public static extern int GetPointListSpectrumDirect(
  225. uint CID,
  226. int Index,
  227. TRTSpectrumHeaderRec SpectrumBuf,
  228. int BufSize);
  229. /// <summary>
  230. /// Quantify PointList Spectrum
  231. /// </summary>
  232. /// <param name="CID">connection identifier</param>
  233. /// <param name="Index">spectrum index (1..n)</param>
  234. /// <param name="MethodName"></param>
  235. /// <param name="Params"></param>
  236. /// <param name="ResultBuf"></param>
  237. /// <param name="ResultBufSize"></param>
  238. /// <param name="SpectrumBuf">buffer to hold complete spectrum with header (around 20kB), must be allocated by caller</param>
  239. /// <param name="BufSize">size of spectrum buffer</param>
  240. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  241. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  242. public static extern int QuantifyPointListSpectrum(
  243. uint CID,
  244. int Index,
  245. string MethodName,
  246. string Params,
  247. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ResultBuf,
  248. int ResultBufSize,
  249. TRTSpectrumHeaderRec SpectrumBuf,
  250. int BufSize);
  251. /// <summary>
  252. /// Save PointList Spectrum
  253. /// </summary>
  254. /// <param name="CID">connection identifier</param>
  255. /// <param name="Buffer">spectrum index (1..n)</param>
  256. /// <param name="FileName">filename to save to</param>
  257. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  258. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  259. public static extern int SavePointListSpectrum(
  260. uint CID,
  261. int Buffer,
  262. string FileName);
  263. /// <summary>
  264. /// Start FeatureList Measurement
  265. /// </summary>
  266. /// <param name="CID">connection identifier</param>
  267. /// <param name="SPU">spectrometer index (1..n)</param>
  268. /// <param name="FeatureCount"></param>
  269. /// <param name="Features"></param>
  270. /// <param name="PixelTimes"></param>
  271. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  272. // functions to deal with object lists
  273. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  274. public static extern int StartFeatureListMeasurement(
  275. uint CID,
  276. int SPU,
  277. int FeatureCount,
  278. TFeatureDataList Features,
  279. int[] PixelTimes);
  280. /// <summary>
  281. /// Get FeatureList-Spectrum
  282. /// </summary>
  283. /// <param name="CID">connection identifier</param>
  284. /// <param name="Index"></param>
  285. /// <param name="SpectrumBuf"></param>
  286. /// <param name="BufSize"></param>
  287. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  288. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  289. public static extern int GetFeatureListSpectrum(
  290. uint CID,
  291. int Index,
  292. TRTSpectrumHeaderRec SpectrumBuf,
  293. int BufSize);
  294. /// <summary>
  295. /// Quantify FeatureList Spectrum
  296. /// </summary>
  297. /// <param name="CID">connection identifier</param>
  298. /// <param name="Index"></param>
  299. /// <param name="MethodName"></param>
  300. /// <param name="Params"></param>
  301. /// <param name="ResultBuf"></param>
  302. /// <param name="ResultBufSize"></param>
  303. /// <param name="SpectrumBuf"></param>
  304. /// <param name="BufSize"></param>
  305. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  306. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  307. public static extern int QuantifyFeatureListSpectrum(
  308. uint CID,
  309. int Index,
  310. string MethodName,
  311. string Params,
  312. [MarshalAs(UnmanagedType.VBByRefStr)] ref string ResultBuf,
  313. int ResultBufSize,
  314. TRTSpectrumHeaderRec SpectrumBuf,
  315. int BufSize);
  316. /// <summary>
  317. /// Save FeatureList Spectrum
  318. /// </summary>
  319. /// <param name="CID">connection identifier</param>
  320. /// <param name="Buffer"></param>
  321. /// <param name="FileName"></param>
  322. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  323. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  324. public static extern int SaveFeatureListSpectrum(
  325. uint CID,
  326. int Buffer,
  327. string FileName);
  328. // functions to communicate with SEM
  329. /// <summary>
  330. /// Set SEM Data
  331. /// </summary>
  332. /// <param name="CID">connection identifier</param>
  333. /// <param name="Magnification"></param>
  334. /// <param name="HighVoltage"></param>
  335. /// <param name="WorkingDistance"></param>
  336. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  337. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  338. public static extern int SetSEMData(
  339. uint CID,
  340. double Magnification,
  341. double HighVoltage,
  342. double WorkingDistance);
  343. /// <summary>
  344. /// Get SEM Data
  345. /// </summary>
  346. /// <param name="CID">connection identifier</param>
  347. /// <param name="Magnification"></param>
  348. /// <param name="HighVoltage"></param>
  349. /// <param name="WorkingDistance"></param>
  350. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  351. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  352. public static extern int GetSEMData(
  353. uint CID,
  354. ref double Magnification,
  355. ref double HighVoltage,
  356. ref double WorkingDistance);
  357. /// <summary>
  358. /// Get SEM BC-Data
  359. /// </summary>
  360. /// <param name="CID">connection identifier</param>
  361. /// <param name="Brightness"></param>
  362. /// <param name="Contrast"></param>
  363. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  364. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  365. public static extern int GetSEMBCData(
  366. uint CID,
  367. ref double Brightness,
  368. ref double Contrast);
  369. /// <summary>
  370. /// Set SEM BC-Data
  371. /// </summary>
  372. /// <param name="CID">connection identifier</param>
  373. /// <param name="Brightness"></param>
  374. /// <param name="Contrast"></param>
  375. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  376. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  377. public static extern int SetSEMBCData(
  378. uint CID,
  379. double Brightness,
  380. double Contrast);
  381. /// <summary>
  382. /// Get SEM ProbeCurrent
  383. /// </summary>
  384. /// <param name="CID">connection identifier</param>
  385. /// <param name="ProbeCurrent"></param>
  386. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  387. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  388. public static extern int GetSEMProbeCurrent(
  389. uint CID,
  390. ref double ProbeCurrent);
  391. /// <summary>
  392. /// Set SEM ProbeCurrent
  393. /// </summary>
  394. /// <param name="CID">connection identifier</param>
  395. /// <param name="ProbeCurrent"></param>
  396. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  397. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  398. public static extern int SetSEMProbeCurrent(
  399. uint CID,
  400. double ProbeCurrent);
  401. /// <summary>
  402. /// Get SEM SpotSize
  403. /// </summary>
  404. /// <param name="CID">connection identifier</param>
  405. /// <param name="SpotSize"></param>
  406. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  407. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  408. public static extern int GetSEMSpotSize(
  409. uint CID,
  410. ref double SpotSize);
  411. /// <summary>
  412. /// Set SEM SpotSize
  413. /// </summary>
  414. /// <param name="CID">connection identifier</param>
  415. /// <param name="SpotSize"></param>
  416. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  417. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  418. public static extern int SetSEMSpotSize(
  419. uint CID,
  420. double SpotSize);
  421. /// <summary>
  422. /// Set SEM Detector
  423. /// </summary>
  424. /// <param name="CID">connection identifier</param>
  425. /// <param name="Channel"></param>
  426. /// <param name="DetectorName"></param>
  427. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  428. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  429. public static extern int SetSEMDetector(
  430. uint CID,
  431. int Channel,
  432. string DetectorName);
  433. /// <summary>
  434. /// Get SEM Detector
  435. /// </summary>
  436. /// <param name="CID">connection identifier</param>
  437. /// <param name="Channel"></param>
  438. /// <param name="DetectorName"></param>
  439. /// <param name="BufSize"></param>
  440. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  441. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  442. public static extern int GetSEMDetector(
  443. uint CID,
  444. int Channel,
  445. [MarshalAs(UnmanagedType.VBByRefStr)] ref string DetectorName,
  446. int BufSize);
  447. /// <summary>
  448. /// Set SEM Stage Data
  449. /// </summary>
  450. /// <param name="CID">connection identifier</param>
  451. /// <param name="XPos"></param>
  452. /// <param name="YPos"></param>
  453. /// <param name="ZPos"></param>
  454. /// <param name="Tilt"></param>
  455. /// <param name="Rotation"></param>
  456. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  457. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  458. public static extern int SetSEMStageData(
  459. uint CID,
  460. double XPos,
  461. double YPos,
  462. double ZPos,
  463. double Tilt,
  464. double Rotation);
  465. /// <summary>
  466. /// Get SEM Stage Data
  467. /// </summary>
  468. /// <param name="CID">connection identifier</param>
  469. /// <param name="XPos"></param>
  470. /// <param name="YPos"></param>
  471. /// <param name="ZPos"></param>
  472. /// <param name="Tilt"></param>
  473. /// <param name="Rotation"></param>
  474. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  475. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  476. public static extern int GetSEMStageData(
  477. uint CID,
  478. ref double XPos,
  479. ref double YPos,
  480. ref double ZPos,
  481. ref double Tilt,
  482. ref double Rotation);
  483. /// <summary>
  484. /// Get SEM Stage Range
  485. /// </summary>
  486. /// <param name="CID">connection identifier</param>
  487. /// <param name="Xmin"></param>
  488. /// <param name="Xmax"></param>
  489. /// <param name="Ymin"></param>
  490. /// <param name="Ymax"></param>
  491. /// <param name="Zmin"></param>
  492. /// <param name="Zmax"></param>
  493. /// <param name="Tmin"></param>
  494. /// <param name="Tmax"></param>
  495. /// <param name="Rmin"></param>
  496. /// <param name="Rmax"></param>
  497. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  498. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  499. public static extern int GetSEMStageRange(
  500. uint CID,
  501. ref double Xmin,
  502. ref double Xmax,
  503. ref double Ymin,
  504. ref double Ymax,
  505. ref double Zmin,
  506. ref double Zmax,
  507. ref double Tmin,
  508. ref double Tmax,
  509. ref double Rmin,
  510. ref double Rmax);
  511. /// <summary>
  512. /// Get SEM Stage State
  513. /// </summary>
  514. /// <param name="CID">connection identifier</param>
  515. /// <param name="State"></param>
  516. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  517. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  518. public static extern int GetSEMStageState(
  519. uint CID,
  520. ref int State);
  521. /// <summary>
  522. /// Get SEM Capabilities
  523. /// </summary>
  524. /// <param name="CID">connection identifier</param>
  525. /// <param name="Capabilities"></param>
  526. /// <param name="BufSize"></param>
  527. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  528. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  529. public static extern int GetSEMCapabilities(
  530. uint CID,
  531. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Capabilities,
  532. int BufSize);
  533. /// <summary>
  534. /// Get SEM info
  535. /// </summary>
  536. /// <param name="CID">connection identifier</param>
  537. /// <param name="Info"></param>
  538. /// <param name="BufSize"></param>
  539. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  540. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  541. public static extern int GetSEMInfo(
  542. uint CID,
  543. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Info,
  544. int BufSize);
  545. /// <summary>
  546. /// Set SEM External On
  547. /// </summary>
  548. /// <param name="CID">connection identifier</param>
  549. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  550. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  551. public static extern int SetSEMExternalOn(
  552. uint CID);
  553. /// <summary>
  554. /// Set SEM External Off
  555. /// </summary>
  556. /// <param name="CID">connection identifier</param>
  557. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  558. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  559. public static extern int SetSEMExternalOff(
  560. uint CID);
  561. /// <summary>
  562. /// Reset SEM Communication
  563. /// </summary>
  564. /// <param name="CID">connection identifier</param>
  565. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  566. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  567. public static extern int ResetSEMCommunication(
  568. uint CID);
  569. /// <summary>
  570. /// Switch SEM Off
  571. /// </summary>
  572. /// <param name="CID">connection identifier</param>
  573. /// <param name="HVOff"></param>
  574. /// <param name="BeamCurrentOff"></param>
  575. /// <param name="BeamBlank"></param>
  576. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  577. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  578. public static extern int SwitchSEMOff(
  579. uint CID,
  580. bool HVOff,
  581. bool BeamCurrentOff,
  582. bool BeamBlank);
  583. // Move EDS detector
  584. /// <summary>
  585. /// Set Position of EDS-Detector
  586. /// </summary>
  587. /// <param name="CID">connection identifier</param>
  588. /// <param name="Detector">Detector to be moved ( 1 in most cases )</param>
  589. /// <param name="Position">Position to move to ( 1 = Park position, 2 = Acquisition position )</param>
  590. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  591. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  592. public static extern int EDSSetDetectorPosition(
  593. uint CID,
  594. int Detector,
  595. int Position);
  596. /// <summary>
  597. /// Get Position of EDS-Detector
  598. /// </summary>
  599. /// <param name="CID">connection identifier</param>
  600. /// <param name="Detector">Detector to ask for position ( 1 in most cases )</param>
  601. /// <param name="Position">Current position ( 1 = Park position, 2 = Acquisition position )</param>
  602. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  603. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  604. public static extern int EDSGetDetectorPosition(
  605. uint CID,
  606. int Detector,
  607. out int Position);
  608. // Mapping functions
  609. /// <summary>
  610. /// Start Hypermapping
  611. /// </summary>
  612. /// <param name="CID">connection identifier</param>
  613. /// <param name="SPU"></param>
  614. /// <param name="PixelTime">Dwell time per Pixel in microseconds</param>
  615. /// <param name="RealTime">Acquisition time in s, RealTime=0 does exactly 1 scan</param>
  616. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  617. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  618. public static extern int HyMapStart(
  619. uint CID,
  620. int SPU,
  621. int PixelTime,
  622. int RealTime);
  623. /// <summary>
  624. /// Start Hypermapping of Image region
  625. /// </summary>
  626. /// <param name="CID">connection identifier</param>
  627. /// <param name="SPU"></param>
  628. /// <param name="PixelTime">Dwell time per Pixel in microseconds</param>
  629. /// <param name="RealTime">Acquisition time in s, RealTime=0 does exactly 1 scan</param>
  630. /// <param name="Region">Image region to be mapped</param>
  631. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  632. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  633. public static extern int HyMapStartEx(
  634. uint CID,
  635. int SPU,
  636. int PixelTime,
  637. int RealTime,
  638. TFeatureData Region);
  639. /// <summary>
  640. /// Start Hypermap acquisition with selected setup
  641. /// </summary>
  642. /// <param name="CID">connection identifier</param>
  643. /// <param name="SPU"></param>
  644. /// <param name="PixelTime">Dwell time per Pixel in microseconds</param>
  645. /// <param name="Region">Image region to be mapped</param>
  646. /// <param name="Profile">Parameter setup</param>
  647. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  648. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  649. public static extern int HyMapStartWithProfile(
  650. uint CID,
  651. int SPU,
  652. int PixelTime,
  653. TFeatureData Region,
  654. string Profile);
  655. //-------------------------------------------------------------------------------------
  656. // EBSD functions
  657. //-------------------------------------------------------------------------------------
  658. /// <summary>
  659. /// Retrieve the list of predefined acquisition setups
  660. /// </summary>
  661. /// <param name="CID">connection identifier</param>
  662. /// <param name="Profiles">buffer to store the list information</param>
  663. /// <param name="BufSize">Size of buffer</param>
  664. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  665. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  666. public static extern int EBSDGetAcquisitionProfiles(
  667. uint CID,
  668. [MarshalAs(UnmanagedType.VBByRefStr)] ref string Profiles,
  669. int BufSize);
  670. /// <summary>
  671. /// Load a predefined acquisition setup
  672. /// </summary>
  673. /// <param name="CID">connection identifier</param>
  674. /// <param name="Profile">buffer with profile name to select</param>
  675. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  676. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  677. public static extern int EBSDSelectAcquisitionProfile(
  678. uint CID,
  679. string Profile);
  680. /// <summary>
  681. /// Start EBSD acquisition with selected setup
  682. /// </summary>
  683. /// <param name="CID">connection identifier</param>
  684. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  685. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  686. public static extern int EBSDStartAcquisition(
  687. uint CID);
  688. /// <summary>
  689. /// // Start EBSD acquisition with defined profile data
  690. /// </summary>
  691. /// <param name="CID">connection identifier</param>
  692. /// <param name="Profile"></param>
  693. /// <returns></returns>
  694. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  695. public static extern int EBSDStartAcquisitionWithProfile(
  696. uint CID,
  697. string Profile);
  698. /// <summary>
  699. /// Stop EBSD acquisition
  700. /// </summary>
  701. /// <param name="CID">connection identifier</param>
  702. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  703. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  704. public static extern int EBSDStopAcquisition(
  705. uint CID);
  706. /// <summary>
  707. /// Retrieve EBSD acquisition state
  708. /// </summary>
  709. /// <param name="CID">connection identifier</param>
  710. /// <param name="CurrentLine">current acquisition Y -position</param>
  711. /// <param name="PercentReady">Current state of Acquisition in %</param>
  712. /// <param name="IndexingPercentReady">Current State of Indexing in %</param>
  713. /// <param name="AcquisitionRunning">Is just giving the running state of the Acquisition</param>
  714. /// <param name="IndexingRunning">Is just giving the running state of the Indexing</param>
  715. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  716. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  717. public static extern int EBSDGetAcquisitionState(
  718. uint CID,
  719. out int CurrentLine,
  720. out int PercentReady,
  721. out int IndexingPercentReady,
  722. out bool AcquisitionRunning,
  723. out bool IndexingRunning);
  724. /// <summary>
  725. /// Save EBSD acquisition data to file in Bruker format
  726. /// </summary>
  727. /// <param name="CID">connection identifier</param>
  728. /// <param name="FileName">File name for the file to store information (*.bcf)</param>
  729. /// <param name="WithEdx">Saves EDX Data</param>
  730. /// <param name="WithPatterns">Saves Patterns</param>
  731. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  732. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  733. public static extern int EBSDSaveToFile(
  734. uint CID,
  735. string FileName,
  736. bool WithEdx,
  737. bool WithPatterns);
  738. // SaveOptions : Bit flags to specify which information has to be stored (frames, detected lines…)
  739. /// <summary>
  740. /// Export Data
  741. /// </summary>
  742. /// <param name="CID">connection identifier</param>
  743. /// <param name="BaseFileName">Base file name for the result files to export (map images…)</param>
  744. /// <param name="ExportOptions">longint representation of export options (Phase=2,IPFX=3,IPFY=4,IPFZ=5,Euler=6)</param>
  745. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  746. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  747. public static extern int EBSDExportData(
  748. uint CID,
  749. string BaseFileName,
  750. int ExportOptions);
  751. /// <summary>
  752. /// Export Data
  753. /// </summary>
  754. /// <param name="CID">connection identifier</param>
  755. /// <param name="Buffer">Memory buffer provided by caller, must be large enough to handle image data</param>
  756. /// <param name="BufferSize">Maximum size of buffer available, returns size which really used</param>
  757. /// <param name="ExportOptions">longint representation of export options (Phase=2,IPFX=3,IPFY=4,IPFZ=5,Euler=6)</param>
  758. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  759. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  760. public static extern int EBSDExportDataBuffer(
  761. uint CID,
  762. IntPtr Buffer,
  763. ref int BufferSize,
  764. int ExportOptions);
  765. /// <summary>
  766. /// Export Results
  767. /// </summary>
  768. /// <param name="CID">connection identifier</param>
  769. /// <param name="BaseFileName">Base file name for the result list (ctf-file) to export</param>
  770. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  771. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  772. public static extern int EBSDExportResults(
  773. uint CID,
  774. string BaseFileName);
  775. /// <summary>
  776. /// Retrieve EBSD detector position
  777. /// </summary>
  778. /// <param name="CID">connection identifier</param>
  779. /// <param name="Position">Detector position in mm</param>
  780. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  781. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  782. public static extern int EBSDGetDetectorPosition(
  783. uint CID,
  784. out double Position);
  785. /// <summary>
  786. /// Move EBSD detector to specified position
  787. /// </summary>
  788. /// <param name="CID">connection identifier</param>
  789. /// <param name="Position">Detector position in mm</param>
  790. /// <param name="Speed">Detector speed in mm/s</param>
  791. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  792. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  793. public static extern int EBSDSetDetectorPosition(
  794. uint CID,
  795. double Position,
  796. double Speed);
  797. /// <summary>
  798. /// Start EBSD-Calibration
  799. /// </summary>
  800. /// <param name="CID">connection identifier</param>
  801. /// <param name="Settings">
  802. /// Settings include:
  803. /// TiltAngle of the Detector
  804. /// TiltAzimuthAngle of the Detector
  805. /// ScanRotation
  806. /// WD
  807. /// DetectorAxis
  808. /// DetectorTilt
  809. /// PhosphorSize
  810. /// </param>
  811. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  812. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  813. public static extern int EBSDStartCalibration(
  814. uint CID,
  815. TRTEBSDCalibSettings Settings);
  816. /// <summary>
  817. /// Stop EBSD Calibration
  818. /// </summary>
  819. /// <param name="CID">connection identifier</param>
  820. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  821. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  822. public static extern int EBSDStopCalibration(
  823. uint CID);
  824. /// <summary>
  825. /// Get Calibration State
  826. /// </summary>
  827. /// <param name="CID">connection identifier</param>
  828. /// <param name="CurrentLine">not yet in use</param>
  829. /// <param name="PercentReady">Calibration state in %</param>
  830. /// <param name="Running">Running state of calibration</param>
  831. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  832. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  833. public static extern int EBSDGetCalibrationState(
  834. uint CID,
  835. out int CurrentLine,
  836. out int PercentReady,
  837. out bool Running);
  838. /// <summary>
  839. /// EBSD Save ImageFromPosition
  840. /// </summary>
  841. /// <param name="CID">connection identifier</param>
  842. /// <param name="aBaseFilename"></param>
  843. /// <param name="X"></param>
  844. /// <param name="Y"></param>
  845. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  846. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  847. public static extern int EBSDSaveEBSPImageFromPosition(
  848. uint CID,
  849. string aBaseFilename,
  850. int X,
  851. int Y);
  852. /// <summary>
  853. /// EBSD SetExposureTime
  854. /// </summary>
  855. /// <param name="CID">connection identifier</param>
  856. /// <param name="ExposureTime"></param>
  857. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  858. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  859. public static extern int EBSDSetExposureTime(
  860. uint CID,
  861. int ExposureTime);
  862. /// <summary>
  863. /// EBDS Get Exposure Time
  864. /// </summary>
  865. /// <param name="CID">connection identifier</param>
  866. /// <param name="ExposureTime"></param>
  867. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  868. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  869. public static extern int EBSDGetExposureTime(
  870. uint CID,
  871. out int ExposureTime);
  872. /// <summary>
  873. /// EBSD Get Image Configuration
  874. /// </summary>
  875. /// <param name="CID">connection identifier</param>
  876. /// <param name="Width">Map width</param>
  877. /// <param name="Height">Map height</param>
  878. /// <returns></returns>
  879. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  880. public static extern int EBSDGetImageConfiguration(
  881. uint CID,
  882. out int Width,
  883. out int Height);
  884. /// <summary>
  885. /// Get Camera Configuration
  886. /// </summary>
  887. /// <param name="CID">connection identifier</param>
  888. /// <param name="Width">Current camera width</param>
  889. /// <param name="Height">Current camera height</param>
  890. /// <returns></returns>
  891. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  892. public static extern int EBSDGetCameraConfiguration(
  893. uint CID,
  894. out int Width,
  895. out int Height);
  896. /// <summary>
  897. /// EDSB Set Gain
  898. /// </summary>
  899. /// <param name="CID">connection identifier</param>
  900. /// <param name="Value"></param>
  901. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  902. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  903. public static extern int EBSDSetGain(
  904. uint CID,
  905. int Value);
  906. /// <summary>
  907. /// EBSD Get Gain
  908. /// </summary>
  909. /// <param name="CID">connection identifier</param>
  910. /// <param name="Value"></param>
  911. /// <returns>Function call sucessful or not( 0 = success, otherwise error )</returns>
  912. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  913. public static extern int EBSDGetGain(
  914. uint CID,
  915. out int Value);
  916. /// <summary>
  917. /// EBSD Get Tilt
  918. /// </summary>
  919. /// <param name="CID">connection identifier</param>
  920. /// <param name="Value"></param>
  921. /// <returns></returns>
  922. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  923. public static extern int EBSDGetTilt(
  924. uint CID,
  925. out double Value);
  926. /// <summary>
  927. /// EBSD Get Available Pattern Format Count
  928. /// </summary>
  929. /// <param name="CID">connection identifier</param>
  930. /// <param name="Count">returns the amount of image format (binning)</param>
  931. /// <returns></returns>
  932. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  933. public static extern int EBSDGetAvailablePatternFormatCount(
  934. uint CID,
  935. out int Count);
  936. /// <summary>
  937. /// Get available Pattern Format
  938. /// </summary>
  939. /// <param name="CID">connection identifier</param>
  940. /// <param name="FormatIndex">Seletion index of image format</param>
  941. /// <param name="Width">Camera Width</param>
  942. /// <param name="Height">Camera Height</param>
  943. /// <returns></returns>
  944. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  945. public static extern int EBSDGetAvailablePatternFormat(
  946. uint CID,
  947. int FormatIndex,
  948. out int Width,
  949. out int Height);
  950. /// <summary>
  951. /// Set Pattern Format
  952. /// </summary>
  953. /// <param name="CID">connection identifier</param>
  954. /// <param name="FormatIndex">The choosen Index for Camera Format</param>
  955. /// <returns></returns>
  956. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  957. public static extern int EBSDSetPatternFormat(
  958. uint CID,
  959. int FormatIndex);
  960. /// <summary>
  961. /// EBSDSetPattern16bitMode
  962. /// </summary>
  963. /// <param name="CID">connection identifier</param>
  964. /// <param name="Value">true (16bit Mode), false (8 bit Mode)</param>
  965. /// <returns></returns>
  966. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  967. public static extern int EBSDSetPattern16bitMode(
  968. uint CID,
  969. bool Value);
  970. [DllImport(rtdll, CharSet = CharSet.Ansi)]
  971. public static extern int EBSDGetEstimatedMappingTime(
  972. uint CID,
  973. out int Time);
  974. }
  975. }