SemController.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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("SemControllerName");
  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.Init())
  45. //{
  46. // return false;
  47. //}
  48. if (hw.IsConnected())
  49. {
  50. return true;
  51. }
  52. var sta= hw.ConncetSem();
  53. return sta;
  54. }
  55. public bool IsConnected()
  56. {
  57. return hw.IsConnected();
  58. }
  59. public bool DisConnect()
  60. {
  61. if (hw.IsConnected())
  62. {
  63. return hw.DisconnectSem();
  64. }
  65. return true;
  66. }
  67. public bool GetMagnification(ref double a_dMagnification)
  68. {
  69. if (!hw.IsConnected())
  70. {
  71. return false;
  72. }
  73. return hw.GetSemMagnification(ref a_dMagnification);
  74. }
  75. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  76. {
  77. if (!hw.IsConnected())
  78. {
  79. return false;
  80. }
  81. return hw.GetSemScanFieldSize(ref dScanFieldSizeX, ref dScanFieldSizeY);
  82. }
  83. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  84. {
  85. if (!hw.IsConnected())
  86. {
  87. return false;
  88. }
  89. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  90. }
  91. public bool GetWorkingDistance(ref double a_distance)
  92. {
  93. if (!hw.IsConnected())
  94. {
  95. return false;
  96. }
  97. return hw.GetSemWorkingDistance(ref a_distance);
  98. }
  99. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double a_dRotation)
  100. {
  101. if (!hw.IsConnected())
  102. {
  103. return false;
  104. }
  105. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY, a_dRotation);
  106. }
  107. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
  108. {
  109. if (!hw.IsConnected())
  110. {
  111. return false;
  112. }
  113. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY);
  114. }
  115. public bool SetMagnification(double a_dMagnification)
  116. {
  117. if (!hw.IsConnected())
  118. {
  119. return false;
  120. }
  121. NLog.LogManager.GetCurrentClassLogger().Warn("Set Magnification:" + a_dMagnification.ToString("F2"));
  122. hw.SetSemMagnification(a_dMagnification);
  123. return true;
  124. }
  125. public bool SetScanExternal(bool b)
  126. {
  127. if (!hw.IsConnected())
  128. {
  129. return false;
  130. }
  131. return hw.SetSemScanExternal(b);
  132. }
  133. public bool SetWorkingDistance(double a_distance)
  134. {
  135. if (!hw.IsConnected())
  136. {
  137. return false;
  138. }
  139. return hw.SetSemWorkingDistance(a_distance);
  140. System.Threading.Thread.Sleep(100);
  141. }
  142. public bool GetSemBrightness(ref double a_dBrightness)
  143. {
  144. if (!hw.IsConnected())
  145. {
  146. return false;
  147. }
  148. return hw.GetSemBrightness(ref a_dBrightness);
  149. }
  150. public bool SetSemBrightness(double a_dBrightness)
  151. {
  152. if (!hw.IsConnected())
  153. {
  154. return false;
  155. }
  156. return hw.SetSemBrightness(a_dBrightness);
  157. }
  158. public bool GetSemContrast(ref double a_dContrast)
  159. {
  160. if (!hw.IsConnected())
  161. {
  162. return false;
  163. }
  164. return hw.GetSemContrast(ref a_dContrast);
  165. }
  166. public bool SetSemContrast(double a_dContrast)
  167. {
  168. if (!hw.IsConnected())
  169. {
  170. return false;
  171. }
  172. return hw.SetSemContrast(a_dContrast);
  173. }
  174. public bool GetSemHighTension(ref double a_dKV)
  175. {
  176. if (!hw.IsConnected())
  177. {
  178. return false;
  179. }
  180. return hw.GetSemHighTension(ref a_dKV);
  181. }
  182. public bool SetSemHighTension(double a_dKV)
  183. {
  184. if (!hw.IsConnected())
  185. {
  186. return false;
  187. }
  188. return hw.SetSemHighTension(a_dKV);
  189. }
  190. public bool SetSemBeamOn(bool val)
  191. {
  192. if (!hw.IsConnected())
  193. {
  194. return false;
  195. }
  196. return hw.SetSemBeamCurrent(val);
  197. }
  198. public bool SetSemBeamBlank(bool value)
  199. {
  200. if (!hw.IsConnected())
  201. {
  202. return false;
  203. }
  204. return hw.SetSemBeamBlank(value);
  205. }
  206. public bool GetSemBeamBlank(ref int a_nBeamBlank)
  207. {
  208. if (!hw.IsConnected())
  209. {
  210. return false;
  211. }
  212. return hw.GetSemBeamBlank(ref a_nBeamBlank);
  213. }
  214. public void StopXrayAcquisition()
  215. {
  216. if (hw.IsConnected())
  217. {
  218. hw.StopXrayAcquisition();
  219. }
  220. return ;
  221. }
  222. public bool SetSemBeamCurrentOff(bool value)
  223. {
  224. return hw.SetSemBeamCurrent(value);
  225. }
  226. bool ISemController.StopXrayAcquisition()
  227. {
  228. throw new NotImplementedException();
  229. }
  230. public bool SetSemHTOff(bool value)
  231. {
  232. return hw.SetSemHTOnOff(value);
  233. }
  234. }
  235. }