瀏覽代碼

clean the ExpressionClassifyEngine code. remove some old comment

gsp 2 年之前
父節點
當前提交
02556c4fae

+ 130 - 128
OTSCPP/OTSClassifyEngine/ExpressionClassifyEngine.cpp

@@ -42,20 +42,10 @@ bool ExpressionClassifyEngine::Init()
 bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPosXrayPtr xray)
 {
 
-	if (particle != nullptr && xray != nullptr)
+	if (particle != nullptr && xray != nullptr)//process the particle with the xray data
 	{
 		auto& originalPartEles = xray->GetElementQuantifyData();//find all the elements containing in the particle xray.
-		//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
-		/*std::string allele=std::to_string(particle->GetTagId()) + " ";
-		for (auto che : originalPartEles)
-		{
-			allele += che->GetName().GetBuffer() ;
-			allele += ":";
-			allele += std::to_string(che->GetPercentage()).c_str();
-			allele += "  ";
-		}
-		LogTrace(__FILE__, __LINE__, allele.c_str());*/
-		//-----------------------------
+
 		//zero element process,if satisfied the condition than set the particular element percentage to 0.and make it 100% of all the element percentage.
 
 		auto partEles = ZeroElementProcess(particle, xray);//
@@ -67,15 +57,11 @@ bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPos
 			mapChemistrys[ch->GetName().GetBuffer()] = ch;
 		}
 
-
 		PartSTDRuleItemList ruleItems = m_std->GetSTDRuleItems();
-		//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
-		/*CString stdnum = _T("STDNum ")+ CString(std::to_string(stdItems.size()).c_str());
-		LogTrace(__FILE__, __LINE__, stdnum);*/
+
 		for (auto itm : ruleItems)
 		{
-			std::string exp = itm->GetExpressionStr();
-			//LogTrace(__FILE__, __LINE__, exp.c_str());
+			
 			//if the element quantity is not match the std item's keyelement num than they are unmatching.
 			if (partEles.size() < itm->GetKeyElementList().size())
 			{
@@ -100,87 +86,16 @@ bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPos
 
 			if (!bMatch) continue;
 
-			// process the special property name such as "first_elem" and "Element#1" etc.
-			for (std::string s : itm->GetUsingOtherpropertyList())
-			{
-
-				if (s.find("_elem") != std::string::npos)
-				{
-					auto val = GetAtomicNoBySortingPercentage(s.c_str(), xray);
-
-					xmls::ReplaceAll(exp, s, std::to_string(val));
-				}
-
-				if (s.find("Element#") != std::string::npos)
-				{
-					auto val = GetEleNameBySortingPercentage(s.c_str(), xray);//find the "Element#1" and  replace it with the real element name. 
-					auto elelist = itm->GetKeyElementList();
-					elelist.push_back(CElementPtr(new CElement(val)));// then replace it in the next step.
-					itm->SetKeyElementList(elelist);
-					xmls::ReplaceAll(exp, s, val.GetBuffer());
-				}
-			}
-
-			for (auto eleChemistry : itm->GetAllSortedEleList())
-			{
-				auto e = mapChemistrys.find(eleChemistry->GetName().GetBuffer());
-
-				if (e != mapChemistrys.end())
-				{
-					std::string name = eleChemistry->GetName();
-
-					xmls::ReplaceAll(exp, name, std::to_string(e->second->GetPercentage()));
-				}
-				else
-				{
-					std::string name = eleChemistry->GetName();
-
-					xmls::ReplaceAll(exp, name, "0");
-				}
-			}
-
-			//process the image property
-			for (std::string s : itm->GetUsingImgPropertyNameList())
-			{
-				auto val = particle->GetImgPropertyValueByName(s.c_str());
-				xmls::ReplaceAll(exp, s, std::to_string(val));
-			}
-			//process the "true" keyword.
-			if (exp.find("true") != std::string::npos)
-			{
-				xmls::ReplaceAll(exp, "true", "(1=1)");
-			}
-			//process the "false" keyword.
-			if (exp.find("false") != std::string::npos)
-			{
-				xmls::ReplaceAll(exp, "false", "(1=0)");
-			}
-			for (int i = 0; i < 10; i++)
-			{
-				std::string macStr = "MAC#" + std::to_string(i);
-				if (exp.find(macStr) != std::string::npos)
-				{
-					auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and  replace it with the real element name. 
-					xmls::ReplaceAll(exp, macStr, std::to_string(val));
-				}
-
-			}
+			std::string exp = itm->GetExpressionStr();
 		
+			
+			ProcessAllPropertiesWithParticleData(exp, mapChemistrys, itm, particle);
 
 			//calculate the expression which has been processed.
 			
 			bool rst = CalcuExp(exp);
 
-			//以下为调试用代码段(在log中打出颗粒元素),不要删除----------
-			/*LogTrace(__FILE__, __LINE__, exp.c_str());
-			if (rst)
-			{
-				LogTrace(__FILE__, __LINE__, CString("true"));
-			}
-			else
-			{
-				LogTrace(__FILE__, __LINE__, CString("false"));
-			}*/
+	
 			
 			if (rst)
 			{
@@ -196,6 +111,14 @@ bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPos
 				particle->SetGroupId(itm->GetGrpID());
 				particle->SetGroupColor(itm->GetGrpColor());
 				particle->SetGroupName(itm->GetGrpName());
+
+				//if this item is a spectrum compared item then we should memory these spectrum to be used when doing spectrum compare.
+
+				if (itm->GetIsElementAnalysis() == false)
+				{
+
+					itm->AddXraySpectrum(particle->GetXrayInfo());
+				}
 				return true;
 			}
 			else
@@ -211,45 +134,20 @@ bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPos
 		particle->SetGroupColor("#000000");
 		return true;
 	}
-	else if(particle != nullptr && xray == nullptr)
+	else if(particle != nullptr && xray == nullptr)//process particle without xray data
 	{
 		PartSTDRuleItemList stdItems = m_std->GetSTDRuleItems();
 
 		for (auto itm : stdItems)
 		{
 			std::string exp = itm->GetExpressionStr();
-
+			//if the rule demand any element infomation then they won't match.
 			if (itm->GetKeyElementList().size() > 0 || itm->GetSubElementList().size() > 0)
 			{
 				continue;
 			}
 
-			//process the image property
-			for (std::string s : itm->GetUsingImgPropertyNameList())
-			{
-				auto val = particle->GetImgPropertyValueByName(s.c_str());
-				xmls::ReplaceAll(exp, s, std::to_string(val));
-			}
-			//process the "true" keyword.
-			if (exp.find("true") != std::string::npos)
-			{
-				xmls::ReplaceAll(exp, "true", "(1=1)");
-			}
-			//process the "false" keyword.
-			if (exp.find("false") != std::string::npos)
-			{
-				xmls::ReplaceAll(exp, "false", "(1=0)");
-			}
-			for (int i = 0; i < 10; i++)
-			{
-				std::string macStr = "MAC#" + std::to_string(i);
-				if (exp.find(macStr) != std::string::npos)
-				{
-					auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and  replace it with the real element name. 
-					xmls::ReplaceAll(exp, macStr, std::to_string(val));
-				}
-
-			}
+			ProcessImgPropertiesWithParticleData(exp, itm, particle);
 			
 
 			//calculate the expression which has been processed.
@@ -270,10 +168,7 @@ bool ExpressionClassifyEngine::ClassifyExpression(COTSParticlePtr particle, CPos
 				particle->SetGroupColor(itm->GetGrpColor());
 				particle->SetGroupName(itm->GetGrpName());
 
-				if (itm->GetIsElementAnalysis() == false)
-				{
-					itm->AddXraySpectrum(particle->GetXrayInfo());
-				}
+				
 
 				return true;
 			}
@@ -489,7 +384,7 @@ CElementChemistriesList ExpressionClassifyEngine::ZeroElementProcess(COTSParticl
 		auto newChe = CElementChemistryPtr(new CElementChemistry(che.get()));
 		partEles.push_back(newChe);
 	}
-	//make it 100% in total.
+	//make it 100% in total.(so called the "Normalization")
 	double rawPercentage = 0;
 	for (auto ele : partEles)
 	{
@@ -590,7 +485,7 @@ CElementChemistriesList ExpressionClassifyEngine::ZeroElementProcess(COTSParticl
 				if (itr != partEles.end())
 				{
 					//partEles.erase(itr);//if satisfied the condition then erase the element(zero the element).
-					(*itr)->SetPercentage(0);//if satisfied the condition then set element percenttage to 0(zero the element).
+					(*itr)->SetPercentage(0);//if satisfied the condition then set element percentage to 0(zero the element).
 					double sumPercentage=0;
 					for (auto ele : partEles)
 					{
@@ -615,6 +510,112 @@ CElementChemistriesList ExpressionClassifyEngine::ZeroElementProcess(COTSParticl
 
 }
 
+void ExpressionClassifyEngine::ProcessAllPropertiesWithParticleData(std::string& exp,
+	std::map<std::string, CElementChemistryPtr>& mapChemistrys,
+	PartSTDRuleItemPtr itm, 
+	COTSParticlePtr particle
+	)
+{
+	// process the special property name such as "first_elem" and "Element#1" etc.
+	auto xray = particle->GetXrayInfo();
+	for (std::string s : itm->GetUsingOtherpropertyList())
+	{
+
+		if (s.find("_elem") != std::string::npos)
+		{
+			auto val = GetAtomicNoBySortingPercentage(s.c_str(), xray);
+
+			xmls::ReplaceAll(exp, s, std::to_string(val));
+		}
+
+		if (s.find("Element#") != std::string::npos)
+		{
+			auto val = GetEleNameBySortingPercentage(s.c_str(), xray);//find the "Element#1" and  replace it with the real element name. 
+			auto elelist = itm->GetKeyElementList();
+			elelist.push_back(CElementPtr(new CElement(val)));// then replace it in the next step.
+			itm->SetKeyElementList(elelist);
+			xmls::ReplaceAll(exp, s, val.GetBuffer());
+		}
+	}
+	//process the element property
+	for (auto eleChemistry : itm->GetAllSortedEleList())
+	{
+		auto e = mapChemistrys.find(eleChemistry->GetName().GetBuffer());
+
+		if (e != mapChemistrys.end())
+		{
+			std::string name = eleChemistry->GetName();
+
+			xmls::ReplaceAll(exp, name, std::to_string(e->second->GetPercentage()));
+		}
+		else
+		{
+			std::string name = eleChemistry->GetName();
+
+			xmls::ReplaceAll(exp, name, "0");
+		}
+	}
+
+	//process the image property
+	for (std::string s : itm->GetUsingImgPropertyNameList())
+	{
+		auto val = particle->GetImgPropertyValueByName(s.c_str());
+		xmls::ReplaceAll(exp, s, std::to_string(val));
+	}
+	//process the "true" keyword.
+	if (exp.find("true") != std::string::npos)
+	{
+		xmls::ReplaceAll(exp, "true", "(1=1)");
+	}
+	//process the "false" keyword.
+	if (exp.find("false") != std::string::npos)
+	{
+		xmls::ReplaceAll(exp, "false", "(1=0)");
+	}
+	//process the contant value
+	for (int i = 0; i < 10; i++)
+	{
+		std::string macStr = "MAC#" + std::to_string(i);
+		if (exp.find(macStr) != std::string::npos)
+		{
+			auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and  replace it with the real element name. 
+			xmls::ReplaceAll(exp, macStr, std::to_string(val));
+		}
+
+	}
+}
+
+void ExpressionClassifyEngine::ProcessImgPropertiesWithParticleData(std::string& exp, PartSTDRuleItemPtr itm, COTSParticlePtr particle)
+{
+	//process the image property
+	for (std::string s : itm->GetUsingImgPropertyNameList())
+	{
+		auto val = particle->GetImgPropertyValueByName(s.c_str());
+		xmls::ReplaceAll(exp, s, std::to_string(val));
+	}
+	//process the "true" keyword.
+	if (exp.find("true") != std::string::npos)
+	{
+		xmls::ReplaceAll(exp, "true", "(1=1)");
+	}
+	//process the "false" keyword.
+	if (exp.find("false") != std::string::npos)
+	{
+		xmls::ReplaceAll(exp, "false", "(1=0)");
+	}
+	//process the constant value
+	for (int i = 0; i < 10; i++)
+	{
+		std::string macStr = "MAC#" + std::to_string(i);
+		if (exp.find(macStr) != std::string::npos)
+		{
+			auto val = GetMacValue(macStr.c_str());//find the "Mac#1" and  replace it with the real element name. 
+			xmls::ReplaceAll(exp, macStr, std::to_string(val));
+		}
+
+	}
+}
+
 bool ExpressionClassifyEngine::ClassifyBySpectrum(COTSParticlePtr particle, CPosXrayPtr xray)
 {
 	return false;
@@ -631,7 +632,8 @@ bool ExpressionClassifyEngine::ClassifyByExpressionTemporarySpectrum(COTSParticl
 	{
 		if (itm->GetIsElementAnalysis() == false)
 		{
-			if (itm->CalculateSimilarity(xray) > 0.90)
+			auto sim = itm->CalculateSimilarity(xray);
+			if (sim > 0.90)
 			{
 				particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
 				particle->SetClassifyId(itm->GetID());

+ 5 - 3
OTSCPP/OTSClassifyEngine/ExpressionClassifyEngine.h

@@ -12,9 +12,6 @@ public:
 	virtual ~ExpressionClassifyEngine() {};
 	virtual bool Init() override;
 	
-
-
-
 	virtual bool IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime) override;
 	// Inherited via IClassifyEngine
 	virtual bool ClassifyBySpectrum(COTSParticlePtr particle, CPosXrayPtr xray) override;
@@ -29,6 +26,11 @@ private:
 	int GetAtomicNoBySortingPercentage(CString sortingNo, CPosXrayPtr xrayInfo);
 	CElementChemistriesList ZeroElementProcess(COTSParticlePtr particle, CPosXrayPtr xray);
 
+	void ProcessAllPropertiesWithParticleData(std::string& express, std::map<std::string, CElementChemistryPtr>& mapChemistrys, PartSTDRuleItemPtr itm, COTSParticlePtr particle);
+	void ProcessImgPropertiesWithParticleData(std::string& express, PartSTDRuleItemPtr itm, COTSParticlePtr particle);
+
+
+
 
 };
 

+ 5 - 1
OTSCPP/OTSClassifyEngine/PartSTDRuleItem.cpp

@@ -179,7 +179,11 @@ CElementsList PartSTDRuleItem::GetAllSortedEleList()
 }
 void PartSTDRuleItem::AddXraySpectrum(CPosXrayPtr xray)
 {
-	m_spectrums.push_back(xray);
+	if (m_spectrums.size() < 50)//only memory 50 spectrum for one item.
+	{
+		m_spectrums.push_back(xray);
+	}
+	
 }
 double PartSTDRuleItem::CalculateSimilarity(CPosXrayPtr xray)
 {

+ 2 - 2
OTSCPP/OTSClrInterface/ControlClr/OTSControlFunExport.cpp

@@ -273,14 +273,14 @@ namespace OTSCLRINTERFACE
 		{
 			xrays.push_back(parts[i]->GetXray()->GetPosXrayPtr());
 		}
-		auto bRet = m_pEDS->QuantifyXrayByParts(xrays);
+		auto bRet = m_pEDS->QuantifyXrays(xrays);
 		return bRet;
 	}
 
 	bool COTSControlFunExport::QuantifyXrayByPart(COTSParticleClr^ part)
 	{
 		auto xray = part->GetXray();
-		auto bRet = m_pEDS->QuantifyXrayByPart(xray->GetPosXrayPtr());
+		auto bRet = m_pEDS->QuantifyXray(xray->GetPosXrayPtr());
 		return bRet;
 	}
 	

+ 2 - 15
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.cpp

@@ -1579,20 +1579,7 @@ BOOL COTSBrukerImpl::QuantifyXrayPoint(CPosXray* a_pXRayPoint, CString a_strMeth
 	// ok, return true
 	return true;
 }
-//BOOL COTSBrukerImpl::QuantifyPosXrayPointsOnLine(std::vector<CPosXrayPtr>& a_vXRayParts)
-//{
-//
-//	
-//	if (!QuantifyPosXrayPointsOnLine(a_vXRayParts))
-//	{
-//		// failed to call ReadXRayPoints method
-//		LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPoints: failed to call ReadXRayPoints method."));
-//		return FALSE;
-//	}
-//
-//	// ok, return true
-//	return true;
-//}
+
 BOOL COTSBrukerImpl::QuantifyPosXrayPointOnLine(CPosXrayPtr a_vXRayPart)
 {
 	char* pcMethod = "Default";//"Default";//"Automatic";
@@ -2460,7 +2447,7 @@ BOOL COTSBrukerImpl::GetXRayByPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTi
 	return FALSE;
 }
 
-BOOL COTSBrukerImpl::QuantifyPosXrayPointsOnLine(CPosXrayList& a_listXrayPois/*, const DWORD a_nACTimeMS*/)
+BOOL COTSBrukerImpl::QuantifyPosXrayPointsOnLine(CPosXrayList& a_listXrayPois)
 {
 	// Fail a_vXPoints is empty
 	if (a_listXrayPois.empty())

+ 26 - 24
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.h

@@ -103,38 +103,25 @@ namespace OTSController {
 		float GetLiveTime(void);
 		BOOL GetLiveRealTime(float& a_dLiveTime, float& a_dRealTime);
 		
-		// collect spectrum data by timeB
+		// ---------collect spectrum data ,for testing
 		BOOL CollectSpectrum(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize);
-
-		// collect spectrum data by timeB and quantify
-		BOOL QuantifySpectrumOut(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistries);
-
-		// quantify spectrum
-		BOOL QuantifySpectrum(char* a_pcMethod, char* a_pcParams, char* a_pcResultBuffer, long a_nBufferSize);
-
-		// collect x-ray
-		
-		BOOL CollectXRayPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
-		BOOL CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS);
+		BOOL CollectOneXRayPoint(const CPoint& a_oPoi, DWORD a_nLifeTimeMilliSeconds, long* a_pnCounts, DWORD a_nBufferSize, bool a_bSetHeadStruc = FALSE);
+		//------------------
 	
 		
-		BOOL ReadXRayPoints(CPosXrayList& a_listXrayPois, const DWORD a_nACTimeMS);
-		BOOL ReadXRayPointsByFeature(std::vector<CPosXray*>& a_vXPoints, const DWORD a_nACTimeMS);
-		BOOL ReadXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
-
-		BOOL CollectOneXRayPoint(const CPoint& a_oPoi, DWORD a_nLifeTimeMilliSeconds, long* a_pnCounts, DWORD a_nBufferSize, bool a_bSetHeadStruc = FALSE);
 
-		// spectrum measurement 
-		BOOL StartSpectrumMeasurement();
-		BOOL IsSpectrumMeasureRunning(BOOL& a_bRunning);
 		BOOL StopSpectrumMeasure(void);
-		BOOL ReadSpectrum(long* a_pnCounts, DWORD a_nBufferSize);
+		
 
 		// get quantification method name
 		BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods);
 		BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, CString a_strMethodName);
 		BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, CString a_strMethodName, CElementChemistriesList& a_vElementChemistry);
+		// collect spectrum data by timeB and quantify
+		BOOL QuantifySpectrumOut(DWORD a_nMilliSeconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistries);
 
+		// quantify spectrum
+		BOOL QuantifySpectrum(char* a_pcMethod, char* a_pcParams, char* a_pcResultBuffer, long a_nBufferSize);
 
 	
 
@@ -146,12 +133,27 @@ namespace OTSController {
 		BOOL GetXRayByPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
 		
 		BOOL GetXRayByFeatures(CPosXrayList& a_vXPoints, std::vector<BrukerFeature> a_vFeatures, SHORT a_nACTimeMS);
-		BOOL SetXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
-		BOOL QuantifyPosXrayPointsOnLine(CPosXrayList& a_vXRayParts/*, const DWORD a_nACTimeMS*/);//delay quantifying 
+	
+		BOOL QuantifyPosXrayPointsOnLine(CPosXrayList& a_vXRayParts);//delay quantifying 
 		
 		BOOL QuantifyPosXrayPointOnLine(CPosXrayPtr a_vXRayPart);//delay quantifying 
 
-	protected:
+	private:
+		BOOL ReadSpectrum(long* a_pnCounts, DWORD a_nBufferSize);
+		BOOL CollectXRayPoints(CPosXrayList& a_listXrayPois, DWORD a_nACTimeMS);
+		BOOL CollectXRayPointsByFeatures(std::vector<CPosXray*>& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS);
+
+
+		BOOL ReadXRayPoints(CPosXrayList& a_listXrayPois, const DWORD a_nACTimeMS);
+		BOOL ReadXRayPointsByFeature(std::vector<CPosXray*>& a_vXPoints, const DWORD a_nACTimeMS);
+		BOOL ReadXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
+
+
+		// spectrum measurement 
+		BOOL StartSpectrumMeasurement();
+		BOOL IsSpectrumMeasureRunning(BOOL& a_bRunning);
+		BOOL SetXRayPointsByFeature(CPosXrayList& a_vXPoints, const DWORD a_nACTimeMS);
+		// collect x-ray
 		// close client
 		BOOL CloseClient(void);//there's no need to call from out ,the single instance destruction method will call it automatically.
 		

+ 2 - 2
OTSCPP/OTSControl/Bruker/OTSEDSBrucker.cpp

@@ -243,12 +243,12 @@ namespace OTSController {
 
 		return TRUE;
 	}
-	BOOL COTSEDSBrucker::QuantifyXrayByParts(std::vector<CPosXrayPtr>& a_vXRayParts)
+	BOOL COTSEDSBrucker::QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)
 	{
 		m_pBrukerImpl->QuantifyPosXrayPointsOnLine(a_vXRayParts);
 		return true;
 	}
-	BOOL COTSEDSBrucker::QuantifyXrayByPart(CPosXrayPtr& a_vXRayPart)
+	BOOL COTSEDSBrucker::QuantifyXray(CPosXrayPtr& a_vXRayPart)
 	{
 		m_pBrukerImpl->QuantifyPosXrayPointOnLine(a_vXRayPart);
 		return true;

+ 25 - 22
OTSCPP/OTSControl/Bruker/OTSEDSBrucker.h

@@ -21,50 +21,53 @@ namespace OTSController {
 		virtual BOOL Init() override;
 
 
-		// collect spectrum data
+		// ---------collect spectrum data, for testing only
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds) override;
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, const CPoint& a_oPoint) override;
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize) override;
-
+		//----------------
 	
-		// get live time
-		virtual float GetLiveTime(void) override;
-
-		// get x-ray point collection limit
-		virtual long GetMaxPointLimit(void) override { return (long)EDSConst::MAX_XRAY_BATCH; }
+		// ----------get xray data and do quatification interface
+		virtual void SetQuantification(BOOL a_bQuantification) override;
+		virtual BOOL GetQuantification() override;
 
-		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) override;
-		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) override;
-		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) override;
-		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) override;
-	
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)override;
-		virtual BOOL QuantifyXrayByParts(std::vector<CPosXrayPtr>& a_vXRayParts)override;
-		virtual BOOL QuantifyXrayByPart(CPosXrayPtr& a_vXRayPart)override;
+		
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
 			std::vector<BrukerFeature>& a_listFeatures,
 			const DWORD a_nXRayAQTime) override;
+		virtual BOOL QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)override;
+		virtual BOOL QuantifyXray(CPosXrayPtr& a_vXRayPart)override;
+		//-----------------------------
+
+
+
 		virtual BOOL COTSEDSBrucker::StopXrayAcquistion()override;
 	
