SemController.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. public SemController()
  14. {
  15. hw =new OTSCLRINTERFACE.COTSControlFunExport();
  16. }
  17. public bool Connect()
  18. {
  19. if (!hw.Init())
  20. {
  21. return false;
  22. }
  23. if (hw.IsConnected())
  24. {
  25. return true;
  26. }
  27. return hw.ConncetSem();
  28. }
  29. public bool IsConnected()
  30. {
  31. //return true;
  32. return hw.IsConnected();
  33. }
  34. public bool DisConnect()
  35. {
  36. if (hw.IsConnected())
  37. {
  38. return hw.DisconnectSem();
  39. }
  40. return true;
  41. }
  42. public bool GetSEMDataGnrFromHw(ref CSEMDataGnr SemDataGnr)
  43. {
  44. if (!hw.IsConnected())
  45. {
  46. return false;
  47. }
  48. double kv=0, brightness=0, contrast=0;
  49. hw.GetSemHighTension(ref kv);
  50. hw.GetSemBrightness(ref brightness);
  51. hw.GetSemContrast(ref contrast);
  52. SemDataGnr.SetValue(kv, brightness, contrast);
  53. return true;
  54. }
  55. public bool GetMagnification(ref double a_dMagnification)
  56. {
  57. if (!hw.IsConnected())
  58. {
  59. return false;
  60. }
  61. return hw.GetSemMagnification(ref a_dMagnification);
  62. }
  63. public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
  64. {
  65. if (!hw.IsConnected())
  66. {
  67. return false;
  68. }
  69. return hw.GetSemScanFieldSize(ref dScanFieldSizeX, ref dScanFieldSizeY);
  70. }
  71. public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
  72. {
  73. if (!hw.IsConnected())
  74. {
  75. return false;
  76. }
  77. return hw.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR);
  78. }
  79. public bool GetWorkingDistance(ref double a_distance)
  80. {
  81. if (!hw.IsConnected())
  82. {
  83. return false;
  84. }
  85. return hw.GetSemWorkingDistance(ref a_distance);
  86. }
  87. public bool MoveSEMToPoint(Point poi, double rotation)
  88. {
  89. if (!hw.IsConnected())
  90. {
  91. return false;
  92. }
  93. return hw.MoveSEMToPoint(poi.X, poi.Y, rotation);
  94. }
  95. public bool SetMagnification(double a_dMagnification)
  96. {
  97. if (!hw.IsConnected())
  98. {
  99. return false;
  100. }
  101. //hw.SetMagnification(a_dMagnification);
  102. hw.SetSemMagnification(a_dMagnification);
  103. return true;
  104. }
  105. public bool SetScanExternal(bool b)
  106. {
  107. if (!hw.IsConnected())
  108. {
  109. return false;
  110. }
  111. //int seValue = b ? 1 : 0;
  112. return hw.SetSemScanExternal(b);
  113. }
  114. public bool SetWorkingDistance(double a_distance)
  115. {
  116. if (!hw.IsConnected())
  117. {
  118. return false;
  119. }
  120. return hw.SetSemWorkingDistance(a_distance);
  121. }
  122. public OTSCLRINTERFACE.COTSControlFunExport GetHardwareInterface()
  123. {
  124. if (!hw.IsConnected())
  125. {
  126. return null;
  127. }
  128. return hw;
  129. }
  130. }
  131. }