SemController.cs 8.0 KB

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