-	
-		// Quatification
-		virtual void SetQuantification(BOOL a_bQuantification) override;
-		virtual BOOL GetQuantification() override;
-
 		// Get number of channels
 		virtual DWORD GetNumberOfChannels(void) override;
 
 		// Get the x-Ray data
 		virtual DWORD* GetXRayData() override;
-
+		// get live time
+		virtual float GetLiveTime(void) override;
+		// get x-ray point collection limit
+		virtual long GetMaxPointLimit(void) override { return (long)EDSConst::MAX_XRAY_BATCH; }
 		virtual void SetExpectCount(int expectcount) override;
+		// Inherited via COTSEDSBase
+		virtual int GetExpectCount() override;
 	private:
 
+
+		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) override;
+		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) override;
+		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) override;
+		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) override;
+
 		// bruker controller
 		std::shared_ptr<COTSBrukerImpl> m_pBrukerImpl;
 
-		// Inherited via COTSEDSBase
-		virtual int GetExpectCount() override;
+	
 	};
 
 } 

+ 17 - 15
OTSCPP/OTSControl/OTSEDSBase.h

@@ -34,19 +34,14 @@ namespace OTSController
 
 		
 		virtual BOOL Init() = 0;		
-
-
-
-		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) = 0;
-		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) = 0;
-		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) = 0;
-		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) = 0;
-
-		// collect spectrum data
-		// virtual
+		//-------- collect spectrum data,for testing
+	
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds) = 0;
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, const CPoint& a_oPoint) = 0;
 		virtual BOOL CollectSpectrum(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize) = 0;
