SmplMeasureCleanliness.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. int nSize = (int)a_listAnalysisParticles.Count();
  38. // go through all analysis particles
  39. int quantifyNum = 0;
  40. for (int i = 0; i < nSize; ++i)
  41. {
  42. COTSParticleClr pParticle = a_listAnalysisParticles[i];
  43. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  44. pParticle.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  45. if (!IsLowCounts(pParticle))
  46. {
  47. if (m_EDSController.GetIfDelayQuantify())
  48. {
  49. if (engine.ClassifyByExpressionTemporarySpectrum(pParticle))
  50. {
  51. if (pParticle.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
  52. {
  53. quantifyNum += 1;
  54. m_EDSController.QuantifyXrayByPart(pParticle);
  55. engine.ClassifyByExpression(pParticle);
  56. }
  57. }
  58. int specComp = nSize - quantifyNum;
  59. log.Info("spectrum compare:" + specComp.ToString() + "element quantify:" + quantifyNum);
  60. }
  61. else
  62. {
  63. engine.ClassifyByExpression(pParticle);
  64. }
  65. }
  66. }
  67. return true;
  68. }
  69. public override void CollectParticlesXrayData(COTSField curFldData)
  70. {
  71. base.CollectParticlesXrayData(curFldData);
  72. var parts = curFldData.GetListAnalysisParticles();
  73. string libname = m_Sample.GetMsrParams().GetSTDName();
  74. //process the maxeds rules
  75. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  76. double maxedstime=0;
  77. List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
  78. foreach (var p in parts)
  79. {
  80. if (engine.IfNeedMaxEDS(p, ref maxedstime))
  81. {
  82. maxedsparts.Add(p);
  83. }
  84. }
  85. if (maxedsparts.Count > 0)
  86. {
  87. log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
  88. m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
  89. }
  90. }
  91. }
  92. }