PicoSmartEDSController.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using FEIApiControl;
  2. using OTSCLRINTERFACE;
  3. using OTSModelSharp.ServiceCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OTSMeasureApp.ServiceCenter.PicoSmart
  10. {
  11. //class PicoSmartEDSController : EDSController
  12. //{
  13. //public PicoSmartEDSController(string deviceType, int expectcount, bool ifautoid, string knownelements) : base(deviceType, expectcount, ifautoid, knownelements)
  14. //{
  15. //}
  16. class PicoSmartEDSController : IEDSController
  17. {
  18. public PicoSmartApi_cshape m_api = null;
  19. private static string EdsDeviceType = "Bruker";
  20. private IEDSController m_eds=null;
  21. private int imgwidth=640 ;
  22. private int imgheight = 480;
  23. public static void set_EdsDeviceType(string DeviceType)
  24. {
  25. EdsDeviceType=DeviceType;
  26. }
  27. private int AnalyExpCount = 100000;
  28. private string strResolution = "";
  29. public PicoSmartEDSController(string SemType,string deviceType, int imgwidth, int imgheight, int expectcount, bool ifautoid, string knownelements)
  30. {
  31. EdsDeviceType= deviceType;
  32. m_api = PicoSmartSemController.GetApiClassInstance();
  33. AnalyExpCount = expectcount;
  34. Connect();
  35. //get eds
  36. switch (deviceType)
  37. {
  38. case "Oxford":
  39. m_eds = new OxfordEDSController(expectcount, ifautoid, knownelements);
  40. break;
  41. case "Bruker":
  42. {
  43. var ctrl = new EDSController("Bruker", expectcount, ifautoid, knownelements);
  44. //var delayQuant = Convert.ToBoolean(FileHelper.GetIfDelayQuantify());
  45. var delayQuant = false;//Now it has proved that this method won't increase the speed of xray analysis.So deactivate it here.
  46. ctrl.delayQuant = delayQuant;
  47. m_eds = ctrl;
  48. }
  49. break;
  50. default:
  51. m_eds = new EDSController("OffLine", expectcount, ifautoid, knownelements);
  52. break;
  53. }
  54. this.imgwidth = imgwidth;
  55. this.imgheight = imgheight;
  56. //加载能谱
  57. }
  58. public bool CollectSpectrum(uint a_nXRayAQTime, ref uint[] a_XrayData)
  59. {
  60. return m_eds.CollectSpectrum(a_nXRayAQTime, ref a_XrayData);
  61. }
  62. public bool Connect()
  63. {
  64. string FEIIP = FileHelper.GetXMLInformations("FEIIP");
  65. string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
  66. if (FEIIP == "" || FEIPORT == "")
  67. {
  68. NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
  69. return false;
  70. }
  71. m_api.set_ip(FEIIP);
  72. m_api.set_port(int.Parse(FEIPORT));
  73. if (m_api.isStart() == 1)
  74. {
  75. return true;
  76. }
  77. else if (m_api.start() == 1)
  78. {
  79. return true;
  80. }
  81. return false;
  82. }
  83. public EDSTYPE GetEDSType()
  84. {
  85. return EDSTYPE.COXM;
  86. }
  87. public int GetExpectCount()
  88. {
  89. return m_eds.GetExpectCount();
  90. }
  91. public bool GetIfDelayQuantify()
  92. {
  93. return m_eds.GetIfDelayQuantify();
  94. }
  95. public bool GetXRayByFeatures(List<COTSParticleClr> a_listParticles, double a_nXRayAQTime, bool a_bElementInfo)
  96. {
  97. return m_eds.GetXRayByFeatures(a_listParticles, a_nXRayAQTime, a_bElementInfo);
  98. }
  99. public bool GetXRayByParts(List<COTSParticleClr> a_listParticles, uint a_nXRayAQTime, bool a_bElementInfo)
  100. {
  101. return m_eds.GetXRayByParts(a_listParticles, a_nXRayAQTime, a_bElementInfo);
  102. }
  103. public bool QuantifyXrayByPart(COTSParticleClr part)
  104. {
  105. return m_eds.QuantifyXrayByPart(part);
  106. }
  107. public void SetFilterKeyEleNames(List<string> KeyNameList)
  108. {
  109. m_eds.SetFilterKeyEleNames(KeyNameList);
  110. }
  111. public void SetResolution(int resolutionWidth, int resolutionHeight)
  112. {
  113. imgwidth = resolutionWidth;
  114. imgheight = resolutionHeight;
  115. m_eds.SetResolution(resolutionWidth, resolutionHeight);
  116. }
  117. bool IEDSController.GetXRayByExpandFeatures(List<COTSParticleClr> a_listParticles, double a_nXRayAQTime, bool a_bElementInfo)
  118. {
  119. return m_eds.GetXRayByExpandFeatures(a_listParticles, a_nXRayAQTime, a_bElementInfo);
  120. }
  121. void IEDSController.SetQuantifiCationParam(bool IfAutoId, string knownElements)
  122. {
  123. m_eds.SetQuantifiCationParam(IfAutoId, knownElements);
  124. }
  125. }
  126. }