OxfordSemController.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. 
  2. using OxfordExtenderWrapper;
  3. using OTSModelSharp.ServiceCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Runtime.Remoting.Channels.Ipc;
  10. using System.Runtime.Remoting.Channels;
  11. using OTSMeasureApp.ServiceCenter.OxfordExtender;
  12. using System.Threading;
  13. namespace OTSMeasureApp.ServiceCenter
  14. {
  15. class OxfordSemController : ISemController
  16. {
  17. ExtenderIpcUI iExtender;
  18. public OxfordSemController()
  19. {
  20. iExtender = ExtenderWrapperIpc.GetExtenderWrapper();
  21. }
  22. public bool Connect()
  23. {
  24. try
  25. {
  26. iExtender = ExtenderWrapperIpc.GetExtenderWrapper();
  27. }
  28. catch (Exception e)
  29. {
  30. NLog.LogManager.GetCurrentClassLogger().Warn(e.Message);
  31. }
  32. return true;
  33. }
  34. public bool DisConnect()
  35. {
  36. try
  37. {
  38. iExtender.CloseExtender();
  39. //ExtenderWrapperIpc.KillExtenderWrapperProcess();
  40. }
  41. catch (Exception e)
  42. {
  43. NLog.LogManager.GetCurrentClassLogger().Warn(e.Message);
  44. }
  45. return true;
  46. }
  47. public bool GetMagnification(ref double a_dMagnification)
  48. {
  49. a_dMagnification= iExtender.GetMagnification();
  50. return true;
  51. }
  52. public bool GetSemBeamBlank(ref int a_nBeamBlank)
  53. {
  54. a_nBeamBlank = 1;
  55. return true;
  56. }
  57. public bool GetSemBrightness(ref double a_dBrightness)
  58. {
  59. a_dBrightness = iExtender.GetBrightness();
  60. return true;
  61. }
  62. public bool GetSemContrast(ref double a_dContrast)
  63. {
  64. a_dContrast = iExtender.GetContrast();
  65. return true;
  66. }
  67. public bool GetSemHighTension(ref double a_dKV)
  68. {
  69. a_dKV = iExtender.GetSEMVoltage() ;
  70. return true;
  71. }
  72. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  73. {
  74. a_dPositionX = iExtender.GetStageAtX();
  75. a_dPositionY = iExtender.GetStageAtY();
  76. a_dPositionR = iExtender.GetStageAtR();
  77. return true;
  78. }
  79. public bool GetWorkingDistance(ref double a_distance)
  80. {
  81. a_distance= iExtender.GetWorkingDistance();
  82. return true;
  83. }
  84. public bool IsConnected()
  85. {
  86. if (Connect())
  87. {
  88. return true;
  89. }
  90. else
  91. {
  92. return false;
  93. }
  94. }
  95. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double rotation)
  96. {
  97. iExtender = ExtenderWrapperIpc.GetExtenderWrapper();//have to init connection here,or else it will lost the connection for no reason.
  98. var b1= iExtender.MoveStageXY((float)a_dPositionX, (float)a_dPositionY);
  99. var b2=iExtender.SetStageGotoR((float)rotation);
  100. return b1&b2;
  101. }
  102. public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
  103. {
  104. //Thread.Sleep(1000);
  105. iExtender = ExtenderWrapperIpc.GetExtenderWrapper();//have to init connection here,or else it will lost the connection for no reason.
  106. var b= iExtender.MoveStageXY((float)a_dPositionX, (float)a_dPositionY);
  107. return b;
  108. }
  109. public bool SetMagnification(double a_dMagnification)
  110. {
  111. return iExtender.SetMagnification((float)a_dMagnification);
  112. }
  113. public bool SetScanExternal(bool b)
  114. {
  115. return iExtender.SetSemScanExternal(b);
  116. }
  117. public bool SetSemBeamOn(bool val)
  118. {
  119. return iExtender.SetBeamAndFilamentOnOrOff(val);
  120. }
  121. public bool GetSemBeamOn()
  122. {
  123. return iExtender.GetSemBeamOn();
  124. }
  125. public bool SetSemBrightness(double a_dBrightness)
  126. {
  127. return iExtender.SetBrightness((float)a_dBrightness);
  128. }
  129. public bool SetSemContrast(double a_dContrast)
  130. {
  131. return iExtender.SetContrast((float)a_dContrast);
  132. }
  133. public bool SetSemHighTension(double a_dKV)
  134. {
  135. return iExtender.SetSEMVoltage((float)a_dKV);
  136. }
  137. public bool SetWorkingDistance(double a_distance)
  138. {
  139. return iExtender.SetWorkingDistance((float)a_distance);
  140. }
  141. public void StopXrayAcquisition()
  142. {
  143. iExtender.StopXrayAquisition();
  144. }
  145. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  146. {
  147. throw new NotImplementedException();
  148. }
  149. public bool SetSemBeamCurrentOff(bool val)
  150. {
  151. return iExtender.SetBeamAndFilamentOnOrOff(val);
  152. }
  153. public bool SetSemBeamBlank(bool val)
  154. {
  155. return iExtender.SetBeamAndFilamentOnOrOff(val);
  156. }
  157. bool ISemController.StopXrayAcquisition()
  158. {
  159. return true;
  160. }
  161. public bool SetSemHTOff(bool value)
  162. {
  163. return iExtender.SetBeamAndFilamentOnOrOff(value);
  164. }
  165. public bool RunHIGH_VACUUM()
  166. {
  167. return true;
  168. }
  169. public bool StopImageAcquisition()
  170. {
  171. return true;
  172. }
  173. public bool SetReducedArea()
  174. {
  175. return true;
  176. }
  177. public bool SetFullFrame()
  178. {
  179. return true;
  180. }
  181. }
  182. }