+		//---------------
+
+
 		virtual BOOL StopXrayAcquistion() = 0;
 		// quantify spectrum
 
@@ -55,18 +50,18 @@ namespace OTSController
 		virtual DWORD* GetXRayData() = 0;
 
 
+		// get max points limit
 
+		virtual long GetMaxPointLimit(void) = 0;
 		// get live time
 		// virtual 
 		virtual float GetLiveTime(void) = 0;
 
-		// get max points limit
-		// virtual
-		virtual long GetMaxPointLimit(void) = 0;
+	
 
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime) = 0;
-		virtual BOOL QuantifyXrayByParts(std::vector<CPosXrayPtr>& a_vXRayParts)=0;//in our system ,one particle has one CPosXray object.
-		virtual BOOL QuantifyXrayByPart(CPosXrayPtr& a_vXRayPart)=0;
+		virtual BOOL QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)=0;//in our system ,one particle has one CPosXray object.
+		virtual BOOL QuantifyXray(CPosXrayPtr& a_vXRayPart)=0;
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
 			std::vector<BrukerFeature>& a_listFeatures,
 			const DWORD a_nXRayAQTime) = 0;
@@ -83,6 +78,13 @@ namespace OTSController
 		virtual int GetExpectCount() = 0;
 
 	protected:
