SemController.cs 8.3 KB

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