FEIScanController.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using FEIApiControl;
  2. using OTSCLRINTERFACE;
  3. using OTSModelSharp.ServiceCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace OTSMeasureApp.ServiceCenter
  11. {
  12. class FEIScanController : IScanController
  13. {
  14. int imageWidth = 0;
  15. int imageHeight = 0;
  16. double dwelltime = 0;
  17. private APIClass ApiClass = null;
  18. public FEIScanController()
  19. {
  20. ApiClass = FEISemController.GetApiClassInstance();
  21. }
  22. public CBSEImgClr AcquireBSEImage()
  23. {
  24. Rectangle r = new Rectangle();
  25. CBSEImgClr bse = new CBSEImgClr(r);
  26. bse.InitImageData(imageWidth, imageHeight);
  27. byte[] imgData = new byte[imageWidth * imageHeight];
  28. NLog.LogManager.GetCurrentClassLogger().Info("FEI:Begin to acquire BSE image!");
  29. if (!ApiClass.RunAcquireImage(imageWidth, imageHeight, dwelltime, "", ref imgData))
  30. {
  31. return null;
  32. }
  33. NLog.LogManager.GetCurrentClassLogger().Info("FEI:End acquiring BSE image!");
  34. bse.SetImageData(imgData, imageWidth, imageHeight);
  35. return bse;
  36. }
  37. public CBSEImgClr AcquireRectangleBSEImage(System.Drawing.Rectangle rec)
  38. {
  39. int fieldWidth = 3072;
  40. int fieldHeight = 2048;
  41. //Rectangle r = new Rectangle();
  42. //double curwidth=0, curheight=0;
  43. //ApiClass.GetCurrentResolution(ref curwidth, ref curheight);
  44. double mag =0;
  45. CBSEImgClr bse = new CBSEImgClr(rec);
  46. //bse.InitImageDa/*t*/a(imageWidth, imageHeight);
  47. byte[] imgData= new byte[0];
  48. //double mag=0;
  49. if (!ApiClass.RunAcquireImageRect(fieldWidth, fieldHeight, rec,ref mag, 2, "", ref imgData))
  50. {
  51. return null;
  52. }
  53. bse.SetImageData(imgData, (int)(rec.Width*mag), (int)(rec.Height*mag));
  54. return bse;
  55. }
  56. public bool Init()
  57. {
  58. string FEIIP = FileHelper.GetXMLInformations("FEIIP");
  59. string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
  60. if (FEIIP == "" || FEIPORT == "")
  61. {
  62. NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
  63. return false;
  64. }
  65. if (ApiClass.isConnect())
  66. {
  67. return true;
  68. }
  69. return ApiClass.Connect(FEIIP, FEIPORT);
  70. }
  71. public bool SetDwellTime(DwellTimeLevel val)
  72. {
  73. dwelltime = 0.5;
  74. switch (val)
  75. {
  76. case DwellTimeLevel.Low:
  77. dwelltime = 0.5;
  78. break;
  79. case DwellTimeLevel.Medium:
  80. dwelltime = 1;
  81. break;
  82. case DwellTimeLevel.High:
  83. dwelltime = 4;
  84. break;
  85. }
  86. return true;
  87. }
  88. public bool SetImageSize(int nWidth, int nHeight)
  89. {
  90. imageWidth = nWidth;
  91. imageHeight = nHeight;
  92. return ApiClass.SetResolution(imageWidth, imageHeight); ;
  93. }
  94. }
  95. }