SmplMeasureInclution.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using OTSCLRINTERFACE;
  2. using OTSDataType;
  3. using OTSModelSharp.ServiceCenter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using static OTSDataType.otsdataconst;
  8. namespace OTSModelSharp
  9. {
  10. class CSmplMeasureIncA : CSmplMeasure
  11. {
  12. public CSmplMeasureIncA(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. var anylysisparts = curFldData.GetListAnalysisParticles();
  23. int nSize = anylysisparts.Count();
  24. // go through all analysis particles
  25. for (int i = 0; i < nSize; ++i)
  26. {
  27. string libname = m_Sample.GetMsrParams().GetSTDName();
  28. if (!IsLowCounts(anylysisparts[i]))
  29. {
  30. ClassifyIncAParticle(anylysisparts[i], libname);
  31. }
  32. }
  33. }
  34. catch (Exception e)
  35. {
  36. log.Info(" classify failed. " + e.Message);
  37. }
  38. }
  39. public bool ClassifyIncAParticle(COTSParticleClr particle, string libname)// classify particles
  40. {
  41. int steelTech = (int)m_Sample.GetMsrParams().GetSteelTechnology();
  42. particle.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  43. if (m_Sample.GetMsrParams().GetEngineType()==OTS_CLASSIFY_ENGINE_TYPE.InclutionPlusExpressionParse)
  44. {
  45. if (libname != "NoSTDDB")
  46. {
  47. //var m_classifyEngine = new CClassifyEngine();
  48. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  49. engine.ClassifyByExpression(particle);
  50. }
  51. if (particle.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED || particle.GetType() == (int)OTS_PARTICLE_TYPE.UNCLASSIFY)
  52. {
  53. IClassifyEngine engine;
  54. engine = m_classifyEngine.GetIncClassifyEngine();
  55. engine.ClassifyIncA(particle, steelTech);
  56. }
  57. }
  58. else if(m_Sample.GetMsrParams().GetEngineType() == OTS_CLASSIFY_ENGINE_TYPE.ExpressionParse)
  59. {
  60. if (libname != "NoSTDDB")
  61. {
  62. //var m_classifyEngine = new CClassifyEngine();
  63. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  64. engine.ClassifyByExpression(particle);
  65. }
  66. }
  67. else if(m_Sample.GetMsrParams().GetEngineType() == OTS_CLASSIFY_ENGINE_TYPE.SpectrumMatch)
  68. {
  69. if (libname != "NoSTDDB")
  70. {
  71. //var m_classifyEngine = new CClassifyEngine();
  72. IClassifyEngine engine = m_classifyEngine.GetSpectrumCompareEngine(libname);
  73. engine.ClassifyBySpectrum(particle);
  74. }
  75. }
  76. else if(m_Sample.GetMsrParams().GetEngineType() == OTS_CLASSIFY_ENGINE_TYPE.InclustionEngine)
  77. {
  78. IClassifyEngine engine;
  79. engine = m_classifyEngine.GetIncClassifyEngine();
  80. engine.ClassifyIncA(particle, steelTech);
  81. }
  82. return true;
  83. }
  84. public override void CollectParticlesXrayData(COTSField curFldData)
  85. {
  86. base.CollectParticlesXrayData(curFldData);
  87. var parts = curFldData.GetListAnalysisParticles();
  88. string libname = m_Sample.GetMsrParams().GetSTDName();
  89. //process the maxeds rules
  90. if (m_Sample.GetMsrParams().GetEngineType() == OTS_CLASSIFY_ENGINE_TYPE.InclutionPlusExpressionParse ||
  91. m_Sample.GetMsrParams().GetEngineType() == OTS_CLASSIFY_ENGINE_TYPE.ExpressionParse)
  92. {
  93. if (libname != "NoSTDDB")
  94. {
  95. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname);
  96. double maxedstime = 0;
  97. List<COTSParticleClr> maxedsparts = new List<COTSParticleClr>();
  98. foreach (var p in parts)
  99. {
  100. if (engine.IfNeedMaxEDS(p, ref maxedstime))
  101. {
  102. maxedsparts.Add(p);
  103. }
  104. }
  105. if (maxedsparts.Count > 0)
  106. {
  107. log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode");
  108. m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true);
  109. }
  110. }
  111. }
  112. }
  113. }
  114. }