+	
+		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) = 0;
+		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) = 0;
+		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) = 0;
+		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) = 0;
+
+	
 		// x-Ray data
 		DWORD m_nRayData[(long)EDSConst::XANA_CHANNELS];
 

+ 2 - 2
OTSCPP/OTSControl/Simulate/OTSEDSSim.cpp

@@ -506,7 +506,7 @@ namespace OTSController {
 		return TRUE;
 	}
 
-	BOOL COTSEDSSim::QuantifyXrayByParts(std::vector<CPosXrayPtr>& a_vXRayParts)
+	BOOL COTSEDSSim::QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)
 	{
 		return true;
 	}
@@ -522,7 +522,7 @@ namespace OTSController {
 	{
 		return m_nRayData;
 	}
-	 BOOL  COTSEDSSim::QuantifyXrayByPart(CPosXrayPtr& a_vXRayPart)
+	 BOOL  COTSEDSSim::QuantifyXray(CPosXrayPtr& a_vXRayPart)
 	{
 		 return true;
 	 }

+ 12 - 11
OTSCPP/OTSControl/Simulate/OTSEDSSim.h

@@ -36,16 +36,7 @@ namespace OTSController {
 		// get live time
 		virtual float GetLiveTime(void) override;
 
-		// get x-ray point collection limit
-		virtual long GetMaxPointLimit(void) override { return (long)EDSConst::MAX_XRAY_BATCH; }	
 
-		// quantification only works for bruker controller now
-		//virtual BOOL IsSupportQuantification() override;
-		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) override;
-		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) override;
-		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) override;
-		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) override;
-	
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)override;
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
 			std::vector<BrukerFeature>& a_vFeatures,
