using OTSCLRINTERFACE; using OTSModelSharp.ServiceCenter; using System; using System.Collections.Generic; using System.Linq; namespace OTSModelSharp { using OTSDataType; using static OTSDataType.otsdataconst; class CSmplMeasureCleanliness : CSmplMeasure { public CSmplMeasureCleanliness(string a_strWorkingFolder, COTSSample a_pSample) : base(a_strWorkingFolder, a_pSample) { SetWorkingFolder(a_strWorkingFolder); SetSample(a_pSample); m_classifyEngine = new CClassifyEngine(); } public override void ClassifyFieldParticles(COTSField curFldData) { try { string libname = m_Sample.GetMsrParams().GetSTDName(); if (libname != "NoSTDDB") { log.Info("Begin to classify big particles!Using " + libname); var parts = curFldData.GetListAnalysisParticles(); ClassifyParticles(parts, libname); } } catch (Exception e) { log.Info("calcu the particle image property or classify failed. " + e.Message); } } public bool ClassifyParticles(List a_listAnalysisParticles, string libname)// classify particles { if(libname == "NoSTDDB") { log.Error("No STDDB, can not classify particles"); return false; } int nSize = (int)a_listAnalysisParticles.Count(); // go through all analysis particles for (int i = 0; i < nSize; ++i) { COTSParticleClr pParticle = a_listAnalysisParticles[i]; IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname); pParticle.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED); if (!IsLowCounts(pParticle)) { engine.ClassifyByExpression(pParticle); } } return true; } public override void CollectParticlesXrayData(COTSField curFldData) { base.CollectParticlesXrayData(curFldData); var parts = curFldData.GetListAnalysisParticles(); string libname = m_Sample.GetMsrParams().GetSTDName(); //process the maxeds rules IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(libname); double maxedstime=0; List maxedsparts = new List(); foreach (var p in parts) { if (engine.IfNeedMaxEDS(p, ref maxedstime)) { maxedsparts.Add(p); } } if (maxedsparts.Count > 0) { log.Warn("Begin to collect MaxEDS particles:" + maxedsparts.Count + "(" + maxedstime.ToString() + ") on Point mode"); m_EDSController.GetXRayByParts(maxedsparts, (uint)maxedstime, true); } } } }