Explorar o código

improve the zeroelementprocess method. improve the brightness contrast regulate method. improve the IsInMeasureArea method of the filedmgr module.

GSP hai 1 mes
pai
achega
41b9c1d93f

+ 2 - 2
OTSCPP/OTSClassifyEngine/ExpressionClassifyEngine.cpp

@@ -1,4 +1,4 @@
-#pragma  once
+#pragma  once
 #include "stdafx.h"
 #include "ExpressionClassifyEngine.h"
 #include "ExpressionParseEngine/LogicExp.h"
@@ -534,7 +534,7 @@ CElementChemistriesList ExpressionClassifyEngine::ZeroElementProcess(COTSParticl
 			continue;
 		}
 	}
-	particle->GetXrayInfo()->SetElementQuantifyData(partEles);//set the particle's xray element quantify data to the new partEles.
+	//particle->GetXrayInfo()->SetElementQuantifyData(partEles);//set the particle's xray element quantify data to the new partEles.
 	return partEles;
 
 }

+ 1 - 1
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.cpp

@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
 #include "stdafx.h"
 #include "OTSBrukerImpl.h"
 #include "3Parties\dibapi.h"

+ 2 - 2
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.h

@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
 
 #include "OTSSingleton.h"
 
@@ -240,7 +240,7 @@ namespace OTSController {
 		int m_expectCount;
 		BOOL m_ifAutoId=TRUE;
 		CString m_knownElements;
-		const int XrayQuantityLimitPerTime = 256;
+		const int XrayQuantityLimitPerTime =256;
 
 	};
 

+ 94 - 94
OTSCPP/OTSImagePro/FieldMgr.cpp

@@ -1,4 +1,4 @@
-#include "stdafx.h"
+#include "stdafx.h"
 
 #include "otsdataconst.h"
 #include "FieldMgr.h"
@@ -420,38 +420,38 @@ namespace OTSIMGPROC {
 		}
 
 		// get measure field centre
-		CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
+		//CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
 
-		// move to left top postion.
-		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
+		//// move to left top postion.
+		//a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
 
-		// rectangle of the field
-		CRect rectFiled(a_poiField, a_sizeImageSize);
+		//// rectangle of the field
+		//CRect rectFiled(a_poiField, a_sizeImageSize);
 
 
-				// on the top left side, need to test the bottom right  corner
-				if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
-				{
-					return TRUE;
-				}
+		//		// on the top left side, need to test the bottom right  corner
+		//		if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
+		//		{
+		//			return TRUE;
+		//		}
 
-				// on the bottom left side, need to test the top right corner
-				if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
-				{
-					return TRUE;
-				}
+		//		// on the bottom left side, need to test the top right corner
+		//		if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
+		//		{
+		//			return TRUE;
+		//		}
 
-				// on the top left side, need to test the bottom right  corner
-				if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
-				{
-					return TRUE;
-				}
+		//		// on the top left side, need to test the bottom right  corner
+		//		if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
+		//		{
+		//			return TRUE;
+		//		}
 	
-				// on the bottom left side, need to test the top right corner
-				if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
-				{
-					return TRUE;
-				}
+		//		// on the bottom left side, need to test the top right corner
+		//		if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
+		//		{
+		//			return TRUE;
+		//		}
 	
 		// this field is not in the area at all, return FALSE.
 		return FALSE;
@@ -517,74 +517,74 @@ namespace OTSIMGPROC {
 			return TRUE;
 		}
 
