ScanController.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. 
  2. using FEIApiControl;
  3. using OTSCLRINTERFACE;
  4. using OTSMeasureApp.ServiceCenter;
  5. using System.Drawing;
  6. using static OxfordExtenderWrapper.ExtenderIpcUI;
  7. namespace OTSModelSharp.ServiceCenter
  8. {
  9. public class ScanController : IScanController
  10. {
  11. private OTSCLRINTERFACE.COTSControlFunExport scan;
  12. static IScanController scanctrl = null;
  13. public static APIClass ApiClass = null;
  14. int imageWidth = 0;
  15. int imageHeight = 0;
  16. public static IScanController GetScanController()
  17. {
  18. var semtype = FileHelper.GetXMLInformations("SemControllerName");
  19. if (scanctrl == null)
  20. {
  21. if (semtype == "FEI")
  22. {
  23. scanctrl = new FEIScanController();
  24. }
  25. else if (semtype == "Oxford")
  26. {
  27. var srcType = FileHelper.GetOxfordInputSourceType();
  28. ImageInputSourceType imageSrcType = ImageInputSourceType.Bse;
  29. if (srcType == "SE")
  30. {
  31. imageSrcType = ImageInputSourceType.SE;
  32. }
  33. else if (srcType == "BSE")
  34. {
  35. imageSrcType = ImageInputSourceType.Bse;
  36. }
  37. scanctrl = new OxfordScanController(imageSrcType);
  38. }
  39. else
  40. {
  41. scanctrl = new ScanController(semtype);
  42. }
  43. }
  44. return scanctrl;
  45. }
  46. private ScanController(string devicetype)
  47. {
  48. this.scan = OTSCLRINTERFACE.COTSControlFunExport.GetControllerInstance(devicetype);
  49. }
  50. public CBSEImgClr AcquireBSEImage()
  51. {
  52. if (!scan.IsConnected())
  53. {
  54. return null;
  55. }
  56. Rectangle r = new Rectangle();
  57. CBSEImgClr bse = new CBSEImgClr(r);
  58. NLog.LogManager.GetCurrentClassLogger().Info("Bruker:Begin to acquire BSE image!");
  59. if (!scan.AcquireBSEImage(ref bse))
  60. {
  61. return null;
  62. }
  63. NLog.LogManager.GetCurrentClassLogger().Info("Bruker:End acquiring BSE image!");
  64. return bse;
  65. }
  66. public bool Init()
  67. {
  68. if (!scan.IsConnected())
  69. {
  70. scan.ConncetSem();
  71. }
  72. return scan.ScanInit();
  73. }
  74. public bool SetDwellTime(DwellTimeLevel val)
  75. {
  76. double dwelltime = 2;
  77. switch (val)
  78. {
  79. case DwellTimeLevel.Low:
  80. dwelltime = 2;
  81. break;
  82. case DwellTimeLevel.Medium:
  83. dwelltime = 4;
  84. break;
  85. case DwellTimeLevel.High:
  86. dwelltime = 8;
  87. break;
  88. }
  89. if (!scan.IsConnected())
  90. {
  91. return false;
  92. }
  93. return scan.SetDwellTime((int)dwelltime);
  94. }
  95. public bool SetImageSize(int width, int height)
  96. {
  97. imageWidth = width;
  98. imageHeight = height;
  99. if (!scan.IsConnected())
  100. {
  101. return false;
  102. }
  103. return scan.SetImageSize(width, height);
  104. }
  105. public CBSEImgClr AcquireRectangleBSEImage(Rectangle rec)
  106. {
  107. return null;
  108. }
  109. }
  110. }