SemController.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using FEIApiControl;
  2. using OTSDataType;
  3. using OTSMeasureApp.ServiceCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Configuration;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace OTSModelSharp.ServiceCenter
  13. {
  14. public class SemController : ISemController
  15. {
  16. private OTSCLRINTERFACE.COTSControlFunExport hw = null;
  17. private static ISemController sem = null;
  18. public static ISemController GetSEMController()
  19. {
  20. var semtype = FileHelper.GetXMLInformations("EDSName");
  21. if (sem == null)
  22. {
  23. if (semtype== "FEI")
  24. {
  25. sem = new FEISemController();
  26. }
  27. else if (semtype == "Oxford")
  28. {
  29. sem = new OxfordSemController();
  30. }
  31. else
  32. {
  33. sem = new SemController(semtype);
  34. }
  35. }
  36. return sem;
  37. }
  38. private SemController(string devicetype)
  39. {
  40. hw = OTSCLRINTERFACE.COTSControlFunExport.GetControllerInstance(devicetype);
  41. }
  42. public bool Connect()
  43. {
  44. if (hw.IsConnected())
  45. {
  46. return true;
  47. }
  48. var sta= hw.ConncetSem();
  49. return sta;
  50. }
  51. public bool IsConnected()
  52. {
  53. return hw.IsConnected();
  54. }
  55. public bool DisConnect()
  56. {
  57. if (hw.IsConnected())
  58. {
  59. return hw.DisconnectSem();
  60. }
  61. return true;
  62. }
  63. public bool GetMagnification(ref double a_dMagnification)
  64. {
  65. if (!hw.IsConnected())
  66. {
  67. return false;
  68. }
  69. return hw.GetSemMagnification(ref a_dMagnification);
  70. }
  71. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  72. {
  73. if (!hw.IsConnected())
  74. {
  75. return false;
  76. }
  77. return hw.GetSemScanFieldSize(ref dScanFieldSizeX, ref dScanFieldSizeY);
  78. }
  79. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  80. {
  81. if (!hw.IsConnected())
  82. {
  83. return false;
  84. }
  85. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  86. }
  87. public bool GetWorkingDistance(ref double a_distance)
  88. {
  89. if (!hw.IsConnected())
  90. {
  91. return false;
  92. }
  93. return hw.GetSemWorkingDistance(ref a_distance);
  94. }
  95. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double a_dRotation)
  96. {
  97. if (!hw.IsConnected())
  98. {
  99. return false;
  100. }
  101. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY, a_dRotation);
  102. }
  103. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
  104. {
  105. if (!hw.IsConnected())
  106. {
  107. return false;
  108. }
  109. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY);
  110. }
  111. public bool SetMagnification(double a_dMagnification)
  112. {
  113. if (!hw.IsConnected())
  114. {
  115. return false;
  116. }
  117. hw.SetSemMagnification(a_dMagnification);
  118. return true;
  119. }
  120. public bool SetScanExternal(bool b)
  121. {
  122. if (!hw.IsConnected())
  123. {
  124. return false;
  125. }
  126. return hw.SetSemScanExternal(b);
  127. }
  128. public bool SetWorkingDistance(double a_distance)
  129. {
  130. if (!hw.IsConnected())
  131. {
  132. return false;
  133. }
  134. return hw.SetSemWorkingDistance(a_distance);
  135. System.Threading.Thread.Sleep(100);
  136. }
  137. public bool GetSemBrightness(ref double a_dBrightness)
  138. {
  139. if (!hw.IsConnected())
  140. {
  141. return false;
  142. }
  143. return hw.GetSemBrightness(ref a_dBrightness);
  144. }
  145. public bool SetSemBrightness(double a_dBrightness)
  146. {
  147. if (!hw.IsConnected())
  148. {
  149. return false;
  150. }
  151. return hw.SetSemBrightness(a_dBrightness);
  152. }
  153. public bool GetSemContrast(ref double a_dContrast)
  154. {
  155. if (!hw.IsConnected())
  156. {
  157. return false;
  158. }
  159. return hw.GetSemContrast(ref a_dContrast);
  160. }
  161. public bool SetSemContrast(double a_dContrast)
  162. {
  163. if (!hw.IsConnected())
  164. {
  165. return false;
  166. }
  167. return hw.SetSemContrast(a_dContrast);
  168. }
  169. public bool GetSemHighTension(ref double a_dKV)
  170. {
  171. if (!hw.IsConnected())
  172. {
  173. return false;
  174. }
  175. return hw.GetSemHighTension(ref a_dKV);
  176. }
  177. public bool SetSemHighTension(double a_dKV)
  178. {
  179. if (!hw.IsConnected())
  180. {
  181. return false;
  182. }
  183. return hw.SetSemHighTension(a_dKV);
  184. }
  185. public bool SetSemBeamOn(bool val)
  186. {
  187. if (!hw.IsConnected())
  188. {
  189. return false;
  190. }
  191. return hw.SetSemBeamCurrent(val);
  192. }
  193. public bool SetSemBeamBlank(bool value)
  194. {
  195. if (!hw.IsConnected())
  196. {
  197. return false;
  198. }
  199. return hw.SetSemBeamBlank(value);
  200. }
  201. public bool GetSemBeamBlank(ref int a_nBeamBlank)
  202. {
  203. if (!hw.IsConnected())
  204. {
  205. return false;
  206. }
  207. return hw.GetSemBeamBlank(ref a_nBeamBlank);
  208. }
  209. public void StopXrayAcquisition()
  210. {
  211. if (hw.IsConnected())
  212. {
  213. hw.StopXrayAcquisition();
  214. }
  215. return ;
  216. }
  217. public bool SetSemBeamCurrentOff(bool value)
  218. {
  219. return hw.SetSemBeamCurrent(value);
  220. }
  221. bool ISemController.StopXrayAcquisition()
  222. {
  223. throw new NotImplementedException();
  224. }
  225. public bool SetSemHTOff(bool value)
  226. {
  227. return hw.SetSemHTOnOff(value);
  228. }
  229. public bool RunHIGH_VACUUM()
  230. {
  231. return true;
  232. }
  233. public bool StopImageAcquisition()
  234. {
  235. return true;
  236. }
  237. public bool SetReducedArea()
  238. {
  239. return true;
  240. }
  241. public bool SetFullFrame()
  242. {
  243. return true;
  244. }
  245. }
  246. }