SmplMeasureCleanliness.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using OTSCLRINTERFACE;
  2. using OTSModelSharp.ServiceCenter;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace OTSModelSharp
  7. {
  8. using OTSDataType;
  9. using static OTSDataType.otsdataconst;
  10. class CSmplMeasureCleanliness : CSmplMeasure
  11. {
  12. public CSmplMeasureCleanliness(string a_strWorkingFolder, COTSSample a_pSample) : base(a_strWorkingFolder, a_pSample)
  13. {
  14. SetWorkingFolder(a_strWorkingFolder);
  15. SetSample(a_pSample);
  16. m_classifyEngine = new CClassifyEngine();
  17. }
  18. public override void ClassifyFieldParticles(COTSField curFldData)
  19. {
  20. try
  21. {
  22. string libname = m_Sample.GetMsrParams().GetSTDName();
  23. if (libname != "NoSTDDB")
  24. {
  25. log.Info("Begin to classify big particles!Using " + libname);
  26. var parts = curFldData.GetListAnalysisParticles();
  27. ClassifyParticles(parts, libname);
  28. }
  29. }
  30. catch (Exception e)
  31. {
  32. log.Info("calcu the particle image property or classify failed. " + e.Message);
  33. }
  34. }
  35. public bool ClassifyParticles(List<COTSParticleClr> a_listAnalysisParticles, string libname)// classify particles
  36. {
  37. if(libname == "NoSTDDB")
  38. {
  39. log.Error("No STDDB, can not classify particles");
  40. return false;
  41. }
  42. int nSize = (int)a_listAnalysisParticles.Count();
  43. // go through all analysis particles
  44. int quantifyNum = 0;
  45. for (int i = 0; i < nSize; ++i)
  46. {
  47. COTSParticleClr pParticle = a_listAnalysisParticles[i];
  48. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  49. pParticle.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  50. if (!IsLowCounts(pParticle))
  51. {
  52. if (m_EDSController.GetIfDelayQuantify())
  53. {
  54. if (engine.ClassifyByExpressionTemporarySpectrum(pParticle))
  55. {
  56. if (pParticle.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
  57. {
  58. quantifyNum += 1;
  59. m_EDSController.QuantifyXrayByPart(pParticle);
  60. engine.ClassifyByExpression(pParticle);
  61. }
  62. }
  63. int specComp = nSize - quantifyNum;
  64. log.Info("spectrum compare:" + specComp.ToString() + "element quantify:" + quantifyNum);
  65. }
  66. else
  67. {
  68. engine.ClassifyByExpression(pParticle);
  69. }
  70. }
  71. }
  72. return true;
  73. }
  74. public override void CollectParticlesXrayData(COTSField curFldData)
  75. {
  76. base.CollectParticlesXrayData(curFldData);
  77. var parts = curFldData.GetListAnalysisParticles();
  78. string libname = m_Sample.GetMsrParams().GetSTDName();
  79. //process the maxeds rules
  80. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  81. double maxedstime=0;
  82. List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
  83. foreach (var p in parts)
  84. {
  85. if (engine.IfNeedMaxEDS(p, ref maxedstime))
  86. {
  87. maxedsparts.Add(p);
  88. }
  89. }
  90. if (maxedsparts.Count > 0)
  91. {
  92. log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
  93. m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
  94. }
  95. }
  96. }
  97. }