SemController.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. 
  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 ServiceInterface
  9. {
  10. public class SemController
  11. {
  12. public static OTSCLRINTERFACE.COTSControlFunExport hw=null;
  13. public SemController()
  14. {
  15. }
  16. public bool Connect()
  17. {
  18. if (hw == null)
  19. {
  20. hw = OTSCLRINTERFACE.COTSControlFunExport.GetControllerInstance();
  21. }
  22. if (hw.IsConnected())
  23. {
  24. return true;
  25. }
  26. else
  27. { //和电镜建立通讯连接
  28. return hw.ConncetSem();
  29. }
  30. }
  31. public bool DisConnect()
  32. {
  33. if (hw != null)
  34. {
  35. if (hw.IsConnected())
  36. {
  37. return hw.DisconnectSem();
  38. }
  39. }
  40. return true;
  41. }
  42. public bool GetMagnification(ref double a_dMagnification)
  43. {
  44. Connect();
  45. return hw.GetSemMagnification(ref a_dMagnification);
  46. }
  47. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  48. {
  49. Connect();
  50. return hw.GetSemScanFieldSize(ref dScanFieldSizeX, ref dScanFieldSizeY);
  51. }
  52. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  53. {
  54. Connect();
  55. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  56. }
  57. public bool GetWorkingDistance(ref double a_distance)
  58. {
  59. Connect();
  60. return hw.GetSemWorkingDistance(ref a_distance);
  61. }
  62. public bool IsConnected()
  63. {
  64. //return true;
  65. return hw.IsConnected();
  66. }
  67. public bool MoveSEMToPoint(Point poi, double rotation)
  68. {
  69. Connect();
  70. return hw.MoveSEMToPoint(poi.X, poi.Y, rotation);
  71. }
  72. public bool SetMagnification(double a_dMagnification)
  73. {
  74. Connect();
  75. //hw.SetMagnification(a_dMagnification);
  76. hw.SetSemMagnification(a_dMagnification);
  77. return true;
  78. }
  79. public bool SetScanExternal(bool b)
  80. {
  81. Connect();
  82. //int seValue = b ? 1 : 0;
  83. return hw.SetSemScanExternal(b);
  84. }
  85. public bool SetWorkingDistance(double a_distance)
  86. {
  87. Connect();
  88. return hw.SetSemWorkingDistance(a_distance);
  89. }
  90. public OTSCLRINTERFACE.COTSControlFunExport GetHardwareInterface()
  91. {
  92. return hw;
  93. }
  94. }
  95. }