FEIScanController.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. if (!ApiClass.RunAcquireImage(imageWidth, imageHeight, dwelltime, "", ref imgData))
  29. {
  30. return null;
  31. }
  32. bse.SetImageData(imgData, imageWidth, imageHeight);
  33. return bse;
  34. }
  35. public bool Init()
  36. {
  37. string FEIIP = FileHelper.GetXMLInformations("FEIIP");
  38. string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
  39. if (FEIIP == "" || FEIPORT == "")
  40. {
  41. NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
  42. return false;
  43. }
  44. if (ApiClass.isConnect())
  45. {
  46. return true;
  47. }
  48. return ApiClass.Connect(FEIIP, FEIPORT);
  49. }
  50. public bool SetDwellTime(double val)
  51. {
  52. dwelltime = val;
  53. return true;
  54. }
  55. public bool SetImageSize(int nWidth, int nHeight)
  56. {
  57. imageWidth = nWidth;
  58. imageHeight = nHeight;
  59. return ApiClass.SetResolution(imageWidth, imageHeight); ;
  60. }
  61. }
  62. }