@@ -54,7 +45,7 @@ namespace OTSController {
 		// Quatification
 		virtual void SetQuantification(BOOL a_bQuantification) override;
 		virtual BOOL GetQuantification() override;
-		virtual BOOL QuantifyXrayByParts(std::vector<CPosXrayPtr>& a_vXRayParts)override;//in our system ,one particle has one CPosXray object.
+		virtual BOOL QuantifyXrays(std::vector<CPosXrayPtr>& a_vXRayParts)override;//in our system ,one particle has one CPosXray object.
 		virtual bool GetLiveRealTime(float& a_dLiveTime, float& a_dRealTime)
 		{
 			a_dLiveTime = GetLiveTime();
@@ -75,9 +66,19 @@ namespace OTSController {
 			return m_list_ampTime;
 		}
 		virtual void SetExpectCount(int expectcount) override;
-		virtual BOOL QuantifyXrayByPart(CPosXrayPtr& a_vXRayPart)override;
+		virtual BOOL QuantifyXray(CPosXrayPtr& a_vXRayPart)override;
 		virtual int GetExpectCount()override;
 	protected:
+		// get x-ray point collection limit
+		virtual long GetMaxPointLimit(void) override { return (long)EDSConst::MAX_XRAY_BATCH; }
+
+		// quantification only works for bruker controller now
+		//virtual BOOL IsSupportQuantification() override;
+		virtual BOOL GetQuantificationMethods(std::vector<CString>& a_vMethods) override;
+		virtual BOOL QuantifyXrayPoint(CPosXray* a_pXRayPoint, LPCTSTR a_sMethodName) override;
+		virtual BOOL QuantifySpectrumFile(LPCTSTR a_sFilePathName, LPCTSTR a_sMethodName, CElementChemistriesList& a_listElementChemistry) override;
+		virtual BOOL QuantifySpectrumOut(DWORD a_nMilliseconds, long* a_pCounts, DWORD a_nBufferSize, CElementChemistriesList& a_listElementChemistry) override;
+
 	  int	m_expectcount;
 	
 	};

+ 18 - 7
OTSIncAMeasureApp/1-OTSMeasure/Measure/2-OTSCleanliness/SmplMeasureCleanliness.cs

@@ -69,16 +69,28 @@ namespace OTSModelSharp
 
                 if (!IsLowCounts(pParticle))
                 {
-                    if (engine.ClassifyByExpressionTemporarySpectrum(pParticle))
+                    if (m_EDSController.GetIfDelayQuantify())
                     {
-                        if (pParticle.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
+
+                        if (engine.ClassifyByExpressionTemporarySpectrum(pParticle))
                         {
-                            quantifyNum += 1;
-                            m_EDSController.QuantifyXrayByPart(pParticle);
-                            engine.ClassifyByExpression(pParticle);
+                            if (pParticle.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
+                            {
+                                quantifyNum += 1;
+                                m_EDSController.QuantifyXrayByPart(pParticle);
+                                engine.ClassifyByExpression(pParticle);
+                            }
+
                         }
+                        int specComp = nSize - quantifyNum;
+                        log.Info("spectrum compare:" + specComp.ToString() + "element quantify:" + quantifyNum);
+                    }
+                    else 
+                    {
+                        engine.ClassifyByExpression(pParticle);
 
                     }
+                    
 
 
                 }
@@ -86,8 +98,7 @@ namespace OTSModelSharp
 
 
             }
-            int specComp = nSize -quantifyNum;
-            log.Info("spectrum compare:" + specComp.ToString() + "element quantify:" + quantifyNum);
+           
 
             return true;
         }

+ 14 - 25
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -941,25 +941,27 @@ namespace OTSModelSharp
        
         public virtual void CollectParticlesXrayData(COTSFieldData curFldData)
         {
+            List<COTSParticleClr> parts = new List<COTSParticleClr>();
+            foreach (var p in curFldData.GetListXrayParticles())
+            {
+                if (p.IsXrayParticle())
+                {
+                    parts.Add(p);
+                }
+            }
+
+            curFldData.CreateXrayList(parts);
             // get x-ray parameters
             COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
             var workmode = pXRayParam.GetScanMode();
+            log.Info("Begin to collect xraydata:"+parts.Count+" on "+workmode.ToString());
             if (workmode == OTS_X_RAY_SCAN_MODE.PointMode)
             {
               
                 uint nXRayAQTime;
-                List<COTSParticleClr> parts = new List<COTSParticleClr>();
+              
               
 
-                foreach (var p in curFldData.GetListXrayParticles())
-                {
-                    if (p.IsXrayParticle())
-                    {
-                       parts.Add(p);
-                    }
-                }
-               
-                curFldData.CreateXrayList(parts); 
 
                 if (parts.Count > 0)
                 {
@@ -976,24 +978,11 @@ namespace OTSModelSharp
               
                 uint nXRayAQTime;
                
-                List<COTSParticleClr> allparts = new List<COTSParticleClr>();
-
-                
-                foreach (var p in curFldData.GetListXrayParticles())
-                {
-                    if (p.IsXrayParticle())
-                    {
-                        allparts.Add(p);
-                    }
-                }
-
-                curFldData.CreateXrayList(allparts); 
-
-                if (allparts.Count > 0)
+                if (parts.Count > 0)
                 {
 
                         nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
-                        m_EDSController.GetXRayByFeatures(allparts, nXRayAQTime, true);
+                        m_EDSController.GetXRayByFeatures(parts, nXRayAQTime, true);
 
                 }
 

+ 12 - 5
OTSIncAMeasureApp/ServiceCenter/CPP(Bruker)API/EDSController.cs

@@ -16,14 +16,14 @@ namespace OTSModelSharp.ServiceCenter
         private COTSControlFunExport eds;
         static IEDSController edsctrl = null;
         private List<String> keyElenamelist = new List<string>();
-        static bool delayQuant;
+        private bool delayQuant=false;
 
-        //public bool DelayQuant { get => delayQuant; set => delayQuant = value; }
+       
 
         public static IEDSController GetEDSController(int imgwidth,int imgheight,int expectCount)
         {
             string deviceType = FileHelper.GetXMLInformations("EDSName");
-            delayQuant = Convert.ToBoolean(FileHelper.GetIfDelayQuantify());
+         
             if (edsctrl == null)
             {
                 if (deviceType == "FEI")
@@ -38,8 +38,10 @@ namespace OTSModelSharp.ServiceCenter
                 }
                 else if (deviceType == "Bruker")
                 {
-                    edsctrl = new EDSController("Bruker",expectCount);
-                    delayQuant = Convert.ToBoolean(FileHelper.GetIfDelayQuantify());
+                    var ctrl = new EDSController("Bruker",expectCount);
+                    var delayQuant = Convert.ToBoolean(FileHelper.GetIfDelayQuantify());
+                    ctrl.delayQuant = delayQuant;
+                    edsctrl = ctrl;
 
                 }
                 else if (deviceType == "OffLine")
@@ -367,5 +369,10 @@ namespace OTSModelSharp.ServiceCenter
         {
             return eds.GetExpectCount();
         }
+
+        public bool GetIfDelayQuantify()
+        {
+            return delayQuant;
+        }
     }
 }

+ 1 - 28
OTSIncAMeasureApp/ServiceCenter/CPP(Bruker)API/SemController.cs

@@ -104,34 +104,7 @@ namespace OTSModelSharp.ServiceCenter
           
         }
 
-        //public bool SetScanFieldSize100(double dScanFieldSizeX, double dScanFieldSizeY)
-        //{
-           
-        //    if (!hw.IsConnected())
-        //        {
-        //            return false;
-        //        }
-        //        Size size = new Size();
-        //        hw.SetSemScanField100(size);
-        //        dScanFieldSizeX = size.Width;
-        //        dScanFieldSizeY = size.Height;
-        //        return true;
-           
-        //}
-
-        //public bool GetScanFieldSize100(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
-        //{
-           
-        //        if (!hw.IsConnected())
-        //        {
-        //            return false;
-        //        }
-        //        Size size = hw.GetSemScanField100();
-        //        dScanFieldSizeX = size.Width;
-        //        dScanFieldSizeY = size.Height;
-        //        return true;
-           
-        //}
+      
 
         public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
         {

+ 6 - 7
OTSIncAMeasureApp/ServiceCenter/FEIAutoScript/FEIEDSController.cs

@@ -123,13 +123,7 @@ namespace OTSMeasureApp.ServiceCenter
 
             return ApiClass.Connect(FEIIP, FEIPORT);
         }
-        //private bool SetResolution(int ResolutionWidth, int ResolutionHeight)
-        //{
-            
-        //        strResolution = ResolutionWidth + "x" + ResolutionHeight;
-          
-        //    return true;
-        //}
+    
 
         private bool SetAnalyExpCount(int MaxCounts)
         {
@@ -169,5 +163,10 @@ namespace OTSMeasureApp.ServiceCenter
         {
             return AnalyExpCount;
         }
+
+        public bool GetIfDelayQuantify()
+        {
+            return false;
+        }
     }
 }

+ 1 - 3
OTSIncAMeasureApp/ServiceCenter/IMeasureHardware.cs

@@ -30,9 +30,6 @@ namespace OTSModelSharp.ServiceCenter
 
         bool SetScanExternal(bool b);
         bool GetScanFieldSize(ref double  dScanFieldSizeX,ref double  dScanFieldSizeY);
-        //bool SetScanFieldSize100(double dScanFieldSizeX,double dScanFieldSizeY);
-
-        //bool GetScanFieldSize100(ref double dScanFieldSizeX, ref double dScanFieldSizeY);
 
         bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR);
         bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double rotation);
