SEMAndEDSOperate.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. 
  2. using OTSCLRINTERFACE;
  3. using OTSCommon.DBOperate.Model;
  4. using OTSIncAReportApp.SysMgrTools;
  5. using OTSModelSharp.ServiceCenter;
  6. using ServiceInterface;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Drawing;
  11. using System.Linq;
  12. namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
  13. {
  14. public class SEMAndEDSOperate
  15. {
  16. #region 定义变量
  17. //为了加快颗粒列表抠图的速度,这里保存一个全局变量
  18. public List<Field> m_list_COTSFieldMgrClr = null;
  19. //是否已经连接到了电镜
  20. public bool m_SEMConnectionState = false;
  21. //连接到电镜的ID号
  22. public int m_SEM_ID = 0;
  23. public HardwareController m_cfun = null;
  24. #endregion
  25. #region 构造函数
  26. /// <summary>
  27. /// 需传入,主窗体对象,与要获取数据窗体的对象
  28. /// </summary>
  29. /// <param name="in_frmReportApp"></param>
  30. /// <param name="form"></param>
  31. public SEMAndEDSOperate()
  32. {
  33. m_cfun = HardwareController.GetSemController();// It's better to reinitialize, but it's not good to uninitialize
  34. }
  35. #endregion
  36. #region 自定义方法封装
  37. #endregion
  38. #region 连接电镜相关
  39. /// <summary>
  40. /// 连接电镜,颗粒列表使用
  41. /// </summary>
  42. public bool Connection_ForParticlesGrid()
  43. {
  44. if (!m_SEMConnectionState)
  45. {
  46. m_SEMConnectionState = m_cfun.Connect();
  47. }
  48. return m_SEMConnectionState;
  49. }
  50. /// <summary>
  51. /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
  52. /// </summary>
  53. /// <param name="PositionX"></param>
  54. /// <param name="PositionY"></param>
  55. public bool MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
  56. {
  57. bool isSuccess = false;
  58. //首先获取电镜当前的位置,并记录原R值
  59. double ls_PositionX = 0;
  60. double ls_PositionY = 0;
  61. double ls_PositionR = 0;
  62. if (m_SEMConnectionState)
  63. {
  64. isSuccess = m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
  65. }
  66. if (m_SEMConnectionState)
  67. {
  68. isSuccess = m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
  69. }
  70. return isSuccess;
  71. }
  72. /// <summary>
  73. /// 设置放大倍数
  74. /// </summary>
  75. /// <param name="a_dMagnification"></param>
  76. /// <returns></returns>
  77. public bool SetMagnification(double a_dMagnification)
  78. {
  79. bool isSuccess = false;
  80. if (m_SEMConnectionState)
  81. {
  82. isSuccess = m_cfun.SetMagnification(a_dMagnification);
  83. }
  84. return isSuccess;
  85. }
  86. public bool AcquireBSEImage(string sampleName, int width, int height, DwellTimeLevel dwellTime, ref byte[] ImageByte)
  87. {
  88. bool isSuccess = false;
  89. if (m_SEMConnectionState)
  90. {
  91. isSuccess = m_cfun.AcquireBSEImage(sampleName, width, height, dwellTime, ref ImageByte);
  92. }
  93. return isSuccess;
  94. }
  95. public bool AcquisitionSpectrum(string samplePath, int xrayMode, double new_PixelSize, ref Particle particle, uint a_nXRayAQTime)
  96. {
  97. bool isSuccess = false;
  98. if (m_SEMConnectionState)
  99. {
  100. isSuccess = m_cfun.AcquisitionSpectrum(samplePath, xrayMode, new_PixelSize, ref particle, a_nXRayAQTime);
  101. }
  102. return isSuccess;
  103. }
  104. #endregion
  105. }
  106. }