SemController.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 BrukerSemController : 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 BrukerSemController(semtype);
  34. }
  35. }
  36. return sem;
  37. }
  38. private BrukerSemController(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 SetScanFieldSize100(double dScanFieldSizeX, double dScanFieldSizeY)
  84. {
  85. if (!hw.IsConnected())
  86. {
  87. return false;
  88. }
  89. Size size = new Size();
  90. hw.SetSemScanField100(size);
  91. dScanFieldSizeX = size.Width;
  92. dScanFieldSizeY = size.Height;
  93. return true;
  94. }
  95. public bool GetScanFieldSize100(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  96. {
  97. if (!hw.IsConnected())
  98. {
  99. return false;
  100. }
  101. Size size = hw.GetSemScanField100();
  102. dScanFieldSizeX = size.Width;
  103. dScanFieldSizeY = size.Height;
  104. return true;
  105. }
  106. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  107. {
  108. if (!hw.IsConnected())
  109. {
  110. return false;
  111. }
  112. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  113. }
  114. public bool GetWorkingDistance(ref double a_distance)
  115. {
  116. if (!hw.IsConnected())
  117. {
  118. return false;
  119. }
  120. return hw.GetSemWorkingDistance(ref a_distance);
  121. }
  122. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double a_dRotation)
  123. {
  124. if (!hw.IsConnected())
  125. {
  126. return false;
  127. }
  128. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY, a_dRotation);
  129. }
  130. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
  131. {
  132. if (!hw.IsConnected())
  133. {
  134. return false;
  135. }
  136. return hw.MoveSEMToPoint(a_dPositionX, a_dPositionY);
  137. }
  138. public bool SetMagnification(double a_dMagnification)
  139. {
  140. if (!hw.IsConnected())
  141. {
  142. return false;
  143. }
  144. NLog.LogManager.GetCurrentClassLogger().Warn("Set Magnification:" + a_dMagnification.ToString("F2"));
  145. hw.SetSemMagnification(a_dMagnification);
  146. return true;
  147. }
  148. public bool SetScanExternal(bool b)
  149. {
  150. if (!hw.IsConnected())
  151. {
  152. return false;
  153. }
  154. return hw.SetSemScanExternal(b);
  155. }
  156. public bool SetWorkingDistance(double a_distance)
  157. {
  158. if (!hw.IsConnected())
  159. {
  160. return false;
  161. }
  162. return hw.SetSemWorkingDistance(a_distance);
  163. System.Threading.Thread.Sleep(100);
  164. }
  165. public bool GetSemBrightness(ref double a_dBrightness)
  166. {
  167. if (!hw.IsConnected())
  168. {
  169. return false;
  170. }
  171. return hw.GetSemBrightness(ref a_dBrightness);
  172. }
  173. public bool SetSemBrightness(double a_dBrightness)
  174. {
  175. if (!hw.IsConnected())
  176. {
  177. return false;
  178. }
  179. return hw.SetSemBrightness(a_dBrightness);
  180. }
  181. public bool GetSemContrast(ref double a_dContrast)
  182. {
  183. if (!hw.IsConnected())
  184. {
  185. return false;
  186. }
  187. return hw.GetSemContrast(ref a_dContrast);
  188. }
  189. public bool SetSemContrast(double a_dContrast)
  190. {
  191. if (!hw.IsConnected())
  192. {
  193. return false;
  194. }
  195. return hw.SetSemContrast(a_dContrast);
  196. }
  197. public bool GetSemHighTension(ref double a_dKV)
  198. {
  199. if (!hw.IsConnected())
  200. {
  201. return false;
  202. }
  203. return hw.GetSemHighTension(ref a_dKV);
  204. }
  205. public bool SetSemHighTension(double a_dKV)
  206. {
  207. if (!hw.IsConnected())
  208. {
  209. return false;
  210. }
  211. return hw.SetSemHighTension(a_dKV);
  212. }
  213. public bool SetSemBeamOn(bool val)
  214. {
  215. if (!hw.IsConnected())
  216. {
  217. return false;
  218. }
  219. return hw.SetSemBeamCurrent(val);
  220. }
  221. public bool SetSemBeamBlank(bool a_dKV)
  222. {
  223. if (!hw.IsConnected())
  224. {
  225. return false;
  226. }
  227. return hw.SetSemBeamBlank(a_dKV);
  228. }
  229. public bool GetSemBeamBlank(ref int a_nBeamBlank)
  230. {
  231. if (!hw.IsConnected())
  232. {
  233. return false;
  234. }
  235. return hw.GetSemBeamBlank(ref a_nBeamBlank);
  236. }
  237. public void StopXrayAcquisition()
  238. {
  239. if (hw.IsConnected())
  240. {
  241. hw.StopXrayAcquisition();
  242. }
  243. return ;
  244. }
  245. //public bool GetSemBeamOn()
  246. //{
  247. // return sem.GetSemBeamOn();
  248. //}
  249. public bool SetSemBeamCurrent(bool a_dKV)
  250. {
  251. throw new NotImplementedException();
  252. }
  253. bool ISemController.StopXrayAcquisition()
  254. {
  255. throw new NotImplementedException();
  256. }
  257. }
  258. }