OTSControlFunExport.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. #pragma once
  2. /**
  3. @file
  4. @brief OTSControl DLL Interface provide for C#
  5. @author xiaoxing.zhang,Anna Hao
  6. @version 1.0.0.0
  7. @date 2017/6/28
  8. - 2017/6/28 1.0.0.0 xiaoxing.zhang developed SEM Interface
  9. - 2017/6/28 1.0.0.0 Anna Hao developed Scan Interface
  10. - 2017/6/29 1.0.0.0 Anna Hao developed EDS Interface
  11. - 2017/7/3 1.0.0.0 xiaoxing.zhang Add log for SemInterface
  12. - 2021 gaoshipeng revised. complete the whole interface so that we can get all infomation through this interface in C#.
  13. */
  14. #include "BSEImg.h"
  15. #include "OTSSemBase.h"
  16. #include "OTSScanBase.h"
  17. #include "OTSEDSBase.h"
  18. #include "Bruker/OTSBrukerImpl_const.h"
  19. #include <OTSFeatureClr.h>
  20. #include <BSEImgClr.h>
  21. #include <OTSParticleClr.h>
  22. using namespace System;
  23. using namespace System::Drawing;
  24. using namespace System::Collections::Generic;
  25. using namespace OTSController;
  26. namespace OTSCLRINTERFACE
  27. {
  28. public ref class COTSControlFunExport
  29. {
  30. public:
  31. static COTSControlFunExport^ GetControllerInstance(String^ deviceType)
  32. {
  33. if (theInstance == nullptr)
  34. {
  35. theInstance = gcnew COTSControlFunExport(deviceType);
  36. }
  37. return theInstance;
  38. }
  39. ~COTSControlFunExport()
  40. {
  41. }
  42. !COTSControlFunExport()
  43. {
  44. }
  45. //get the hardware object according to the configure file.
  46. bool Init();
  47. //和电镜建立通讯连接
  48. bool ConncetSem();
  49. bool DisconnectSem();
  50. bool IsConnected();
  51. // 初始化
  52. bool ScanInit()
  53. {
  54. bool bRet = m_pScan->Init();
  55. return bRet;
  56. }
  57. //EDS初始化
  58. //函数名称:bool EDSInit()
  59. //输入参数:无
  60. //输出参数:类型:bool,true,设备申请成功
  61. // false,设备申请失败
  62. bool EDSInit()
  63. {
  64. bool bRet = m_pEDS->Init();
  65. return bRet;
  66. }
  67. //获取当前电镜的ID号
  68. int GetSemType()
  69. {
  70. int ID = 0;
  71. ID = (int)m_pSem->GetType();
  72. return ID;
  73. }
  74. bool GetSemBeamBlank(long% a_nBeamBlank)
  75. {
  76. long lBBlank = 0;
  77. BOOL bRev = m_pSem->GetBeamBlank(lBBlank);
  78. a_nBeamBlank = lBBlank;
  79. return bRev;
  80. }
  81. bool SetSemBeamBlank(bool a_nBeamBlank)
  82. {
  83. BOOL bRev = m_pSem->SetBeamBlank(a_nBeamBlank);
  84. return bRev;
  85. }
  86. bool SetSemBeamCurrent(bool a_nBeamCurrent)
  87. {
  88. bool bRev = true;
  89. bRev = m_pSem->SetBeamBlank(a_nBeamCurrent);
  90. return bRev;
  91. }
  92. //获得亮度
  93. bool GetSemBrightness(double% a_dBrightness)
  94. {
  95. double dBriness = 0;
  96. BOOL bRev = m_pSem->GetBrightness(dBriness);
  97. a_dBrightness = dBriness;
  98. return bRev;
  99. }
  100. //设置亮度
  101. bool SetSemBrightness(double a_dBrightness)
  102. {
  103. BOOL bRev = m_pSem->SetBrightness(a_dBrightness);
  104. return bRev;
  105. }
  106. //获得对比度
  107. bool GetSemContrast(double% a_dContrast)
  108. {
  109. double dContrast = 0;
  110. BOOL bRev = m_pSem->GetContrast(dContrast);
  111. a_dContrast = dContrast;
  112. return bRev;
  113. }
  114. //设置对比度
  115. bool SetSemContrast(double a_dContrast)
  116. {
  117. BOOL bRev = m_pSem->SetContrast(a_dContrast);
  118. return bRev;
  119. }
  120. //获得Z轴的工作距离
  121. bool GetSemWorkingDistance(double% a_dWorkingDistance)
  122. {
  123. double dWDistance = 0;
  124. BOOL bRev = m_pSem->GetWorkingDistance(dWDistance);
  125. a_dWorkingDistance = dWDistance;
  126. return bRev;
  127. }
  128. // 设置Z轴工作距离
  129. bool SetSemWorkingDistance(double a_dWorkingDistance)
  130. {
  131. BOOL bRev = m_pSem->SetWorkingDistance(a_dWorkingDistance);
  132. return bRev;
  133. }
  134. // 获得电压值
  135. bool GetSemHighTension(double% a_dKV)
  136. {
  137. double dDKV = 0;
  138. BOOL bRev = m_pSem->GetHighTension(dDKV);
  139. a_dKV = dDKV;
  140. return bRev;
  141. }
  142. // 设置电压值
  143. bool SetSemHighTension(double a_dKV)
  144. {
  145. BOOL bRev = m_pSem->SetHighTension(a_dKV);
  146. return bRev;
  147. }
  148. //获得放大倍数
  149. bool GetSemMagnification(double% a_dMagnification)
  150. {
  151. double dMagni = 0;
  152. BOOL bRev = m_pSem->GetMagnification(dMagni);
  153. a_dMagnification = dMagni;
  154. return bRev;
  155. }
  156. //设置放大倍数
  157. bool SetSemMagnification(double a_dMagnification)
  158. {
  159. BOOL bRev = m_pSem->SetMagnification(a_dMagnification);
  160. return bRev;
  161. }
  162. //获得扫描区域尺寸
  163. bool GetSemScanFieldSize(double% a_dScanFieldSizeX, double% a_dScanFieldSizeY)
  164. {
  165. double dFSizeX = 0;
  166. double dFSizeY = 0;
  167. BOOL bRev = m_pSem->GetScanFieldSize(dFSizeX, dFSizeY);
  168. a_dScanFieldSizeX = dFSizeX;
  169. a_dScanFieldSizeY = dFSizeY;
  170. return bRev;
  171. }
  172. //设置扫描区域尺寸
  173. bool SetSemScanFieldSizeX(double a_dScanFieldSizeX)
  174. {
  175. BOOL bRev = m_pSem->SetScanFieldSizeX(a_dScanFieldSizeX);
  176. return bRev;
  177. }
  178. bool GetSemHTOnOff(bool% a_bHTValue)
  179. {
  180. BOOL bHTV = FALSE;
  181. BOOL bRev = m_pSem->GetHTOnOff(bHTV);
  182. a_bHTValue = bHTV;
  183. return bRev;
  184. }
  185. bool SetSemHTOnOff(bool a_bHTValue)
  186. {
  187. bool bRev = m_pSem->SetHTOnOff(a_bHTValue);
  188. return bRev;
  189. }
  190. //获得电镜位置
  191. bool GetSemPositionXY(double% a_dPositionX, double% a_dPositionY, double% a_dPositionR)
  192. {
  193. double dPosX = 0;
  194. double dPosY = 0;
  195. double dPosR = 0;
  196. BOOL bRev = m_pSem->GetPositionXY(dPosX, dPosY, dPosR);
  197. a_dPositionX = dPosX;
  198. a_dPositionY = dPosY;
  199. a_dPositionR = dPosR;
  200. return bRev;
  201. }
  202. //设置电镜位置
  203. bool SetSemPositionXY(double a_dPositionX, double a_dPositionY, double a_dPositionR)
  204. {
  205. BOOL bRev = m_pSem->SetPositionXY(a_dPositionX, a_dPositionY, a_dPositionR);
  206. return bRev;
  207. }
  208. bool SetSemPositionXY(double a_dPositionX, double a_dPositionY)
  209. {
  210. BOOL bRev = m_pSem->SetPositionXY(a_dPositionX, a_dPositionY);
  211. return bRev;
  212. }
  213. //获得焦点尺寸
  214. bool GetSemSpotSize(double% a_dSpotSize)
  215. {
  216. double dPSize = 0;
  217. BOOL bRev = m_pSem->GetSpotSize(dPSize);
  218. a_dSpotSize = dPSize;
  219. return bRev;
  220. }
  221. //设置焦点尺寸
  222. bool SetSemSpotSize(double a_dSpotSize)
  223. {
  224. BOOL bRev = m_pSem->SetSpotSize(a_dSpotSize);
  225. return bRev;
  226. }
  227. bool SetSemScanExternal(bool external)
  228. {
  229. bool bRev = false;
  230. try
  231. {
  232. bRev = m_pSem->SetScanExternal(external);
  233. }
  234. catch (const std::exception&)
  235. {
  236. bRev = false;
  237. }
  238. return bRev;
  239. }
  240. int GetSemExternalMode()
  241. {
  242. BOOL bRev = m_pSem->GetExternalMode();
  243. return bRev;
  244. }
  245. //移动电镜到指定的位置
  246. bool MoveSEMToPoint(double dPosX, double dPosY, double dRotation)
  247. {
  248. //double dRota = dRotation;
  249. CPoint cPos;
  250. cPos.x = (LONG)dPosX;
  251. cPos.y = (LONG)dPosY;
  252. bool bRev = m_pSem->MoveSEMToPoint(cPos, dRotation);
  253. return bRev;
  254. }
  255. //移动电镜到指定的位置
  256. bool MoveSEMToPoint(double dPosX, double dPosY)
  257. {
  258. double dRotation;
  259. CPoint cPos;
  260. cPos.x = (LONG)dPosX;
  261. cPos.y = (LONG)dPosY;
  262. bool bRev = m_pSem->MoveSEMToPoint(cPos, dRotation);
  263. return bRev;
  264. }
  265. //获取EDS类型,Bruker是3.
  266. //函数名称:int EDSGetType()
  267. //输入参数:无
  268. //输出参数:类型:int,设备ID标识
  269. int EDSGetType()
  270. {
  271. int a_type=(int)m_pEDS->GetType();
  272. return a_type;
  273. }
  274. bool CollectSpectrum(unsigned long a_nMilliseconds, Point a_oPoint, cli::array<unsigned long>^% a_XrayData);
  275. bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array<unsigned long>^% a_XrayData, unsigned long a_nBufferSize);
  276. bool CollectSpectrum(unsigned long a_nMilliseconds, cli::array<unsigned long>^% a_XrayData);
  277. bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array<CPosXrayClr^>^% a_XrayData, bool bQuant);
  278. bool GetXRayByPoints(unsigned long a_nMilliseconds, cli::array<Point>^ points, cli::array<COTSParticleClr^>^ parts, bool bQuant);
  279. bool QuantifyXrayByParts(cli::array<COTSParticleClr^>^ parts);
  280. bool QuantifyXrayByPart(COTSParticleClr^ part);
  281. bool GetXRayBySinglePoint(unsigned long a_nMilliseconds, Point point, cli::array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant);
  282. bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array<COTSFeatureClr^>^ feas,cli::array<cli::array<unsigned long>^>^% a_XrayData, cli::array<String^>^% a_strEleResult, bool bQuant);
  283. bool GetXRayByFeatures(unsigned long a_nMilliseconds, cli::array<COTSParticleClr^>^ parts, bool bQuant);
  284. bool GetXRayBySingleFeature(unsigned long a_nMilliseconds, COTSFeatureClr^ feature, cli::array<unsigned long>^% a_XrayData, String^% a_strEleResult, bool bQuant);
  285. // analysis elements
  286. bool GetXRayAndElements(unsigned long a_nMilliseconds, int a_BSEX, int a_BSEY, cli::array<unsigned long>^% a_XrayData, int^% a_nElementNum, String^% a_strResult);
  287. /// get live time
  288. float GetLiveTime(void)
  289. {
  290. float fRet = m_pEDS->GetLiveTime();
  291. return fRet;
  292. }
  293. /// get x-ray point collection limit
  294. long GetMaxPointLimit(void)
  295. {
  296. long lRet = m_pEDS->GetMaxPointLimit();
  297. return lRet;
  298. }
  299. //获取图像数据14741238434
  300. int AcquireBSEImage( cli::array<System::Byte>^% a_ImgData);
  301. //获取图像数据14741238434
  302. bool AcquireBSEImage( CBSEImgClr^% a_ImgData)
  303. {
  304. CBSEImgPtr pbseImg = nullptr;
  305. pbseImg = m_pScan->AcquireBSEImage();
  306. if (pbseImg == nullptr)
  307. {
  308. return false;
  309. }
  310. a_ImgData = gcnew CBSEImgClr(pbseImg);
  311. return true;
  312. }
  313. int GetScanType()
  314. {
  315. int nRet = (int)ScanController::SCANNER_ID::BRUKER;
  316. return nRet;
  317. }
  318. // set Image Size
  319. bool SetImageSize(long nWidth,long nHeight)
  320. {
  321. bool bRet = m_pScan->SetImageSize(nWidth,nHeight);
  322. return bRet;
  323. }
  324. /// set dwell time
  325. bool SetDwellTime(long nDwellTime)
  326. {
  327. bool bRet = m_pScan->SetDwellTime(nDwellTime);
  328. return bRet;
  329. }
  330. bool MoveBeamTo(Point a_beamPos)
  331. {
  332. CPoint pt;
  333. pt.x = a_beamPos.X;
  334. pt.y = a_beamPos.Y;
  335. bool bRet = (bool)m_pScan->MoveBeamTo(pt);
  336. return bRet;
  337. }
  338. bool StopXrayAcquisition()
  339. {
  340. bool bRet = (bool)m_pEDS->StopXrayAcquistion();
  341. return bRet;
  342. }
  343. void SetExpectCount(int expectcount);
  344. int GetExpectCount();
  345. private:
  346. COTSControlFunExport(String^ deviceType)
  347. {
  348. m_DeviceType = deviceType;
  349. this->Init();
  350. }
  351. int GetEDSControllerID(const CString& EDSControllerName);
  352. COTSSemBase* m_pSem;
  353. COTSScanBase* m_pScan;
  354. COTSEDSBase* m_pEDS;
  355. String^ m_DeviceType;
  356. static COTSControlFunExport^ theInstance=nullptr;
  357. };
  358. }