SemController.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using OTSDataType;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace OTSModelSharp.ServiceInterface
  9. {
  10. public class SemController : ISemController
  11. {
  12. public static OTSCLRINTERFACE.COTSControlFunExport hw=null;
  13. private static SemController sem=null;
  14. public static SemController GetSEMController()
  15. {
  16. if (sem == null)
  17. {
  18. sem = new SemController();
  19. }
  20. return sem;
  21. }
  22. private SemController()
  23. {
  24. hw = OTSCLRINTERFACE.COTSControlFunExport.GetControllerInstance();
  25. }
  26. public bool Connect()
  27. {
  28. if (!hw.Init())
  29. {
  30. return false;
  31. }
  32. if (hw.IsConnected())
  33. {
  34. return true;
  35. }
  36. return hw.ConncetSem();
  37. }
  38. public bool IsConnected()
  39. {
  40. //return true;
  41. return hw.IsConnected();
  42. }
  43. public bool DisConnect()
  44. {
  45. if (hw.IsConnected())
  46. {
  47. return hw.DisconnectSem();
  48. }
  49. return true;
  50. }
  51. public bool GetSEMDataGnrFromHw(ref CSEMDataGnr SemDataGnr)
  52. {
  53. if (!hw.IsConnected())
  54. {
  55. return false;
  56. }
  57. double kv=0, brightness=0, contrast=0;
  58. hw.GetSemHighTension(ref kv);
  59. hw.GetSemBrightness(ref brightness);
  60. hw.GetSemContrast(ref contrast);
  61. SemDataGnr.SetValue(kv, brightness, contrast);
  62. return true;
  63. }
  64. public bool GetMagnification(ref double a_dMagnification)
  65. {
  66. if (!hw.IsConnected())
  67. {
  68. return false;
  69. }
  70. return hw.GetSemMagnification(ref a_dMagnification);
  71. }
  72. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  73. {
  74. if (!hw.IsConnected())
  75. {
  76. return false;
  77. }
  78. return hw.GetSemScanFieldSize(ref dScanFieldSizeX, ref dScanFieldSizeY);
  79. }
  80. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  81. {
  82. if (!hw.IsConnected())
  83. {
  84. return false;
  85. }
  86. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  87. }
  88. public bool GetWorkingDistance(ref double a_distance)
  89. {
  90. if (!hw.IsConnected())
  91. {
  92. return false;
  93. }
  94. return hw.GetSemWorkingDistance(ref a_distance);
  95. }
  96. public bool MoveSEMToPoint(Point poi, double rotation)
  97. {
  98. if (!hw.IsConnected())
  99. {
  100. return false;
  101. }
  102. return hw.MoveSEMToPoint(poi.X, poi.Y,rotation);
  103. }
  104. public bool MoveSEMToPoint(Point poi)
  105. {
  106. if (!hw.IsConnected())
  107. {
  108. return false;
  109. }
  110. return hw.MoveSEMToPoint(poi.X, poi.Y);
  111. }
  112. public bool SetMagnification(double a_dMagnification)
  113. {
  114. if (!hw.IsConnected())
  115. {
  116. return false;
  117. }
  118. //hw.SetMagnification(a_dMagnification);
  119. hw.SetSemMagnification(a_dMagnification);
  120. return true;
  121. }
  122. public bool SetScanExternal(bool b)
  123. {
  124. if (!hw.IsConnected())
  125. {
  126. return false;
  127. }
  128. //int seValue = b ? 1 : 0;
  129. return hw.SetSemScanExternal(b);
  130. }
  131. public bool SetWorkingDistance(double a_distance)
  132. {
  133. if (!hw.IsConnected())
  134. {
  135. return false;
  136. }
  137. return hw.SetSemWorkingDistance(a_distance);
  138. }
  139. public bool SetSemBeamCurrentOff()
  140. {
  141. if (!hw.IsConnected())
  142. {
  143. return false;
  144. }
  145. //int seValue = b ? 1 : 0;
  146. return hw.SetSemBeamCurrent(true);
  147. }
  148. public OTSCLRINTERFACE.COTSControlFunExport GetHardwareInterface()
  149. {
  150. if (!hw.IsConnected())
  151. {
  152. return null;
  153. }
  154. return hw;
  155. }
  156. }
  157. }