-		// get measure field centre
-		CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
-
-		// move to left top postion.
-		a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
-
-		// rectangle of the field
-		CRect rectFiled(a_poiField, a_sizeImageSize);
-
-		// check field position
-		if (rectFiled.left <= poiMsrAreaCentre.x && rectFiled.right >= poiMsrAreaCentre.x)
-		{
-			// centre column field or centre field
-			return TRUE;
-		}
-		else if (rectFiled.top <= poiMsrAreaCentre.y && rectFiled.bottom >= poiMsrAreaCentre.y)
-		{
-			// centre row field?
-			return TRUE;
-		}
-		else if ( rectFiled.right <= poiMsrAreaCentre.x)
-		{
-			// on the left side		
-
-			//up
-			if (rectFiled.top >= poiMsrAreaCentre.y)
-			{
-				// on the top left side, need to test the bottom right  corner
-				if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.right, rectFiled.top)))
-				{
-					return TRUE;
-				}
-			}
-			else if(rectFiled.bottom <= poiMsrAreaCentre.y) //down//
-			{
-				// on the bottom left side, need to test the top right corner
-				if (m_pMeasureArea->PtInDomain(rectFiled.BottomRight()))
-				{
-					return TRUE;
-				}
-			}
-
-		}
-		else if(rectFiled.left >= poiMsrAreaCentre.x)
-		{
-			// on the right side
-
-			//up
-			if (rectFiled.top >= poiMsrAreaCentre.y)
-			{
-				// on the top left side, need to test the bottom right  corner
-				if (m_pMeasureArea->PtInDomain(rectFiled.TopLeft()))
-				{
-					return TRUE;
-				}
-			}
-			else if (rectFiled.bottom <= poiMsrAreaCentre.y) //down//
-			{
-				// on the bottom left side, need to test the top right corner
-				if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.left, rectFiled.bottom)))
-				{
-					return TRUE;
-				}
-			}
-
-		}
-
-		// this field is not in the area at all, return FALSE.
+		//// get measure field centre
+		//CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
+
+		//// move to left top postion.
+		//a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
+
+		//// rectangle of the field
+		//CRect rectFiled(a_poiField, a_sizeImageSize);
+
+		//// check field position
+		//if (rectFiled.left <= poiMsrAreaCentre.x && rectFiled.right >= poiMsrAreaCentre.x)
+		//{
+		//	// centre column field or centre field
+		//	return TRUE;
+		//}
+		//else if (rectFiled.top <= poiMsrAreaCentre.y && rectFiled.bottom >= poiMsrAreaCentre.y)
+		//{
+		//	// centre row field?
+		//	return TRUE;
+		//}
+		//else if ( rectFiled.right <= poiMsrAreaCentre.x)
+		//{
+		//	// on the left side		
+
+		//	//up
+		//	if (rectFiled.top >= poiMsrAreaCentre.y)
+		//	{
+		//		// on the top left side, need to test the bottom right  corner
+		//		if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.right, rectFiled.top)))
+		//		{
+		//			return TRUE;
+		//		}
+		//	}
+		//	else if(rectFiled.bottom <= poiMsrAreaCentre.y) //down//
+		//	{
+		//		// on the bottom left side, need to test the top right corner
+		//		if (m_pMeasureArea->PtInDomain(rectFiled.BottomRight()))
+		//		{
+		//			return TRUE;
+		//		}
+		//	}
+
+		//}
+		//else if(rectFiled.left >= poiMsrAreaCentre.x)
+		//{
+		//	// on the right side
+
+		//	//up
+		//	if (rectFiled.top >= poiMsrAreaCentre.y)
+		//	{
+		//		// on the top left side, need to test the bottom right  corner
+		//		if (m_pMeasureArea->PtInDomain(rectFiled.TopLeft()))
+		//		{
+		//			return TRUE;
+		//		}
+		//	}
+		//	else if (rectFiled.bottom <= poiMsrAreaCentre.y) //down//
+		//	{
+		//		// on the bottom left side, need to test the top right corner
+		//		if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.left, rectFiled.bottom)))
+		//		{
+		//			return TRUE;
+		//		}
+		//	}
+
+		//}
+
+		// this field is not in the area , return FALSE.
 		return FALSE;
 	}
 

+ 10 - 9
OTSIncAMeasureApp/0-OTSModel/OTSDataType/otsdataconst.cs

@@ -117,15 +117,16 @@ namespace OTSDataType
             _1024_684 = 1,
             _1024_704 = 2,
             _1024_768 = 3,
