SemController.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. NLog.LogManager.GetCurrentClassLogger().Warn("Set Magnification:" + a_dMagnification.ToString("F2"));
  118. hw.SetSemMagnification(a_dMagnification);
  119. return true;
  120. }
  121. public bool SetScanExternal(bool b)
  122. {
  123. if (!hw.IsConnected())
  124. {
  125. return false;
  126. }
  127. return hw.SetSemScanExternal(b);
  128. }
  129. public bool SetWorkingDistance(double a_distance)
  130. {
  131. if (!hw.IsConnected())
  132. {
  133. return false;
  134. }
  135. return hw.SetSemWorkingDistance(a_distance);
  136. System.Threading.Thread.Sleep(100);
  137. }
  138. public bool GetSemBrightness(ref double a_dBrightness)
  139. {
  140. if (!hw.IsConnected())
  141. {
  142. return false;
  143. }
  144. return hw.GetSemBrightness(ref a_dBrightness);
  145. }
  146. public bool SetSemBrightness(double a_dBrightness)
  147. {
  148. if (!hw.IsConnected())
  149. {
  150. return false;
  151. }
  152. return hw.SetSemBrightness(a_dBrightness);
  153. }
  154. public bool GetSemContrast(ref double a_dContrast)
  155. {
  156. if (!hw.IsConnected())
  157. {
  158. return false;
  159. }
  160. return hw.GetSemContrast(ref a_dContrast);
  161. }
  162. public bool SetSemContrast(double a_dContrast)
  163. {
  164. if (!hw.IsConnected())
  165. {
  166. return false;
  167. }
  168. return hw.SetSemContrast(a_dContrast);
  169. }
  170. public bool GetSemHighTension(ref double a_dKV)
  171. {
  172. if (!hw.IsConnected())
  173. {
  174. return false;
  175. }
  176. return hw.GetSemHighTension(ref a_dKV);
  177. }
  178. public bool SetSemHighTension(double a_dKV)
  179. {
  180. if (!hw.IsConnected())
  181. {
  182. return false;
  183. }
  184. return hw.SetSemHighTension(a_dKV);
  185. }
  186. public bool SetSemBeamOn(bool val)
  187. {
  188. if (!hw.IsConnected())
  189. {
  190. return false;
  191. }
  192. return hw.SetSemBeamCurrent(val);
  193. }
  194. public bool SetSemBeamBlank(bool value)
  195. {
  196. if (!hw.IsConnected())
  197. {
  198. return false;
  199. }
  200. return hw.SetSemBeamBlank(value);
  201. }
  202. public bool GetSemBeamBlank(ref int a_nBeamBlank)
  203. {
  204. if (!hw.IsConnected())
  205. {
  206. return false;
  207. }
  208. return hw.GetSemBeamBlank(ref a_nBeamBlank);
  209. }
  210. public void StopXrayAcquisition()
  211. {
  212. if (hw.IsConnected())
  213. {
  214. hw.StopXrayAcquisition();
  215. }
  216. return ;
  217. }
  218. public bool SetSemBeamCurrentOff(bool value)
  219. {
  220. return hw.SetSemBeamCurrent(value);
  221. }
  222. bool ISemController.StopXrayAcquisition()
  223. {
  224. throw new NotImplementedException();
  225. }
  226. public bool SetSemHTOff(bool value)
  227. {
  228. return hw.SetSemHTOnOff(value);
  229. }
  230. }
  231. }