OTSControlFunExport.h 9.2 KB

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