-            _1536_1024 = 4,
-            _2048_1408 = 5,           
-            _2048_1536 = 6,
-            _3072_2048 = 7,
-            _3072_2112 = 8,
-            _3072_2304 = 9,
-            _4096_2816 =10,
-            _4096_3072 = 11,
-            _1280_960 = 12
+            _768_512 = 4,
+            _1536_1024 = 5,
+            _2048_1408 = 6,           
+            _2048_1536 = 7,
+            _3072_2048 = 8,
+            _3072_2112 = 9,
+            _3072_2304 = 10,
+            _4096_2816 =11,
+            _4096_3072 = 12,
+            _1280_960 = 13
         }
         public static Size[] RESOLUTION_VALUE
         {

+ 38 - 30
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CBrightnessContrastAdjust.cs

@@ -253,47 +253,42 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
                 var desirebright = m_BrightnessContrastRegulateParam.brightphaseGrayvalue;
                 
                 SortedDictionary<double, SEMStateObject> BCstatedic =new SortedDictionary<double, SEMStateObject>();
-
-                while (Math.Abs( dark-desiredark)>3 || Math.Abs(bright-desirebright)>3)
+                bool finishcondition = Math.Abs(dark - desiredark) < 1 && Math.Abs(bright - desirebright) < 1;
+                while (!finishcondition)
                 {
                    
-                   
-                    double curbrightness = 0, curcontrast = 0; 
-                   
-                  
+                   //regulate
+                    double curbrightness = 0, curcontrast = 0;
+                    m_SemHardwareMgr.GetSemBrightness(ref curbrightness);
+                    m_SemHardwareMgr.GetSemContrast(ref curcontrast);
+                    RegulateBrightnessAndContrast(bright, desirebright, dark, desiredark,ref curbrightness,ref curcontrast);
+                    Thread.Sleep(200);
+
+                    //record the state
 
                     var error1 = desirebright - bright;
                     var error2 = desiredark - dark;
                     var varerror = Math.Pow(error1, 2) + Math.Pow(error2, 2);
                     SEMStateObject BcsemState = new SEMStateObject();
-                    m_SemHardwareMgr.GetSemBrightness(ref curbrightness);
-                    m_SemHardwareMgr.GetSemContrast(ref curcontrast);
+                    
                     BcsemState.brightness = curbrightness;
                     BcsemState.contrast = curcontrast;  
                     if(!BCstatedic.ContainsKey(varerror))
                     {
                         BCstatedic.Add(varerror, BcsemState);                       
-                    }   
-                    if((DateTime.Now-starttime).TotalSeconds>30)
+                    }
+                    //time out check
+                    if ((DateTime.Now-starttime).TotalSeconds>60)
                     {
                         log.Warn("Auto BC time out, stop the auto BC!");
 
-                        if (BCstatedic.Count > 0)
-                        {
-                            var minerror = BCstatedic.Keys.Min();
-                            var minstate = BCstatedic[minerror];
-                            m_SemHardwareMgr.SetSemBrightness(minstate.brightness);
-                            m_SemHardwareMgr.SetSemContrast(minstate.contrast);
-                            log.Warn("Auto BC set brightness and contrast to:" + minstate.brightness + " " + minstate.contrast);
-                        }
-                        return;
+                       break;
                     }
-                    RegulateBrightnessAndContrast(bright, desirebright, dark, desiredark,curbrightness,curcontrast);
-
-                    log.Info("two gray:" + bright.ToString() +" "+ dark.ToString());
-                    Thread.Sleep(500);
+                   
+                    
+                   
 
-                    // take BSE image for the fields
+                    // check bse image
                      pBSEIamge = m_ScanHardwareMgr.AcquireBSEImage();
 
                     if (pBSEIamge == null)
@@ -302,8 +297,18 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
                         return;
                     }
                     ProcessBSEImageToGetTheTwoGrayValue(pBSEIamge, ref bright, ref dark);
