ScanController.cs 3.7 KB

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