CoxmSemController.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using FEIApiControl;
  2. using OTSModelSharp.ServiceCenter;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NSDLL_CLR;
  9. using System.Reflection;
  10. namespace OTSMeasureApp.ServiceCenter.Coxm
  11. {
  12. class CoxmSemController : ISemController
  13. {
  14. public static NSRestClient m_api;
  15. private int imageWidth = 640;
  16. private int imageHeight = 480;
  17. double dwelltime = 10;
  18. int port = 7321;
  19. string ip = "127.0.0.1";
  20. /// <summary>
  21. /// //se 0;bse 1;se_bse 2;
  22. /// </summary>
  23. int scan_chanel = 1;
  24. /// <summary>
  25. /// //red 0; fast 1; slow 2; slow2 3
  26. /// </summary>
  27. int scan_speed = 1;
  28. public CoxmSemController()
  29. {
  30. m_api = NSDLL_CLR.NSRestClient.GetControllerInstance();
  31. }
  32. public static NSRestClient GetApiClassInstance()
  33. {
  34. if (m_api == null)
  35. {
  36. m_api = NSDLL_CLR.NSRestClient.GetControllerInstance();
  37. }
  38. return m_api;
  39. }
  40. public bool Connect()
  41. {
  42. string FEIIP = FileHelper.GetXMLInformations("FEIIP");
  43. string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
  44. if (FEIIP == "" || FEIPORT == "")
  45. {
  46. NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
  47. return false;
  48. }
  49. if (m_api.IsServerConnectStatus())
  50. {
  51. return true;
  52. }
  53. if (m_api.ServerConnect())
  54. {
  55. return true;
  56. }
  57. return false;
  58. }
  59. public bool DisConnect()
  60. {
  61. if (m_api.ServerDisConnect())
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. public bool GetMagnification(ref double a_dMagnification)
  68. {
  69. int mag = 0;
  70. if (m_api.GetMagnification(ref mag))
  71. {
  72. a_dMagnification=(double)mag;
  73. return true;
  74. }
  75. return false;
  76. }
  77. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  78. {
  79. if (!m_api.IsServerConnectStatus())
  80. {
  81. return false;
  82. }
  83. else
  84. {
  85. dScanFieldSizeX = imageWidth;
  86. dScanFieldSizeY = imageHeight;
  87. return true;
  88. }
  89. }
  90. public bool GetSemBeamBlank(ref bool a_nBeamBlank)
  91. {
  92. return m_api.PostBeamBlank(a_nBeamBlank);
  93. }
  94. public bool GetSemBrightness(ref double a_dBrightness)
  95. {
  96. int brightness = 0;
  97. bool get = m_api.GetBrightness(ref brightness);
  98. if(get)
  99. a_dBrightness=(double)brightness;
  100. return get;
  101. }
  102. public bool GetSemContrast(ref double a_dContrast)
  103. {
  104. int contrast = 0;
  105. bool get=m_api.GetContrast(ref contrast);
  106. if(get)
  107. {
  108. a_dContrast=(double)contrast;
  109. }
  110. return get;
  111. }
  112. public bool GetSemHighTension(ref double a_dKV)
  113. {
  114. int kv = 0;
  115. if(m_api.GetAccVoltage(ref kv))
  116. {
  117. a_dKV=(double)kv;
  118. }
  119. return false;
  120. }
  121. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  122. {
  123. double t = 0;
  124. return m_api.GetStageALL(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR, ref a_dPositionR, ref t);
  125. }
  126. public bool GetWorkingDistance(ref double a_distance)
  127. {
  128. return m_api.GetWD(ref a_distance);
  129. }
  130. public bool IsConnected()
  131. {
  132. return m_api.IsServerConnectStatus();
  133. }
  134. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double rotation)
  135. {
  136. return false;
  137. }
  138. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
  139. {
  140. return true;//test when no stage
  141. //return m_api.MoveStageX_YAndConform(a_dPositionX, a_dPositionY);
  142. }
  143. public bool SetMagnification(double a_dMagnification)
  144. {
  145. int mag =(int) a_dMagnification;
  146. return m_api.PostMagnification(mag);
  147. }
  148. public bool SetScanExternal(bool b)
  149. {
  150. return m_api.PostExternalOn(b);
  151. }
  152. public bool SetSemBeamBlank(bool value)
  153. {
  154. return m_api.PostBeamBlank(value);
  155. }
  156. public bool SetSemBeamCurrentOff(bool value)
  157. {
  158. return false;
  159. }
  160. public bool SetSemBrightness(double a_dBrightness)
  161. {
  162. int brightness=(int) a_dBrightness;
  163. return m_api.PostBrightness(brightness);
  164. }
  165. public bool SetSemContrast(double a_dContrast)
  166. {
  167. int contast=(int) a_dContrast;
  168. return m_api.PostContrast(contast);
  169. }
  170. public bool SetSemHighTension(double a_dKV)
  171. {
  172. int KV = (int)a_dKV;
  173. return m_api.PostAccVoltage(KV);
  174. }
  175. public bool SetSemHTOff(bool value)
  176. {
  177. if(value)
  178. {
  179. return m_api.PostEGunOFF();
  180. }
  181. else
  182. {
  183. return false;
  184. }
  185. }
  186. public bool SetWorkingDistance(double a_distance)
  187. {
  188. return m_api.PostWD(a_distance);
  189. }
  190. public bool StopXrayAcquisition()
  191. {
  192. return false;
  193. }
  194. bool ISemController.GetSemBeamBlank(ref int a_nBeamBlank)
  195. {
  196. if(a_nBeamBlank==1)
  197. {
  198. m_api.PostBeamBlank(true);
  199. }
  200. else if(a_nBeamBlank==0)
  201. {
  202. m_api.PostBeamBlank(false);
  203. }
  204. return false;
  205. }
  206. bool ISemController.RunHIGH_VACUUM()
  207. {
  208. return true;
  209. }
  210. bool ISemController.SetFullFrame()
  211. {
  212. return true;
  213. }
  214. bool ISemController.SetReducedArea()
  215. {
  216. return true;
  217. }
  218. bool ISemController.StopImageAcquisition()
  219. {
  220. return true;
  221. }
  222. }
  223. }