CSmplMeasureInclutionForSteelMineral.cs 5.0 KB

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