@@ -72,5 +69,6 @@ namespace OTSModelSharp.ServiceCenter
         void SetFilterKeyEleNames(List<string> KeyNameList);
         void SetResolution(int resolutionWidth, int resolutionHeight);
         int GetExpectCount();
+        bool GetIfDelayQuantify();
     }
 }

+ 5 - 0
OTSIncAMeasureApp/ServiceCenter/OxfordExtender/OxfordEDSController.cs

@@ -187,5 +187,10 @@ namespace OTSMeasureApp.ServiceCenter
         {
             return AnalyExpCount;
         }
+
+        public bool GetIfDelayQuantify()
+        {
+            return false;
+        }
     }
 }

+ 2 - 2
OTSIncAMeasureApp/ServiceCenter/OxfordExtender/OxfordScanController.cs

@@ -23,7 +23,7 @@ namespace OTSMeasureApp.ServiceCenter
         ExtenderIpcUI iExtender;
         ImageInputSources imagesourceType;
 
-        //private APIClass ApiClass = null;
+     
         public OxfordScanController(ImageInputSources sourceType)
         {
   
@@ -66,7 +66,7 @@ namespace OTSMeasureApp.ServiceCenter
             imageWidth = nWidth;
             imageHeight = nHeight;
 
-            //return   iExtender.set.SetResolution(imageWidth, imageHeight); ;
+          
             return true;
         }
     }

+ 0 - 9
OTSIncAMeasureApp/ServiceCenter/OxfordExtender/OxfordSemController.cs

@@ -175,15 +175,6 @@ namespace OTSMeasureApp.ServiceCenter
             throw new NotImplementedException();
         }
 
-        public bool SetScanFieldSize100(double dScanFieldSizeX, double dScanFieldSizeY)
-        {
-            throw new NotImplementedException();
-        }
-
-        public bool GetScanFieldSize100(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
-        {
-            throw new NotImplementedException();
-        }
 
         public bool SetSemBeamCurrent(bool a_dKV)
         {