-                   
+                    log.Info("two gray:" + bright.ToString() + " " + dark.ToString());
+                    finishcondition = Math.Abs(dark - desiredark) < 1 && Math.Abs(bright - desirebright) < 1;
+                }
+                if (BCstatedic.Count > 0)
+                {
+                    var minerror = BCstatedic.Keys.Min();
+                    var minstate = BCstatedic[minerror];
+                    m_SemHardwareMgr.SetSemBrightness(minstate.brightness);
+                    m_SemHardwareMgr.SetSemContrast(minstate.contrast);
+                    log.Warn("Auto BC set brightness and contrast to:" + minstate.brightness + " " + minstate.contrast);
                 }
+
                 m_SemHardwareMgr.GetSemContrast(ref m_BrightnessContrastRegulateParam.initialContrast);
                 m_SemHardwareMgr.GetSemBrightness(ref m_BrightnessContrastRegulateParam.initialBrightness);
                 log.Warn("Auto BC done!");
@@ -337,23 +342,24 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
             m_SemHardwareMgr.SetSemContrast(contrast);
             m_SemHardwareMgr.SetSemBrightness(bright);
         }
-        void RegulateBrightnessAndContrast(double bri, double desirebri, double dark, double desiredark,double curbrightness,double curcontrast)
+        void RegulateBrightnessAndContrast(double bri, double desirebri, double dark, double desiredark,ref double curbrightness,ref double curcontrast)
         {
            
           
-            var adjustScope =6;//the scope that sem brightness and contrast can be adjusted
+            var adjustScope =3;//the scope that sem brightness and contrast can be adjusted
 
             var error1 = desirebri - bri;
             var error2 = desiredark - dark;
           
             var error = error1 + error2;
             double brightness = curbrightness + (error/255)* adjustScope;
+            double contrast=0;
             if (bri - dark > 10)
             {
                 double expectcontrast = (desirebri - desiredark) / desirebri;
                 double currentcontrast = (bri - dark) / bri;
                 double gain = (expectcontrast - currentcontrast) / expectcontrast * adjustScope;
-                double contrast = curcontrast + gain;
+                 contrast = curcontrast + gain;
                 m_SemHardwareMgr.SetSemContrast(contrast);
 
             }
@@ -362,18 +368,20 @@ namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
                 var everagegray=(bri+dark) / 2;
                 if (everagegray >= 125)
                 {
-                    double contrast = curcontrast - 0.5;
+                     contrast = curcontrast - 0.5;
                     m_SemHardwareMgr.SetSemContrast(contrast);
                 }
                 else 
                 {
-                    double contrast = curcontrast + 0.5;
+                     contrast = curcontrast + 0.5;
                     m_SemHardwareMgr.SetSemContrast(contrast);
                 }
             }
 
 
                 m_SemHardwareMgr.SetSemBrightness(brightness);
+            curcontrast = contrast;
+            curbrightness = brightness; 
         }
 
         bool InitAcquireBSEParam()

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

@@ -368,6 +368,7 @@ namespace OTSModelSharp
                 {
                     Thread.Sleep(hardWareDelay);
                     pSEMController.SetWorkingDistance(wd);
+                    log.Info("Set Working Distance to:" + wd.ToString("F2"));
                 }
 
               

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

@@ -72,7 +72,7 @@ namespace OTSModelSharp.ServiceCenter
             //process the repeat ele problem
             foreach (var ele in eleChemistry)
             {
-                if (eleInfoDic.ContainsKey(ele.GetName()))//contain repeat data;
+                if (eleInfoDic.ContainsKey(ele.GetName().Trim()))//contain repeat data;
                 {
                     eleInfoDic[ele.GetName()].Add(ele.GetPercentage());
                     //hasRepeatEle = true;

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

@@ -207,11 +207,11 @@ namespace OTSMeasureApp.ServiceCenter
 
                 p.dMilliSecondsTime = a_nXRayAQTime;
                 var feas = part.GetFeature().GetSegmentsList();
-              
+              //var rec=part.GetParticleRect();
                 foreach (var f in feas)
                 {
                     var len = f.GetLength();
-                    var start = f.GetStart() - len*2;
+                    var start = f.GetStart() - len*1;
                     if (start < 0)
                     {
                         start = 0;