CoxmSemController.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 m_api.MoveStageX_YAndConform(a_dPositionX, a_dPositionY);
  141. }
  142. public bool SetMagnification(double a_dMagnification)
  143. {
  144. int mag =(int) a_dMagnification;
  145. return m_api.PostMagnification(mag);
  146. }
  147. public bool SetScanExternal(bool b)
  148. {
  149. return m_api.PostExternalOn(b);
  150. }
  151. public bool SetSemBeamBlank(bool value)
  152. {
  153. return m_api.PostBeamBlank(value);
  154. }
  155. public bool SetSemBeamCurrentOff(bool value)
  156. {
  157. return false;
  158. }
  159. public bool SetSemBrightness(double a_dBrightness)
  160. {
  161. int brightness=(int) a_dBrightness;
  162. return m_api.PostBrightness(brightness);
  163. }
  164. public bool SetSemContrast(double a_dContrast)
  165. {
  166. int contast=(int) a_dContrast;
  167. return m_api.PostContrast(contast);
  168. }
  169. public bool SetSemHighTension(double a_dKV)
  170. {
  171. int KV = (int)a_dKV;
  172. return m_api.PostAccVoltage(KV);
  173. }
  174. public bool SetSemHTOff(bool value)
  175. {
  176. if(value)
  177. {
  178. return m_api.PostEGunOFF();
  179. }
  180. else
  181. {
  182. return false;
  183. }
  184. }
  185. public bool SetWorkingDistance(double a_distance)
  186. {
  187. return m_api.PostWD(a_distance);
  188. }
  189. public bool StopXrayAcquisition()
  190. {
  191. return false;
  192. }
  193. bool ISemController.GetSemBeamBlank(ref int a_nBeamBlank)
  194. {
  195. if(a_nBeamBlank==1)
  196. {
  197. m_api.PostBeamBlank(true);
  198. }
  199. else if(a_nBeamBlank==0)
  200. {
  201. m_api.PostBeamBlank(false);
  202. }
  203. return false;
  204. }
  205. bool ISemController.RunHIGH_VACUUM()
  206. {
  207. return true;
  208. }
  209. bool ISemController.SetFullFrame()
  210. {
  211. return true;
  212. }
  213. bool ISemController.SetReducedArea()
  214. {
  215. return true;
  216. }
  217. bool ISemController.StopImageAcquisition()
  218. {
  219. return true;
  220. }
  221. }
  222. }