ScanController.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. 
  2. using FEIApiControl;
  3. using OINA.Extender.Data.Image;
  4. using OTSCLRINTERFACE;
  5. using OTSDataType;
  6. using OTSMeasureApp.ServiceCenter;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace OTSModelSharp.ServiceCenter
  15. {
  16. public class BrukerScanController : 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. ImageInputSources imageSrcType=ImageInputSources.Bse;
  36. if (srcType == "SE")
  37. {
  38. imageSrcType = ImageInputSources.SE;
  39. }
  40. else if (srcType == "BSE")
  41. {
  42. imageSrcType = ImageInputSources.Bse;
  43. }
  44. scanctrl = new OxfordScanController(imageSrcType);
  45. }
  46. else
  47. {
  48. scanctrl = new BrukerScanController(semtype);
  49. }
  50. }
  51. return scanctrl;
  52. }
  53. private BrukerScanController(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(double val)
  80. {
  81. if (!scan.IsConnected())
  82. {
  83. return false;
  84. }
  85. return scan.SetDwellTime((int)val);
  86. }
  87. public bool SetImageSize(int width,int height)
  88. {
  89. imageWidth = width;
  90. imageHeight = height;
  91. if (!scan.IsConnected())
  92. {
  93. return false;
  94. }
  95. return scan.SetImageSize(width, height);
  96. }
  97. }
  98. }