OTSControlFunExport.h 9.2 KB

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