SmplMeasureCleanliness.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. for (int i = 0; i < nSize; ++i)
  45. {
  46. COTSParticleClr pParticle = a_listAnalysisParticles[i];
  47. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  48. pParticle.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  49. if (!IsLowCounts(pParticle))
  50. {
  51. engine.ClassifyByExpression(pParticle);
  52. }
  53. }
  54. return true;
  55. }
  56. public override void CollectParticlesXrayData(COTSField curFldData)
  57. {
  58. base.CollectParticlesXrayData(curFldData);
  59. var parts = curFldData.GetListAnalysisParticles();
  60. string libname = m_Sample.GetMsrParams().GetSTDName();
  61. //process the maxeds rules
  62. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  63. double maxedstime=0;
  64. List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
  65. foreach (var p in parts)
  66. {
  67. if (engine.IfNeedMaxEDS(p, ref maxedstime))
  68. {
  69. maxedsparts.Add(p);
  70. }
  71. }
  72. if (maxedsparts.Count > 0)
  73. {
  74. log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
  75. m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
  76. }
  77. }
  78. }
  79. }