Browse Source

optimize the CMeasureThreadWrapper.cs

gsp 1 year ago
parent
commit
bf21674264

+ 2 - 2
Bin/x64/Debug/Config/ProData/HardwareConfig.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <XMLData PathName="HardwareConfig.xml" ID="1">
-  <Member RegName="SemControllerName" Value="Bruker" ImageInputSources="BSE" />
-  <Member RegName="EDSName" Value="Bruker" DelayQuantify="false" />
+  <Member RegName="SemControllerName" Value="OffLine" ImageInputSources="BSE" />
+  <Member RegName="EDSName" Value="OffLine" DelayQuantify="false" />
   <Member RegName="BrukerDllVersion" Version="Bruker.API.Esprit64.dll" />
   <Member RegName="FEIIP" Value="192.168.0.1" />
   <Member RegName="FEIPORT" Value="7520" />

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

@@ -1251,21 +1251,7 @@ namespace OTSController {
 		m_bConnected = bConnected;
 		return m_bConnected;
 	}
-	//BOOL COTSBrukerImpl::OpenClient(char* a_sServerName, char* a_sUserName, char* a_sPassword, BYTE a_nStartNew, BYTE a_bGUI, uint32_t& a_nClientID)
-	//{
-	//
-
-	//	// open client
-	//	int32_t bRet = BrukerDll::OpenClient(a_sServerName, a_sUserName, a_sPassword, a_nStartNew, a_bGUI, a_nClientID);
-	//	if (bRet!=0)
-	//	{
-	//		
-	//			LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::OpenClient: failed to open client dll."));
-	//			return false;
-	//	}
-
-	//	return true;
-	//}
+	
 
 	// check detector states and set m_nSPU                    // Bruker四个有一个盒子,盒子共接4个探头
 	BOOL COTSBrukerImpl::SetSPU(void)

+ 25 - 15
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSXRayParam.cs

@@ -19,8 +19,10 @@ namespace OTSDataType
     
         // x-ray speed analysis
         const int DEFAULE_XRAY_ANALY_MID_TIME = 1000;
+        const double DEFAULE_XRAY_QUANTIFY_MINSIZE = 50;
+
+        const int DEFAULE_FASTXRAYTIME = 100;
 
-   
         const int Default_Xray_Limit = 50;
         private OTS_X_RAY_SCAN_MODE m_nScanMode;
 
@@ -32,7 +34,8 @@ namespace OTSDataType
 
         private bool m_nUsingXray;
         private bool m_UseFilter;
-
+        private double m_nQutantifyMinSize;
+        private int m_nFastXrayTime;
         private int m_XrayLimit;
 
         void Init()
@@ -43,7 +46,8 @@ namespace OTSDataType
             m_nAnalyLowestCount = DEFAULE_XRAY_LOW_COUNT;
 
             m_nMidAnalyAQTime = DEFAULE_XRAY_ANALY_MID_TIME;
-
+            m_nQutantifyMinSize = DEFAULE_XRAY_QUANTIFY_MINSIZE;
+            m_nFastXrayTime = DEFAULE_FASTXRAYTIME;
             m_XrayLimit = Default_Xray_Limit;
          
         }
@@ -98,7 +102,16 @@ namespace OTSDataType
 
         public int GetAnalyExpCount() { return m_nAnalyLowestCount; }
         public void SetAnalyExpCount(int a_nVal) { m_nAnalyLowestCount = a_nVal; }
-
+        public double GetFeatureModeMinSize() { return m_nQutantifyMinSize; }
+        public void SetQuantifyMinSize(double a_nQuantifyMinSize)
+        {
+            m_nQutantifyMinSize = a_nQuantifyMinSize;
+        }
+        public int GetFastXrayTime() { return m_nFastXrayTime; }
+        public void SetFastXrayTime(int a_nFastXrayTime)
+        {
+            m_nFastXrayTime = a_nFastXrayTime;
+        }
 
         public int GetMidAnalyAQTime() { return m_nMidAnalyAQTime; }
         public void SetMidAnalyAQTime(int a_nMidAnalyAQTime) { m_nMidAnalyAQTime = a_nMidAnalyAQTime; }
@@ -140,8 +153,7 @@ namespace OTSDataType
             xBool xnUseFilter = new xBool();
 
             xInt xXrayLimit = new xInt();
-            //xDouble xXrayStep = new xDouble();
-            //xBool xZeroElementProcess = new xBool();
+           
 
             Slo slo = new Slo();
 
@@ -161,9 +173,7 @@ namespace OTSDataType
 
             slo.Register("XrayLimit", xXrayLimit);
 
-            //slo.Register("XrayStep", xXrayStep);
-
-            //slo.Register("ZeroElementProcess", xZeroElementProcess);
+          
 
 
             if (isStoring)
@@ -174,16 +184,16 @@ namespace OTSDataType
             
                 xnMidAnalyAQTime.AssignValue(m_nMidAnalyAQTime);
 
-                //xSmallPartAQTime.AssignValue(m_nFastXrayTime);
+                xSmallPartAQTime.AssignValue(m_nFastXrayTime);
 
-                //xQuantifyMinSize.AssignValue(m_nQutantifyMinSize);
+                xQuantifyMinSize.AssignValue(m_nQutantifyMinSize);
 
                 xnUsingXray.AssignValue(m_nUsingXray);
 
                 xnUseFilter.AssignValue(m_UseFilter);
 
                 xXrayLimit.AssignValue(m_XrayLimit);
-                //xXrayStep.AssignValue(m_xrayStep);
+            
 
                 slo.Serialize(true, classDoc, rootNode);
             }
@@ -197,16 +207,16 @@ namespace OTSDataType
              
                 m_nMidAnalyAQTime = xnMidAnalyAQTime.value();
 
-                //m_nFastXrayTime = xSmallPartAQTime.value();
+                m_nFastXrayTime = xSmallPartAQTime.value();
 
-                //m_nQutantifyMinSize = xQuantifyMinSize.value();
+                m_nQutantifyMinSize = xQuantifyMinSize.value();
 
                 m_nUsingXray = xnUsingXray.value();
 
                 m_UseFilter = xnUseFilter.value();
 
                 m_XrayLimit = xXrayLimit.value();
-                //m_xrayStep = xXrayStep.value();
+              
             }
         }
     }

+ 2 - 10
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CFieldPositionMgr.cs

@@ -67,15 +67,7 @@ namespace OTSModelSharp
            
             fieldmgrclr.Init(domainclr.GetClrDomainObj(), sizePixelImage,scanfieldsize, (int)m_poImageScanParam.GetFieldStartMode());
             fieldmgrclr.SetOverlap(a_poImageProcParam.GetOverlapParam());
-            //List<Point> fieldpoints = new List<Point>();
-            //for (int i = 0; i < a_listMeasuredFieldCentrePoints.Count; i++)
-            //{
-            //    var p = a_listMeasuredFieldCentrePoints[i];
-            //    fieldpoints.Add(new Point((int)p.X, (int)p.Y));
-            //}
-
-            //m_listUnmeasuredFieldCentrePoints = fieldmgrclr.GetUnmeasuredFieldCentrePoints(fieldpoints);
-
+ 
             List<System.Drawing.Point> fieldpoints = new List<System.Drawing.Point>();
             for(int i=0;i<a_listMeasuredFieldCentrePoints.Count;i++)
             {
@@ -88,7 +80,7 @@ namespace OTSModelSharp
                 var p = sortedlistUnmeasuredFieldCentrePoints[i];
                 m_listUnmeasuredFieldCentrePoints.Add(p);
             }
-            //m_listUnmeasuredFieldCentrePoints = fieldmgrclr.GetUnmeasuredFieldCentrePoints(fieldpoints).ToList;
+           
             m_listFieldCentrePoints = fieldmgrclr.GetFieldCentrePoints();
 
             return true;

+ 59 - 173
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasure.cs

@@ -7,100 +7,15 @@ using static OTSDataType.otsdataconst;
 using OTSModelSharp.ImageProcess;
 using OTSModelSharp.ServiceCenter;
 using System.Threading;
+using OTSCLRINTERFACE;
+using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
 
 namespace OTSModelSharp
 {
 
 
     // enum and struct used for send message to App
-    public enum ENUM_MSG_TYPE
-    {
-        MTHREADSTATUS = 1001,
-        MSAMPLESTATUS = 1002,
-        MSAMPLERESULT = 1003
-    };
-
-
-    public enum MSAMPLE_RET
-    {
-        BSE_DATA = 0,
-        FIELD_DATA = 1,
-        START_MSR_FIELD = 2
-
-    };
-
-    public struct SMSR_COMPLETE_DATA
-    {
-        public OTS_MSR_THREAD_STATUS MsrStatus;
-        public string csMsrStartTime;
-        public int iMsrCompleteSampleCount;
-        public int iMsrCompleteFieldCount;
-        public int iParticleCount;
-        public TimeSpan MsrUsedTime;
-        public string csMsrEndTime;
-    };
-
-
-
-    public struct STMThreadStatus
-    {
-        public OTS_MSR_THREAD_STATUS iMsrStatu;        //OTS_MSR_THREAD_STATUS
-        public string csMsrStartTime;   //MSR_START_TIME
-        public string csMsrEndTime;     //MSR_END_TIME
-        public SMSR_COMPLETE_DATA SMsrCompleteData;
-    };
-    public struct STMSampleStatus
-    {
-        public OTS_MSR_SAMPLE_STATUS iMsrSampleStatu;    //OTS_MSR_SAMPLE_STATUS
-        public string cSampleName;
-        public string csSampleMsrStartTime;
-        public List<PointF> BCompleteFieldList;
-    };
-
-
-    public struct STMSampleResultData
-    {
-        public MSAMPLE_RET iRetDataType;                 //ENUM_MEASURE_SAMPLE_RESULT
-
-        public struct RBSEDATA
-        {
-            public int fieldId;
-            public System.Drawing.Point pos;
-            public int iBSEDataHeight;
-            public int iBSEDataWidth;
-            public byte[] lpBSEData;
-        };
-
-        public struct SAMPLEFIELDDATA
-        {
-            public System.Drawing.Point FieldPos;
-            public int iMeasureFieldCount;
-            public int iCompleteFieldCount;
-            public int iSParticleCount;     // Field particle count
-            public TimeSpan TUsedTime;
-        };
-
-        public struct StartToMsrField
-        {
-            public System.Drawing.Point FieldPos;
-        };
-
-        public RBSEDATA BSEData;
-        public SAMPLEFIELDDATA SFieldData;
-        public StartToMsrField SMsrField;
-    };
-
-    public  struct ST_MSTMsg
-    {
-
-    
-      public ENUM_MSG_TYPE iMsgType;
-      public   STMThreadStatus STMThreadStu;
-      public   STMSampleStatus STMSampleStu;
-      public   STMSampleResultData STMSampleRetData;
-
-
-    };
+  
     
     public class CMeasure
     {
@@ -108,6 +23,9 @@ namespace OTSModelSharp
         private const string UNTITLED_FILE_NAME = "Untitled";
         public delegate void   ProgressEventHandler(ST_MSTMsg msg);
         public event ProgressEventHandler ProgressEvent;
+
+        public event ProgressEventHandler HolePreviewEvent;
+
         COTSMsrPrjResultData m_pProjData;
         List< COTSSample> m_listMeasurableSamples=new List<COTSSample>();
         string m_strWorkingFolder;
@@ -160,22 +78,14 @@ namespace OTSModelSharp
         void ThreadOver()
         {
           
+            ST_MSTMsg MsrMsg = new ST_MSTMsg(m_ThreadStatus);
+           
 
-            DateTime timeEnd = m_ThreadStatus.GetEndTime();
-
-            ST_MSTMsg MsrMsg = new ST_MSTMsg
-            {
-                iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS
-            };
-
-            MsrMsg.STMThreadStu.iMsrStatu = m_ThreadStatus.GetStatus();
-
-
-        
-            MsrMsg.STMThreadStu.csMsrEndTime = timeEnd.ToString("yyyy-MM-dd HH:mm:ss");
-            ProgressEvent(MsrMsg);
+            MsrMsg.InitThreadOverMsg();
+           
+            SendMessageToMeasureGUI(MsrMsg);
 
-            if (MsrMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.FAILED || MsrMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.COMPLETED)
+            if (m_ThreadStatus.GetStatus() == otsdataconst.OTS_MSR_THREAD_STATUS.FAILED || m_ThreadStatus.GetStatus() == otsdataconst.OTS_MSR_THREAD_STATUS.COMPLETED)
             {
 
                 if (m_pProjData.GetGenParam().AutoBeamOff)
@@ -184,21 +94,16 @@ namespace OTSModelSharp
                 }
             }
         }
-        void ThreadOverWithoutDisConnect()
+        void HolePreviewThreadOver()
         {
 
 
-            DateTime timeEnd = m_ThreadStatus.GetEndTime();
+            ST_MSTMsg MsrMsg = new ST_MSTMsg(m_ThreadStatus);
 
-            ST_MSTMsg MsrMsg = new ST_MSTMsg();
-            MsrMsg.iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
+            MsrMsg.InitThreadOverMsg();
 
-            MsrMsg.STMThreadStu.iMsrStatu = m_ThreadStatus.GetStatus();
+            SendHolePreviewMessageToMeasureGUI(MsrMsg);
 
-          
-            MsrMsg.STMThreadStu.csMsrEndTime = timeEnd.ToString("yyyy-MM-dd HH:mm:ss");
-            ProgressEvent(MsrMsg);
-        
         }
         void SetWorkingFolderStrAndSaveCurrentSettings()
         {
@@ -223,10 +128,14 @@ namespace OTSModelSharp
             m_pProjData.Save();
             return ;
         }
-       public void SendMessageToMeasureApp(ST_MSTMsg msg)
+       public void SendMessageToMeasureGUI(ST_MSTMsg msg)
         {
             ProgressEvent(msg);
         }
+        public void SendHolePreviewMessageToMeasureGUI(ST_MSTMsg msg)
+        {
+            HolePreviewEvent(msg);
+        }
         public bool IsMeasureStopped()
         {
             return m_ThreadStatus.GetStatus() == OTS_MSR_THREAD_STATUS.STOPPED;
@@ -239,16 +148,12 @@ namespace OTSModelSharp
         {
             // start measurement, creat thread measure status class, let the main thread know that measurement started
             m_ThreadStatus.SetStartTime(System.DateTime.Now);
-            DateTime timeStart = m_ThreadStatus.GetStartTime();
 
-            ST_MSTMsg MsgMsrStart = new ST_MSTMsg
-            {
-                iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS
-            };
-            MsgMsrStart.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
-            MsgMsrStart.STMThreadStu.csMsrStartTime = timeStart.ToShortDateString();
 
-            ProgressEvent (MsgMsrStart);
+            ST_MSTMsg MsgMsrStart = new ST_MSTMsg(m_ThreadStatus);
+            MsgMsrStart.InitThreadStartMsg();
+            SendMessageToMeasureGUI (MsgMsrStart);
+
             loger.Info("Measurement started!");
             // connect hardware
             loger.Info("Connect SEM!");
@@ -342,9 +247,6 @@ namespace OTSModelSharp
                
                 pSmplMeasure.DoMeasureForOneSample();
 
-
-           
-
                 // check if measurement is successful
                 if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
                 {// record end time
@@ -352,13 +254,9 @@ namespace OTSModelSharp
                     m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
                     // update thread measure status class, let the main thread know that this sample measurement stopped
-                    ST_MSTMsg MsgSmpStop = new ST_MSTMsg();
-                    MsgSmpStop.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                    MsgSmpStop.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
-                    MsgSmpStop.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
-                    MsgSmpStop.STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
-                    MsgSmpStop.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
-                    ProgressEvent(MsgSmpStop);
+                    ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_ThreadStatus);
+                    MsgSmpStop.InitThreadPausedMsg();
+                    SendMessageToMeasureGUI(MsgSmpStop);
 
 
                     ThreadOver();
@@ -369,13 +267,10 @@ namespace OTSModelSharp
                     m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
                     // update thread measure status class, let the main thread know that this sample measurement stopped
-                    ST_MSTMsg MsgSmpStop = new ST_MSTMsg(); 
-                    MsgSmpStop.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                    MsgSmpStop.STMThreadStu.iMsrStatu= OTS_MSR_THREAD_STATUS.STOPPED;
-                    MsgSmpStop.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
-                    MsgSmpStop.STMThreadStu.csMsrEndTime = DateTime .Now .ToShortDateString();
-                    MsgSmpStop.STMThreadStu.iMsrStatu= OTS_MSR_THREAD_STATUS.STOPPED;
-                    ProgressEvent(MsgSmpStop);
+                    ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_ThreadStatus);
+                    MsgSmpStop.InitThreadStoppedMsg();
+                    
+                    SendMessageToMeasureGUI(MsgSmpStop);
 
 
                     ThreadOver();
@@ -389,23 +284,20 @@ namespace OTSModelSharp
                     m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
                 // update thread measure status class, let the main thread know that this sample measurement failed
-                ST_MSTMsg MsgSmpFailed=new ST_MSTMsg(); 
-              
-                MsgSmpFailed.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-				MsgSmpFailed.STMSampleStu.iMsrSampleStatu =  OTS_MSR_SAMPLE_STATUS.FAILED;                 
-
+                ST_MSTMsg MsgSmpFailed=new ST_MSTMsg(m_ThreadStatus);
+                    MsgSmpFailed.InitThreadFailedMsg();
                    
-                 ProgressEvent(MsgSmpFailed);
+                 SendMessageToMeasureGUI(MsgSmpFailed);
                 ThreadOver();
 				  return;
 			    }
 
               
                 // update thread measure status class, let the main thread know that this sample measurement successes
-                ST_MSTMsg MsgSmpSuccess = new ST_MSTMsg();
-                MsgSmpSuccess.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                MsgSmpSuccess.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
-                ProgressEvent(MsgSmpSuccess);
+                ST_MSTMsg MsgSmpSuccess = new ST_MSTMsg(m_ThreadStatus);
+                MsgSmpSuccess.InitThreadSucceedMsg();
+
+                SendMessageToMeasureGUI(MsgSmpSuccess);
 
 
                 // continue to the next sample
@@ -434,12 +326,11 @@ namespace OTSModelSharp
 
   
 
-            ST_MSTMsg MsgMsrStart = new ST_MSTMsg();
-          
-            MsgMsrStart.iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
-            MsgMsrStart.STMThreadStu.iMsrStatu =OTS_MSR_THREAD_STATUS.INPROCESS;
+            ST_MSTMsg MsgMsrStart = new ST_MSTMsg(m_ThreadStatus);
+            MsgMsrStart.InitHolePreThreadInProcessMsg();
+            
          
-            SendMessageToMeasureApp(MsgMsrStart);
+            SendHolePreviewMessageToMeasureGUI(MsgMsrStart);
             // connect hardware
             if (!m_SemController.Connect())
             {
@@ -447,7 +338,7 @@ namespace OTSModelSharp
                 
                 SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.FAILED);
                 m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
-                ThreadOverWithoutDisConnect();
+                HolePreviewThreadOver();
             }
 
 
@@ -480,14 +371,13 @@ namespace OTSModelSharp
                 SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
 
                 // update thread measure status class, let the main thread know that this sample measurement stopped
-                ST_MSTMsg MsgSmpStop = new ST_MSTMsg();
-           
-                MsgSmpStop.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                MsgSmpStop.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
+                ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_ThreadStatus);
+                MsgSmpStop.InitHolePreThreadStoppedMsg();
+              
           
-                SendMessageToMeasureApp(MsgSmpStop);
+                SendHolePreviewMessageToMeasureGUI(MsgSmpStop);
 
-                ThreadOverWithoutDisConnect();
+                HolePreviewThreadOver();
                 return;
             }
             else if (pSampleHole.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.FAILED)
@@ -498,13 +388,11 @@ namespace OTSModelSharp
                 m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
                 // update thread measure status class, let the main thread know that this sample measurement failed
-                ST_MSTMsg MsgSmpFailed = new ST_MSTMsg();
-          
-                MsgSmpFailed.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                MsgSmpFailed.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
-           
-                SendMessageToMeasureApp(MsgSmpFailed);
-                ThreadOverWithoutDisConnect();
+                ST_MSTMsg MsgSmpFailed = new ST_MSTMsg(m_ThreadStatus);
+                MsgSmpFailed.InitHolePreThreadFailedMsg();
+             
+                SendHolePreviewMessageToMeasureGUI(MsgSmpFailed);
+                HolePreviewThreadOver();
                 return;
             }
 
@@ -512,21 +400,19 @@ namespace OTSModelSharp
             m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
             // update thread measure status class, let the main thread know that this sample measurement successes
-            ST_MSTMsg MsgSmpSuccess = new ST_MSTMsg();
-         
-            MsgSmpSuccess.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-            MsgSmpSuccess.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
-         
+            ST_MSTMsg MsgSmpSuccess = new ST_MSTMsg(m_ThreadStatus);
+            MsgSmpSuccess.InitHolePreThreadSucceedMsg();
+      
 
 
-            SendMessageToMeasureApp(MsgSmpSuccess);
+            SendHolePreviewMessageToMeasureGUI(MsgSmpSuccess);
 
             // measurement completed
             SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.COMPLETED);
             // record end time
             m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
-            ThreadOverWithoutDisConnect();
+            HolePreviewThreadOver();
         }
 
       public  COTSSample CreateHoleSample(CDomain a_pMsrArea)

+ 123 - 73
OTSIncAMeasureApp/1-OTSMeasure/CMeasureThreadWrapper.cs → OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasureThreadWrapper.cs

@@ -5,6 +5,7 @@ using OTSDataType;
 using System.Collections.Generic;
 using static OTSDataType.otsdataconst;
 using System.Drawing;
+using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
 
 namespace OTSMeasureApp
 {
@@ -56,9 +57,89 @@ namespace OTSMeasureApp
 
             m_measure = new CMeasure();
             m_measure.ProgressEvent += M_MsrThread_ProgressEvent;
-         
+            m_measure.HolePreviewEvent += M_measure_HolePreviewEvent;
 
         }
+        private void M_MsrThread_ProgressEvent(ST_MSTMsg MSTMsg)
+        {
+            ExecuteMeasureMsg(MSTMsg);
+        }
+        private void M_measure_HolePreviewEvent(ST_MSTMsg msg)
+        {
+            ExecuteHolePreviewMsg(msg);
+        }
+
+        private void ExecuteHolePreviewMsg(ST_MSTMsg MSTMsg)
+        {
+           
+
+            switch (MSTMsg.iMsgType)
+            {
+                case ENUM_MSG_TYPE.MTHREADSTATUS:
+                    if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS)
+                    {
+                        m_MeasureApp.SetStartMeasureRibbonStatus();
+                       
+                    }
+                    else if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED)
+                    {
+                        m_MeasureApp.SetStopMeasureRibbonStatus();
+                      
+
+                    }
+                    else if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.FAILED)
+                    {
+                        m_MeasureApp.SetStopMeasureRibbonStatus();
+                     
+
+
+                    }
+                    else if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.COMPLETED)
+                    {
+                        m_MeasureApp.SetStopMeasureRibbonStatus();
+                      
+
+                    }
+                    
+                   
+                    break;
+
+                case ENUM_MSG_TYPE.MSAMPLESTATUS:
+                    
+                    break;
+                case ENUM_MSG_TYPE.MSAMPLERESULT:
+                    if (MSTMsg.STMSampleRetData.iRetDataType == MSAMPLE_RET.BSE_DATA)
+                    {
+                        int iHeight = MSTMsg.STMSampleRetData.BSEData.iBSEDataHeight;
+                        int iWidth = MSTMsg.STMSampleRetData.BSEData.iBSEDataWidth;
+
+                        if (iHeight > 0 && iWidth > 0)
+                        {
+
+                            //获取显示BSE的图片数据
+                            byte[] ImageData = MSTMsg.STMSampleRetData.BSEData.lpBSEData;
+                            //图片宽度
+                            int width = MSTMsg.STMSampleRetData.BSEData.iBSEDataWidth;
+                            //图片高度
+                            int height = MSTMsg.STMSampleRetData.BSEData.iBSEDataHeight;
+                            //Field位置
+                            Point fieldPos = MSTMsg.STMSampleRetData.BSEData.pos;
+                            int fieldid = MSTMsg.STMSampleRetData.BSEData.fieldId;
+                            //设置样品孔中BSE图像信息
+                            m_MeasureApp.m_SamplepaceWindow.AddHoleBSEImageData(ImageData, width, height, fieldPos, fieldid);
+
+                        }
+                        else
+                        {
+                            log.Error("(OTSGetMreRetThread) BSEDataHeight = " + iHeight.ToString() + "BSEDataWidth = " + iWidth.ToString() + " Failed");
+                        }
+                    }
+                   
+                    break;
+
+            }
+        }
+
         public bool IsHavingNotCompleteSamples()
         {
             foreach(var s in m_measure.GetListMeasurableSamples())
@@ -106,10 +187,7 @@ namespace OTSMeasureApp
                 return true;
 
             }
-            //if (m_bgWorker.IsBusy)
-            //{
-            //    return true;
-            //}
+           
             return false;
         }
         public bool BgWorkIsPaused()
@@ -169,7 +247,7 @@ namespace OTSMeasureApp
                 InitMeasureThread(m_MeasureApp.m_ProjData);
 
                 SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS);
-                DoHolePreview( );
+                m_measure.DoHolePreview();
             }
         }
 
@@ -184,26 +262,23 @@ namespace OTSMeasureApp
 
         }
 
-        private void M_MsrThread_ProgressEvent(OTSModelSharp.ST_MSTMsg msg)
-        {
-           AddMeasureMsg(msg);
-        }
-        private void AddMeasureMsg(OTSModelSharp.ST_MSTMsg MSTMsg)
+      
+        private void ExecuteMeasureMsg(ST_MSTMsg MSTMsg)
         {
           
             ShowCurrentFieldPointMessage(MSTMsg.STMSampleRetData.SMsrField.FieldPos);
           
             switch (MSTMsg.iMsgType)
             {
-                case OTSModelSharp.ENUM_MSG_TYPE.MTHREADSTATUS:
+                case ENUM_MSG_TYPE.MTHREADSTATUS:
                     if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS)
                     {
-
-                        StartMeasure(MSTMsg);
+                        m_MeasureApp.SetStartMeasureRibbonStatus();
+                        //StartMeasure(MSTMsg);
                     }
                     else if (MSTMsg.STMThreadStu.iMsrStatu == otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED)
                     {
-                        string csETime = MSTMsg.STMThreadStu.csMsrEndTime;
+                      
                         StopMeasure(MSTMsg);
 
                     }
@@ -233,7 +308,7 @@ namespace OTSMeasureApp
                     }
                     break;
 
-                case OTSModelSharp.ENUM_MSG_TYPE.MSAMPLESTATUS:
+                case ENUM_MSG_TYPE.MSAMPLESTATUS:
                     if (MSTMsg.STMSampleStu.iMsrSampleStatu == OTSDataType.OTS_MSR_SAMPLE_STATUS.INPROCESS)   // 开始测量样品
                     {
                         string csName = MSTMsg.STMSampleStu.cSampleName;
@@ -248,7 +323,7 @@ namespace OTSMeasureApp
                     }
                     else if (MSTMsg.STMSampleStu.iMsrSampleStatu == OTSDataType.OTS_MSR_SAMPLE_STATUS.FAILED)
                     {
-                        //StopMeasure(MSTMsg);
+                        StopMeasure(MSTMsg);
                         log.Error("(OTSGetMreRetThread) MSTMsg.STMSampleStu.iMeasureSampleStatus = RET_MEASURE_SAMPLE_STATUS.FAILED Failed");
 
                     }
@@ -262,8 +337,8 @@ namespace OTSMeasureApp
                         log.Warn("This sample measure is paused!");
                     }
                     break;
-                case OTSModelSharp.ENUM_MSG_TYPE.MSAMPLERESULT:
-                    if (MSTMsg.STMSampleRetData.iRetDataType == OTSModelSharp.MSAMPLE_RET.BSE_DATA)
+                case ENUM_MSG_TYPE.MSAMPLERESULT:
+                    if (MSTMsg.STMSampleRetData.iRetDataType ==MSAMPLE_RET.BSE_DATA)
                     {
                         int iHeight = MSTMsg.STMSampleRetData.BSEData.iBSEDataHeight;
                         int iWidth = MSTMsg.STMSampleRetData.BSEData.iBSEDataWidth;
@@ -271,22 +346,26 @@ namespace OTSMeasureApp
                         if (iHeight > 0 && iWidth > 0)
                         {
 
-                            GetBSEData(MSTMsg);
-
+                            //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(MSTMsg);
+                            m_OTSMeasureResult.Field_BSE_DATA(MSTMsg);
                         }
                         else
                         {
                             log.Error("(OTSGetMreRetThread) BSEDataHeight = " + iHeight.ToString() + "BSEDataWidth = " + iWidth.ToString() + " Failed");
                         }
                     }
-                    else if (MSTMsg.STMSampleRetData.iRetDataType == OTSModelSharp.MSAMPLE_RET.FIELD_DATA)
+                    else if (MSTMsg.STMSampleRetData.iRetDataType == MSAMPLE_RET.FIELD_DATA)
                     {
-                        UpdateMeasureState(MSTMsg);
+                        this.GetSMsrUsedTime(ref MSTMsg.STMSampleRetData.SFieldData.TUsedTime);
+
+                        //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(MSTMsg);
+                        m_OTSMeasureResult.Field_DATA(MSTMsg);
                     }
 
-                    else if (MSTMsg.STMSampleRetData.iRetDataType == OTSModelSharp.MSAMPLE_RET.START_MSR_FIELD)
+                    else if (MSTMsg.STMSampleRetData.iRetDataType == MSAMPLE_RET.START_MSR_FIELD)
                     {
-                        GetStartMsrField(MSTMsg);
+                        //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(MSTMsg);
+                        m_OTSMeasureResult.Field_START_MSR(MSTMsg);
                     }
                     else
                     {
@@ -297,15 +376,15 @@ namespace OTSMeasureApp
             }
         }
         #region privte part
-        private void StartMeasure(ST_MSTMsg SMsrData)
-        {
-            m_MeasureApp.SetStartMeasureRibbonStatus();
+        //private void StartMeasure(ST_MSTMsg MSTMsg)
+        //{
+        //    m_MeasureApp.SetStartMeasureRibbonStatus();
 
-           GetMsrRetData(ref SMsrData.STMThreadStu.SMsrCompleteData);
+        //    GetMsrRetData(ref MSTMsg.STMThreadStu.SMsrCompleteData);
 
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
+        //    m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(MSTMsg);
 
-        }
+        //}
 
 
         private void ShowCurrentFieldPointMessage(Point currPoint)
@@ -330,39 +409,23 @@ namespace OTSMeasureApp
 
             GetMsrRetData(ref SMsrData.STMThreadStu.SMsrCompleteData);
 
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
+            //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(SMsrData);
+            m_OTSMeasureResult.MeasureStopped(SMsrData);
         }
 
         private void PauseMeasure(ST_MSTMsg SMsrData)
         {
             m_MeasureApp.SetPauseMeasureRibbonStatus();
 
-            GetMsrRetData(ref SMsrData.STMThreadStu.SMsrCompleteData);
+            //GetMsrRetData(ref SMsrData.STMThreadStu.SMsrCompleteData);
 
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
+            //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(SMsrData);
+            //m_OTSMeasureResult.me
         }
 
-        private void GetBSEData(ST_MSTMsg SMsrData)
-        {
-
-
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
-        }
+      
 
-        private void UpdateMeasureState(ST_MSTMsg SMsrData)
-        {
-
-            this.GetSMsrUsedTime(ref SMsrData.STMSampleRetData.SFieldData.TUsedTime);
-
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
-        }
-
-        private void GetStartMsrField(ST_MSTMsg SMsrData)
-        {
-
-
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
-        }
+       
 
         private void StartMsrSample(ST_MSTMsg SMsrData)
         {
@@ -379,8 +442,8 @@ namespace OTSMeasureApp
                 SMsrData.STMSampleStu.BCompleteFieldList = FieldList;
             }
 
-            m_OTSMeasureResult.RunMeasureState(SMsrData);
-
+            //m_OTSMeasureResult.UpdateMeasureState_samplespace_propertyGrid(SMsrData);
+            m_OTSMeasureResult.SampleStart(SMsrData);
         }
 
         private void GetSMsrUsedTime(ref TimeSpan MsrUsedTime)
@@ -411,11 +474,8 @@ namespace OTSMeasureApp
            
             return ;
         }
-        public void DoHolePreview()
-        {
-            m_measure.DoHolePreview();
-        }
-        // 开始样品测量
+       
+      
        
         //停止测量
         public void SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS ThreadStatus)
@@ -451,21 +511,11 @@ namespace OTSMeasureApp
             
 
                 List<COTSSample> MeasureCompleteSampleList = new List<COTSSample>();
-                if (!m_ProjData.GetMsredSampleList(ref MeasureCompleteSampleList))
-                {
-                    return false;
-                }
+                
 
 
                 DateTime DTime = new DateTime();
-                if (m_measure.GetMsrThreadStatus() == null)
-                {
-                    return false;
-                }
-                if (m_measure.GetMsrThreadStatus().GetStartTime() == null)
-                {
-                    return false;
-                }
+               
                 DTime = (DateTime)m_measure.GetMsrThreadStatus().GetStartTime();
                 MsrCompleteData.csMsrStartTime = DTime.ToString("yyyy-MM-dd HH:mm:ss");
 

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

@@ -16,6 +16,7 @@ using OTSMeasureApp._0_OTSModel.OTSDataType;
 using System.Windows.Forms;
 using System.Data;
 using System.IO;
+using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
 
 namespace OTSModelSharp
 {
@@ -568,12 +569,10 @@ namespace OTSModelSharp
                 pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
 
                 // let main App know that the sample begin to measure
-                ST_MSTMsg MsgSmpStart = new ST_MSTMsg();
-                MsgSmpStart.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                MsgSmpStart.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
-                MsgSmpStart.STMSampleStu.cSampleName = m_Sample.GetName();
+                ST_MSTMsg MsgSmpStart = new ST_MSTMsg(m_Sample);
+                MsgSmpStart.InitSampleStartMsg();
 
-                m_pMsrThread.SendMessageToMeasureApp(MsgSmpStart);
+                m_pMsrThread.SendMessageToMeasureGUI(MsgSmpStart);
 
                 log.Info(m_Sample.GetName() + " Measurement started!");
                 // get SEM controller to set magnification and working distance
@@ -665,13 +664,11 @@ namespace OTSModelSharp
 
                         SetSEMExteralOff();
                         // update thread measure status class, let the main thread know that this sample measurement stopped
-                        ST_MSTMsg MsgSmpStop = new ST_MSTMsg();
-                        MsgSmpStop.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                        MsgSmpStop.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
-                        MsgSmpStop.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
-                        MsgSmpStop.STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
-                        MsgSmpStop.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
-                        m_pMsrThread.SendMessageToMeasureApp(MsgSmpStop);
+                        ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_Sample);
+
+                        MsgSmpStop.InitSamplePausedMsg();
+                       
+                        m_pMsrThread.SendMessageToMeasureGUI(MsgSmpStop);
                         while (IsPaused())
                         {
                             Thread.Sleep(300);
@@ -708,11 +705,11 @@ namespace OTSModelSharp
                     // update thread measure status class, let the main thread know that starts a new field
                   
 
-                    ST_MSTMsg MsgFieldStart = new ST_MSTMsg();
-                    MsgFieldStart.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-                    MsgFieldStart.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
-                    MsgFieldStart.STMSampleRetData.SMsrField.FieldPos = new Point((int)poiFieldCentre.X,(int)poiFieldCentre.Y);
-                    m_pMsrThread.SendMessageToMeasureApp(MsgFieldStart);
+                    ST_MSTMsg MsgFieldStart = new ST_MSTMsg(m_Sample,curFld);
+
+                    MsgFieldStart.InitFieldStartMsg();
+
+                    m_pMsrThread.SendMessageToMeasureGUI(MsgFieldStart);
                     int fldNo = curFld.GetId();
                     log.Warn("Current field:" + fldNo.ToString());
                     
@@ -739,41 +736,43 @@ namespace OTSModelSharp
                         pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
                         return;
                     }
+                    curFld.SetBSEImage(pBSEImg);
 
-                 
 
                     //BSEData
-                    ST_MSTMsg MsgFieldBSE = new ST_MSTMsg(); 
-
-                    MsgFieldBSE.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-                    MsgFieldBSE.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
-                    MsgFieldBSE.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
-                    MsgFieldBSE.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
-                    MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
-                    MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
-                    byte[] pImgData = pBSEImg.GetImageDataPtr();
-                    MsgFieldBSE.STMSampleRetData.BSEData.lpBSEData = pImgData;
-
-                    m_pMsrThread.SendMessageToMeasureApp(MsgFieldBSE);
+                    ST_MSTMsg MsgFieldBSE = new ST_MSTMsg(m_Sample,curFld);
+                    MsgFieldBSE.InitFieldBSEImageMsg();
+
+                    m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
                   
 
                     log.Info("Acquire BSE image success! Processing image...");
 
                     // image process
 
-                    var rst = FieldImageProcess(curFld, pBSEImg);
+                    FieldImageProcess(curFld);
 
-                  
+                    COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
 
-                    if (rst == true)
+                    if (pXRayParam.GetUsingXray() == true)
                     {
-                        curFld.SetIsMeasureComplete(true);
+
+                       CollectParticlesXrayData(curFld);
+
 
                     }
-                    else 
-                    {
-                        return;
-                    }
+
+                    m_SemHardwareMgr.SetScanExternal(false);
+
+
+
+
+                    m_Sample.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
+
+                   
+                   curFld.SetIsMeasureComplete(true);
+
+                   
                  
                     log.Info("Begin to classify particles! particle num:" + curFld.GetListAnalysisParticles().Count);
                     ClassifyFieldParticles(curFld);
@@ -801,11 +800,12 @@ namespace OTSModelSharp
             pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
 
             // let main thread to know that this sample measurement completes
-            ST_MSTMsg MsgSmplEnd = new ST_MSTMsg();
-            MsgSmplEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-            MsgSmplEnd.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
-            MsgSmplEnd.STMSampleStu.cSampleName = theSample.GetName();
-            m_pMsrThread.SendMessageToMeasureApp(MsgSmplEnd);
+            ST_MSTMsg MsgSmplEnd = new ST_MSTMsg(m_Sample);
+            MsgSmplEnd.InitSampleCompleteMsg();
+            //MsgSmplEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
+            //MsgSmplEnd.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
+            //MsgSmplEnd.STMSampleStu.cSampleName = theSample.GetName();
+            m_pMsrThread.SendMessageToMeasureGUI(MsgSmplEnd);
 
             string userdB = m_Sample.GetMsrParams().GetSTDName();
             if(userdB.ToLower() != "nostddb" && userdB.ToLower() != "nostddb.db")
@@ -828,12 +828,12 @@ namespace OTSModelSharp
         }
 
      
-        public virtual bool FieldImageProcess(COTSFieldData curFldData, CBSEImgClr a_pBSEImg)
+        public virtual void FieldImageProcess(COTSFieldData curFldData)
         {
 
             PointF fldCenter = curFldData.OTSPos;
            
-            curFldData.SetBSEImage(a_pBSEImg);
+           
             CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
             PointF semPos = new Point();
             a_pCSEMStageData.ConvertOTSToSEMCoord(fldCenter, ref semPos);
@@ -856,34 +856,8 @@ namespace OTSModelSharp
             var analysisparts = curFldData.GetListAnalysisParticles();
             curFldData.CalParticleImageProp(analysisparts);//calculate particle image property such as feret diameter, DMAX etc.
 
-            COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
-
-            if (pXRayParam.GetUsingXray() == true)
-            {
-               
-              
-
-                while (bSaveThreadWorking)
-                {
-                    log.Info("last field has not finished yet! waiting!");
-                    Thread.Sleep(100);
-                }
-                
-                CollectParticlesXrayData(curFldData);
-
-               
-            }
-
-            m_SemHardwareMgr.SetScanExternal(false);
-
-
-
-
-            m_Sample.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
-
           
-
-            return true;
+            return ;
 
         }
 
@@ -952,34 +926,53 @@ namespace OTSModelSharp
        
         public virtual void CollectParticlesXrayData(COTSFieldData curFldData)
         {
-            List<COTSParticleClr> parts = new List<COTSParticleClr>();
-            foreach (var p in curFldData.GetListXrayParticles())
+          
+            var allParts = curFldData.GetListXrayParticles();
+          
+            var smallparts = new List<COTSParticleClr>();
+            var bigparts = new List<COTSParticleClr>();
+
+            double quantifyThreshold = m_Sample.GetMsrParams().GetXRayParam().GetFeatureModeMinSize();
+            foreach (var part in allParts)
             {
-                if (p.IsXrayParticle())
+                double equalCircleDiameter = Math.Sqrt(part.GetActualArea() / 3.14159) * 2f;
+                if (equalCircleDiameter < quantifyThreshold)
+                {
+                    smallparts.Add(part);
+                }
+                else
                 {
-                    parts.Add(p);
+                    bigparts.Add(part);
                 }
             }
 
-            curFldData.CreateXrayList(parts);
+            log.Info("SmallQuantifyParts (<" + quantifyThreshold.ToString("f2") + "): " + smallparts.Count);
+            log.Info("BigQuantifyParts (>=" + quantifyThreshold.ToString("f2") + "): " + bigparts.Count);
+
+            curFldData.CreateXrayList(smallparts);
+            curFldData.CreateXrayList(bigparts);
+
             // 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;
-              
-              
 
+                uint nXRayAQTime;
 
-                if (parts.Count > 0)
+                if (bigparts.Count > 0)
                 {
+                    log.Info("Begin to collect xraydata:" + bigparts.Count + " on " + workmode.ToString());
+                    nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
+                    m_EDSController.GetXRayByParts(bigparts, nXRayAQTime, true);
 
-                        nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
-                        m_EDSController.GetXRayByParts(parts, nXRayAQTime, true);
-                   
+                }
+                if (smallparts.Count > 0)
+                {
+                    log.Info("Begin to collect xraydata:" + smallparts.Count + " on " + workmode.ToString());
+                    nXRayAQTime = (uint)pXRayParam.GetFastXrayTime();
+                    m_EDSController.GetXRayByParts(smallparts, nXRayAQTime, true);
 
                 }
 
@@ -989,11 +982,18 @@ namespace OTSModelSharp
               
                 uint nXRayAQTime;
                
-                if (parts.Count > 0)
+                if (bigparts.Count > 0)
                 {
-
+                        log.Info("Begin to collect xraydata:" + bigparts.Count + " on " + OTS_X_RAY_SCAN_MODE.FeatureMode.ToString());
                         nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
-                        m_EDSController.GetXRayByFeatures(parts, nXRayAQTime, true);
+                        m_EDSController.GetXRayByFeatures(bigparts, nXRayAQTime, true);
+
+                }
+                if (smallparts.Count > 0)
+                {
+                    log.Info("Begin to collect xraydata:" + smallparts.Count + " on " + OTS_X_RAY_SCAN_MODE.PointMode.ToString());
+                    nXRayAQTime = (uint)pXRayParam.GetFastXrayTime();
+                    m_EDSController.GetXRayByParts(smallparts, nXRayAQTime, true);
 
                 }
 
@@ -1051,11 +1051,6 @@ namespace OTSModelSharp
                 // set current time to current time
                 pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
 
-                // let main App know that the sample begin to measure
-                ST_MSTMsg MsgSmpStart=new ST_MSTMsg();
-                MsgSmpStart.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
-                MsgSmpStart.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
-               MsgSmpStart.STMSampleStu.cSampleName=m_Sample.GetName();
 
 
                 // get SEM controller to set magnification and working distance
@@ -1098,7 +1093,7 @@ namespace OTSModelSharp
                 }
 
                 // go through each field
-                int nNewFieldId = 0;
+                //int nNewFieldId = 0;
                 for ( int i = 0; i < listFieldCenter.Count; ++i)
                 {// check and break if stop button is clicked
                     if (IsAborted())
@@ -1121,16 +1116,6 @@ namespace OTSModelSharp
 
              
 
-                    // update thread measure status class, let the main thread know that starts a new field
-                    pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
-
-                    ST_MSTMsg MsgFieldStart=new ST_MSTMsg();
-                    MsgFieldStart.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-                    MsgFieldStart.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
-                    MsgFieldStart.STMSampleRetData.SMsrField.FieldPos = poiFieldCentre;
-
-
-                    m_pMsrThread.SendMessageToMeasureApp(MsgFieldStart);
 
                     // move SEM to the field center
                     if (!MoveSEMToPoint(poiFieldCentre))
@@ -1156,21 +1141,15 @@ namespace OTSModelSharp
                         return;
                     }
 
+
                     //BSEData
-                    ST_MSTMsg MsgFieldBSE=new ST_MSTMsg();
-                  
-                    MsgFieldBSE.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-                    MsgFieldBSE.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
-                    MsgFieldBSE.STMSampleRetData.BSEData.pos = poiFieldCentre;
-                    MsgFieldBSE.STMSampleRetData.BSEData.fieldId = i;
+                    ST_MSTMsg MsgFieldBSE=new ST_MSTMsg(m_HolePreviewSample);
 
-                    MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataHeight = pBSEIamge.GetHeight();
-                    MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataWidth = pBSEIamge.GetWidth();
-                    byte[] pImgData = pBSEIamge.GetImageDataPtr();
-                    MsgFieldBSE.STMSampleRetData.BSEData.lpBSEData = pImgData;
+                    MsgFieldBSE.InitHolePreBSEDataMsg(pBSEIamge,poiFieldCentre);
+                  
 
 
-                    m_pMsrThread.SendMessageToMeasureApp(MsgFieldBSE);
+                    m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgFieldBSE);
 
                     if (pStatus.GetStatus() != OTS_MSR_SAMPLE_STATUS.INPROCESS)
                     {
@@ -1191,24 +1170,6 @@ namespace OTSModelSharp
 
                     m_listHoleBSEImg.Add(pHoleBSEImg);
 
-                   
-
-                    // prepare for the next
-                    ++nNewFieldId;
-                    pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
-
-                    ST_MSTMsg MsgFieldEnd=new ST_MSTMsg();
-                   
-                    MsgFieldEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-                    MsgFieldEnd.STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
-                    MsgFieldEnd.STMSampleRetData.SFieldData.iCompleteFieldCount = (i + 1);
-                    MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = listFieldCenter.Count;
-                    MsgFieldEnd.STMSampleRetData.SFieldData.iSParticleCount = 0;
-                    MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos = poiFieldCentre;
-                   
-
-                    m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
-
                 }
 
                 pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
@@ -1216,11 +1177,12 @@ namespace OTSModelSharp
                 pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
 
                 // let main thread to know that this sample measurement completes
-                ST_MSTMsg MsgSmplEnd=new ST_MSTMsg();
-                MsgSmplEnd.iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
-                MsgSmplEnd.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.COMPLETED;
+                ST_MSTMsg MsgSmplEnd=new ST_MSTMsg(m_HolePreviewSample);
+
+                MsgSmplEnd.InitHolePreSampleEndMsg();
+               
               
-                m_pMsrThread.SendMessageToMeasureApp(MsgSmplEnd);
+                m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgSmplEnd);
 
             }
         }
@@ -1361,16 +1323,11 @@ namespace OTSModelSharp
             //Field Data
             // record end time
             pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
-            ST_MSTMsg MsgFieldEnd = new ST_MSTMsg();
-            MsgFieldEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
-            MsgFieldEnd.STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
-            MsgFieldEnd.STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
-            MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = m_Sample.GetFieldsData().Count;
-            MsgFieldEnd.STMSampleRetData.SFieldData.iSParticleCount = (int)curFld.GetListAnalysisParticles().Count;
-            MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(curFld.OTSPos.X);
-            MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(curFld.OTSPos.Y);
-
-            m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
+            ST_MSTMsg MsgFieldEnd = new ST_MSTMsg(m_Sample,curFld);
+            MsgFieldEnd.InitFieldDataMsg();
+           
+
+            m_pMsrThread.SendMessageToMeasureGUI(MsgFieldEnd);
 
 
         }

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

@@ -45,11 +45,6 @@ namespace OTSModelSharp
 
     
 
-        // search x-ray file name
-        //public string SMPL_MSR_RESULT_SEARCH_X_RAY_FILE = ("SearchXray.db");
-
-
-
         //----------全局定义------------------
         // sample measure result file mark
         public int SMPL_MSR_RESULT_FILE_MARK = 'S' + 'M' + 'P' + 'L' + 'M' + 'S' + 'R' + 'R' + 'E' + 'S' + 'U' + 'L' + 'T';

+ 1 - 3
OTSIncAMeasureApp/1-OTSMeasure/Measure/BSEPicData/COTSFieldData.cs

@@ -245,12 +245,10 @@ namespace OTSModelSharp
        
         public bool CreateXrayList(List<COTSParticleClr> a_listParticles)
         {
-      ;
+     
             foreach (COTSParticleClr pPart in a_listParticles)
             {
              
-         
-              
                 System.Drawing.Point poi = (System.Drawing.Point)pPart.GetXRayPos();
              
                 CPosXrayClr pPosXray = new CPosXrayClr();

+ 72 - 10
OTSIncAMeasureApp/1-OTSMeasure/MeasureRetThread.cd

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <ClassDiagram MajorVersion="1" MinorVersion="1">
   <Class Name="OTSMeasureApp.OTSMeasureDisplayResult">
-    <Position X="12.5" Y="6" Width="2.75" />
+    <Position X="12.25" Y="6" Width="2.75" />
     <Compartments>
       <Compartment Name="Methods" Collapsed="true" />
     </Compartments>
@@ -13,47 +13,109 @@
       </Enum>
     </NestedTypes>
     <TypeIdentifier>
-      <HashCode>AABAAAIgABAQAAIAIAAAiAIiAAACAAAFAABRYAABABA=</HashCode>
+      <HashCode>IABAAAIgAAAQAAAAIAAAiAIiAAACAAAFAABRYAAJABA=</HashCode>
       <FileName>1-OTSMeasure\OTSMeasureDisplayResult.cs</FileName>
     </TypeIdentifier>
     <ShowAsAssociation>
       <Field Name="m_OTSSamplespaceWindow" />
       <Field Name="m_OTSMeasureResultWindow" />
+      <Field Name="m_OTSMeasureStatusWindow" />
+      <Field Name="m_SPropertyWindows" />
     </ShowAsAssociation>
   </Class>
   <Class Name="OTSMeasureApp.OTSMeasureResultWindow" Collapsed="true">
-    <Position X="17.75" Y="7.5" Width="2.75" />
+    <Position X="17.25" Y="7.5" Width="3" />
     <TypeIdentifier>
-      <HashCode>AADAIjAARLAIITjAIECASAMiACEogAEkAQIAAQRABCU=</HashCode>
+      <HashCode>AADAIjAARLAIITDAIECASAMiACEooAEkAQIAAQRABCU=</HashCode>
       <FileName>1-OTSMeasure\OTSMeasureResultWindow.cs</FileName>
     </TypeIdentifier>
   </Class>
   <Class Name="OTSMeasureApp.OTSSamplespaceWindow" Collapsed="true">
     <Position X="7.25" Y="7.5" Width="2.5" />
     <TypeIdentifier>
-      <HashCode>A7Tc6pkUBKXhzgHlBCiCeIv3wH4DgJnV80iECQATUAA=</HashCode>
+      <HashCode>A7TY6hkUBKXhzgHlBCiCeIv3QH6DgJnV80iECQATUAA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\OTSSamplespaceWindow.cs</FileName>
     </TypeIdentifier>
   </Class>
   <Class Name="OTSMeasureApp.CMeasureThreadWrapper">
-    <Position X="12" Y="2.75" Width="3.75" />
+    <Position X="11.5" Y="2.75" Width="3.75" />
     <Compartments>
       <Compartment Name="Methods" Collapsed="true" />
     </Compartments>
     <TypeIdentifier>
       <HashCode>FAgIAgAgIYIAAACQBAAEKo0gQBAAAAUAAQBiYAQACAA=</HashCode>
-      <FileName>1-OTSMeasure\CMeasureThreadWrapper.cs</FileName>
+      <FileName>1-OTSMeasure\Measure\3-MeasureFlow\CMeasureThreadWrapper.cs</FileName>
     </TypeIdentifier>
     <ShowAsAssociation>
       <Field Name="m_OTSMeasureResult" />
       <Field Name="m_measure" />
     </ShowAsAssociation>
   </Class>
-  <Class Name="OTSModelSharp.CMeasure" Collapsed="true">
-    <Position X="17.75" Y="2.75" Width="1.5" />
+  <Class Name="OTSModelSharp.CMeasure">
+    <Position X="16.5" Y="2.75" Width="2.75" />
+    <Compartments>
+      <Compartment Name="Methods" Collapsed="true" />
+    </Compartments>
+    <NestedTypes>
+      <Delegate Name="OTSModelSharp.CMeasure.ProgressEventHandler" Collapsed="true">
+        <TypeIdentifier>
+          <NewMemberFileName>1-OTSMeasure\Measure\3-MeasureFlow\CMeasure.cs</NewMemberFileName>
+        </TypeIdentifier>
+      </Delegate>
+    </NestedTypes>
     <TypeIdentifier>
       <HashCode>AAxAEAgAAQIAAAAQFQAEAADAAAJBAAAQAAAGSCBgQAA=</HashCode>
-      <FileName>0-OTSModel\Measure\3-MeasureFlow\CMeasure.cs</FileName>
+      <FileName>1-OTSMeasure\Measure\3-MeasureFlow\CMeasure.cs</FileName>
+    </TypeIdentifier>
+    <ShowAsCollectionAssociation>
+      <Field Name="mapSmplMsr" />
+    </ShowAsCollectionAssociation>
+  </Class>
+  <Class Name="OTSModelSharp.CSmplMeasure">
+    <Position X="20.75" Y="2.75" Width="2.75" />
+    <Compartments>
+      <Compartment Name="Methods" Collapsed="true" />
+    </Compartments>
+    <NestedTypes>
+      <Class Name="OTSModelSharp.CSmplMeasure.SEMStateObject" Collapsed="true">
+        <TypeIdentifier>
+          <NewMemberFileName>1-OTSMeasure\Measure\3-MeasureFlow\CSmplMeasure.cs</NewMemberFileName>
+        </TypeIdentifier>
+      </Class>
+      <Class Name="OTSModelSharp.CSmplMeasure.AutoResetSEMControl" Collapsed="true">
+        <TypeIdentifier>
+          <NewMemberFileName>1-OTSMeasure\Measure\3-MeasureFlow\CSmplMeasure.cs</NewMemberFileName>
+        </TypeIdentifier>
+        <Lollipop Position="0.2" />
+      </Class>
+    </NestedTypes>
+    <TypeIdentifier>
+      <HashCode>kQMAACcA0xIAAAAUZQAhCQAwBAJEkADBYIIkCAgQAMA=</HashCode>
+      <FileName>1-OTSMeasure\Measure\3-MeasureFlow\CSmplMeasure.cs</FileName>
+    </TypeIdentifier>
+    <ShowAsAssociation>
+      <Field Name="m_pMsrThread" />
+    </ShowAsAssociation>
+  </Class>
+  <Class Name="OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow.ST_MSTMsg" Collapsed="true">
+    <Position X="15.25" Y="2" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AAAAAQAAAAAAAAAAAAAABAAAAAAAAAUAAAAAAAAAAAA=</HashCode>
+      <FileName>1-OTSMeasure\Measure\3-MeasureFlow\ST_MSTMsg.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Class Name="OTSMeasureApp.OTSMeasureStatusWindow" Collapsed="true">
+    <Position X="17.25" Y="6.5" Width="3" />
+    <TypeIdentifier>
+      <HashCode>BMAhagmSRPDiAwdW1A7tCTDKogmcQcCKQchMCQTtNZU=</HashCode>
+      <FileName>5-OTSMeasureStatuImageFun\OTSMeasureStatusWindow.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Class Name="OTSMeasureApp.OTSPropertyWindow" Collapsed="true">
+    <Position X="7.25" Y="6.25" Width="2" />
+    <TypeIdentifier>
+      <HashCode>IAAAQAgAASAIAAAAEQCAAAACAQAQgCEABQAIIAAAAAQ=</HashCode>
+      <FileName>3-OTSDisplaySourceGridData\OTSPropertyWindow.cs</FileName>
     </TypeIdentifier>
   </Class>
   <Font Name="Microsoft YaHei UI" Size="9" />

+ 229 - 322
OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs

@@ -11,7 +11,9 @@ using System.Text;
 using System.Threading;
 using System.Windows.Forms;
 using static OTSDataType.otsdataconst;
-using static OTSModelSharp.STMSampleResultData;
+
+using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
+using static OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow.STMSampleResultData;
 
 namespace OTSMeasureApp
 {
@@ -39,11 +41,14 @@ namespace OTSMeasureApp
         public OTSMeasureResultWindow m_OTSMeasureResultWindow = null;
         //在窗体TAB测量状态中显示BSE图
         public OTSMeasureStatusWindow m_OTSMeasureStatusWindow = null;
+
+        public OTSPropertyWindow m_SPropertyWindows = null;
+
         public System.ComponentModel.BackgroundWorker m_bgWorker;
       
    
         ST_MSTMsg MeasureResultMsrData;
-        //已完成帧图的绘制 根据位置-判断相差范围  四舍五入返回的数值有偏差
+       
        
         #endregion
 
@@ -56,9 +61,11 @@ namespace OTSMeasureApp
                
                 m_OTSSamplespaceWindow = m_MeasureApps.m_SamplepaceWindow;
                 m_OTSMeasureResultWindow = m_MeasureApp.m_MeasureResultWindow;
-                m_OTSMeasureStatusWindow = new OTSMeasureStatusWindow(m_MeasureApp);
-               
-                Control.CheckForIllegalCrossThreadCalls = false;
+                m_SPropertyWindows = m_MeasureApp.m_SPropertyWindows;
+            //m_OTSMeasureStatusWindow = new OTSMeasureStatusWindow(m_MeasureApp);
+            m_OTSMeasureStatusWindow = m_MeasureApp.m_MessureStatuWindow;
+
+            Control.CheckForIllegalCrossThreadCalls = false;
 
                 //测量结束信息窗口对象
                 m_MeasureCheckReportInfoWindow = new MeasureCheckResultInfoWindow();
@@ -69,7 +76,7 @@ namespace OTSMeasureApp
                 m_bgWorker.WorkerSupportsCancellation = true;
              
                 m_bgWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
-                m_bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
+               
               
           
         }
@@ -106,8 +113,9 @@ namespace OTSMeasureApp
                         List<CMsrResultItem> cMsrResultItemClrList = MsrResults.GetResultItems();
                         
                         //设置测量状态数据列表
-                        SetMeasureListInfo(cMsrResultItemClrList);
-                   
+                       
+                    m_OTSMeasureResultWindow.SetMeasureListInfo(cMsrResultItemClrList);
+
                 }
 
             }
@@ -118,16 +126,6 @@ namespace OTSMeasureApp
         }
         #endregion
 
-        #region 处理完成的响应事件_RunWorkerCompleted
-        //这里是后台工作完成后的消息处理,可以在这里进行后续的处理工作。
-        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
-        {
-            //m_bgWorker.CancelAsync();
-
-            //m_bgWorker = null;
-        }
-        #endregion
-
 
 
    
@@ -194,54 +192,11 @@ namespace OTSMeasureApp
         }
         #endregion
 
-        #region 隐藏BSE图片
-
-        #endregion
-
-        #region 初始窗口对象
+      
 
-        int intFlag = 0;
-        public void RunThreadLoadEvent()
-        {
-            if (intFlag == 0)
-            {
-                m_bgWorker.RunWorkerAsync();
-                intFlag++;
-            }
-        }
-        #endregion
-        #region 设置测量状态列表数据
-        /// <summary>
-        /// 设置测量状态列表数据
-        /// </summary>
-        /// <param name="stratTime"></param>
-        public void SetMeasureListInfo(IList list)
-        {
-            //设置开始时间
-            if (list != null)
-            {
-                //获取测量状态Grid中的数据list
-                m_OTSMeasureResultWindow.SetMeasureListInfo(list);
-            }
-        }
-        #endregion
-        #region 设置开始时间
-        /// <summary>
-        /// 设置开始时间
-        /// </summary>
-        /// <param name="stratTime"></param>
-        public void SetStartTime(string stratTime)
-        {
-            //设置开始时间
-            if (stratTime != null)
-            {
-                if (stratTime != "")
-                {
-                    m_OTSMeasureResultWindow.SetStartTime(stratTime);
-                }
-            }
-        }
-        #endregion
+       
+        
+       
 
 
         #region 设置测量结束窗体中信息内容
@@ -283,45 +238,146 @@ namespace OTSMeasureApp
         }
         #endregion
 
-        #region 设置测量用时
-        public void SetMeasureTime(TimeSpan tSpan)
+       
+
+        public void MeasureComplete(ST_MSTMsg SMsrData)
         {
-            m_OTSMeasureResultWindow.SetMeasureTime(tSpan);
+
+
+            string inprocessEndTime = SMsrData.STMThreadStu.csMsrEndTime;
+            SetMeasureResultInfo(SMsrData);
+            MeasureResultMsrData = SMsrData;
+
+            m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
+            //激活跳转至报告程序按钮
+            m_MeasureApp.rbPReport.Enabled = true;
+            m_MeasureApp.rbReport.Enabled = true;
+            //获取需显示的grid信息
+            var sample = m_MeasureApp.m_ProjParam.GetWorkSample();
+            var stype = m_MeasureApp.m_ProjParam.GetDefaultParam().GetSysType();
+            OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype);
+            m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
         }
-        #endregion
 
-        #region 设置样品名称
-        /// <summary>
-        /// 设置样品名称
-        /// </summary>
-        /// <param name="SetSampleName"></param>
-        public void SetSampleName(string sampleName)
+
+
+
+
+            #region 测量方法
+            //运行测量状态方法
+        //public void UpdateMeasureState_samplespace_propertyGrid(ST_MSTMsg SMsrData)
+        //{
+           
+                
+              
+        //        //测量状态:开始状态、完成状态(测量停止、测量失败、测量完成)
+        //        OTS_MSR_THREAD_STATUS msrStatus = SMsrData.STMThreadStu.iMsrStatu;
+
+               
+
+
+        //        switch (SMsrData.iMsgType)
+        //        {
+        //            //测量线程状态
+        //            case ENUM_MSG_TYPE.MTHREADSTATUS:
+        //                switch (msrStatus)
+        //                {
+        //                    //测量状态在进行中-测量开始
+        //                    case OTS_MSR_THREAD_STATUS.INPROCESS:
+                               
+        //                        break;
+        //                    //测量状态已完成
+        //                    case OTS_MSR_THREAD_STATUS.COMPLETED:
+        //                        //当前线程执行类型 1:测量
+        //                        MeasureComplete(SMsrData);
+
+
+
+
+        //                        break;
+        //                    //测量状态已失败
+        //                    case OTS_MSR_THREAD_STATUS.FAILED:
+        //                        //当前线程执行类型 1:测量
+        //                        MeasureFailed(SMsrData);
+                                    
+                               
+        //                        break;
+        //                    //测量状态已停止
+        //                    case OTS_MSR_THREAD_STATUS.STOPPED:
+        //                        //当前线程执行类型 1:测量
+        //                        MeasureStopped(SMsrData);
+                                
+                               
+                          
+
+                             
+        //                        break;
+        //                }
+        //                break;
+        //            //测量结果
+        //            case ENUM_MSG_TYPE.MSAMPLESTATUS:
+        //                //获取测量状态样品信息
+        //                OTS_MSR_SAMPLE_STATUS msrSampleStatu = SMsrData.STMSampleStu.iMsrSampleStatu;
+        //                switch (msrSampleStatu)
+        //                {
+        //                    case OTS_MSR_SAMPLE_STATUS.INPROCESS:
+        //                        //当前线程执行类型 1:测量
+        //                        SampleStart(SMsrData);
+                               
+        //                        break;
+        //                }
+        //                break;
+        //            case ENUM_MSG_TYPE.MSAMPLERESULT:
+        //                //获取测量状态的Field与BSE信息
+        //                MSAMPLE_RET retDataType = SMsrData.STMSampleRetData.iRetDataType;
+
+        //                //判断测量状态提供Field与BSE信息
+        //                switch (retDataType)
+        //                {
+        //                    case MSAMPLE_RET.BSE_DATA:
+
+        //                        Field_BSE_DATA(SMsrData);
+                               
+                                
+                                   
+                                
+        //                        break;
+        //                    case MSAMPLE_RET.FIELD_DATA:
+        //                        //当前线程执行类型 1:测量
+        //                        Field_DATA(SMsrData);
+        //                        //设置测量当前用时
+                               
+
+                               
+        //                        break;
+        //                    case MSAMPLE_RET.START_MSR_FIELD:
+        //                        //当前线程执行类型 1:测量
+        //                        Field_START_MSR(SMsrData);
+                                   
+                                
+        //                        break;
+        //                }
+        //                break;
+        //        }
+           
+        //}
+
+        public void Field_START_MSR(ST_MSTMsg SMsrData)
         {
-            //设置开始时间
-            if (sampleName != null)
-            {
-                if (sampleName != "")
-                {
-                    m_MeasureApp.m_SamplepaceWindow.SetSampleOrder(sampleName);
-                    double iWDistance = 0;
-                    double dMagni = 0;
-                    m_MeasureApp.m_ProjParam.GetWorkingSampleSEMData(ref iWDistance, ref dMagni);
-                    
-                    if (m_MeasureApp.GetRunType() == MSR_RUN_TYPE.RUNMEASURE)
-                    {
-                        m_OTSMeasureResultWindow.SetSampleName(sampleName);
-                    }
-                    m_MeasureApp.m_SamplepaceWindow.Invalidate();
-                }
-            }
-        }
-        #endregion
+            var sam1 = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
+            m_MeasureApp.m_SamplepaceWindow.ChangeDoneMeasureState(sam1, SMsrData.STMSampleRetData.SMsrField.FieldPos, Color.Yellow);
 
-       
+            m_MeasureApp.m_SamplepaceWindow.Invalidate();
+        }
 
-        #region 测量状态进度窗口
-        public void MeasureStateProgressInfo(SAMPLEFIELDDATA FieldData)
+        public void Field_DATA(ST_MSTMsg SMsrData)
         {
+            
+                
+            m_OTSMeasureResultWindow.SetMeasureTime(SMsrData.STMSampleRetData.SFieldData.TUsedTime);
+            
+            //---------update the progress bar测量状态进度窗口
+            var FieldData =SMsrData.STMSampleRetData.SFieldData;
             //样品测量中的总帧图数
             int MeasureFieldTotalCount = FieldData.iMeasureFieldCount;
             //样品测量中当前已测量的帧图数
@@ -333,243 +389,94 @@ namespace OTSMeasureApp
                 //设置当前进度信息(当前Field数量与Field总数)
                 m_OTSMeasureResultWindow.SetCurrentProgressInfo(CompleteFieldCount, MeasureFieldTotalCount, ParticleCount);
             }
+            //-----------
+            var sam = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
+            m_MeasureApp.m_SamplepaceWindow.ChangeDoneMeasureState(sam, SMsrData.STMSampleRetData.SFieldData.FieldPos, Color.Green);
+            m_MeasureApp.m_SamplepaceWindow.Invalidate();
         }
-        #endregion
 
-     
-
-       
-
-
-
-        #region 测量方法
-        //运行测量状态方法
-        public void RunMeasureState(ST_MSTMsg SMsrData)
+        public void Field_BSE_DATA(ST_MSTMsg SMsrData)
         {
-            try
+            //获取显示BSE的图片数据
+            byte[] ImageData = SMsrData.STMSampleRetData.BSEData.lpBSEData;
+            //图片宽度
+            int width = SMsrData.STMSampleRetData.BSEData.iBSEDataWidth;
+            //图片高度
+            int height = SMsrData.STMSampleRetData.BSEData.iBSEDataHeight;
+            //显示状态中的BSE图像控件
+            if (!m_MeasureApp.m_MessureStatuWindow.picBox.Visible)
             {
-                
-                //消息枚举 测量状态、测量结果
-                ENUM_MSG_TYPE dataType = SMsrData.iMsgType;
-                //测量状态:开始状态、完成状态(测量停止、测量失败、测量完成)
-                OTS_MSR_THREAD_STATUS msrStatus = SMsrData.STMThreadStu.iMsrStatu;
-                //获取当前线程执行类型 1:测量 2:获取样品孔图片
-                var runThreadType = m_MeasureApp.GetRunType();
-
-                //获取需显示的grid信息
-                var sample = m_MeasureApp.m_ProjParam.GetWorkSample();
-                var stype = m_MeasureApp.m_ProjParam.GetDefaultParam().GetSysType();
-                OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample,stype);
-                //m_MeasureApp.m_ProjParam.GetWorkSamplePerameter(m_MeasureApp.m_ProjParam.GetWorkSample(), ref MeasureInfo);
-
-                switch (dataType)
-                {
-                    //测量线程状态
-                    case ENUM_MSG_TYPE.MTHREADSTATUS:
-                        switch (msrStatus)
-                        {
-                            //测量状态在进行中-测量开始
-                            case OTS_MSR_THREAD_STATUS.INPROCESS:
-                               
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-
-                                    string startTime = SMsrData.STMThreadStu.csMsrStartTime;
-                             
-                                     
-                                }
-                           
-                                break;
-                            //测量状态已完成
-                            case OTS_MSR_THREAD_STATUS.COMPLETED:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    string inprocessEndTime = SMsrData.STMThreadStu.csMsrEndTime;
-                                    SetMeasureResultInfo(SMsrData);
-                                    MeasureResultMsrData = SMsrData;
-
-                                    m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
-                                    //激活跳转至报告程序按钮
-                                    m_MeasureApp.rbPReport.Enabled = true;
-                                    m_MeasureApp.rbReport.Enabled = true;
-                                    m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
-                                }
-                          
+                m_MeasureApp.m_MessureStatuWindow.picBox.Visible = true;
+            }
+            //调用测量状态TAB中窗体 显示BSE图片
+            OTSMeasureStatusWindowFun(width, height, ImageData, m_MeasureApp);
+        }
 
-                                //测量完成,更新Grid显示的测量信息
-                             
-                                break;
-                            //测量状态已失败
-                            case OTS_MSR_THREAD_STATUS.FAILED:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    string failedEndTime = SMsrData.STMThreadStu.csMsrEndTime;
-                                    SetMeasureResultInfo(SMsrData);
-                                    MeasureResultMsrData = SMsrData;
-                                    m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
-                                }
-                          
+        public void SampleStart(ST_MSTMsg SMsrData)
+        {
+            //获取样品名称
+            string sampleName = SMsrData.STMSampleStu.cSampleName;
+            //样品测量开始时间
+            string csSampleMsrStartTime = SMsrData.STMSampleStu.csSampleMsrStartTime;
+            //设置样品名称
+            
+                if (sampleName != "")
+                {
+                    
+                        m_MeasureApp.m_SamplepaceWindow.SetSampleOrder(sampleName);
 
-                                //测量失败,更新Grid显示的测量信息
-                                m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
-                                break;
-                            //测量状态已停止
-                            case OTS_MSR_THREAD_STATUS.STOPPED:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    string stopEndTime = SMsrData.STMThreadStu.csMsrEndTime;
-                                    //打开测量结果窗口
-                                    SetMeasureResultInfo(SMsrData);
-                                    MeasureResultMsrData = SMsrData;
-                                    m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
-                                    //激活跳转至报告程序按钮
-                                    m_MeasureApp.rbPReport.Enabled = true;
-                                    m_MeasureApp.rbReport.Enabled = true;
-                                    //测量停止,更新Grid显示的测量信息
-                                    m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
-                                }
-                          
 
-                             
-                                break;
-                        }
-                        break;
-                    //测量结果
-                    case ENUM_MSG_TYPE.MSAMPLESTATUS:
-                        //获取测量状态样品信息
-                        OTS_MSR_SAMPLE_STATUS msrSampleStatu = SMsrData.STMSampleStu.iMsrSampleStatu;
-                        switch (msrSampleStatu)
+                        if (m_MeasureApp.GetRunType() == MSR_RUN_TYPE.RUNMEASURE)
                         {
-                            case OTS_MSR_SAMPLE_STATUS.INPROCESS:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    //获取样品名称
-                                    string sampleName = SMsrData.STMSampleStu.cSampleName;
-                                    //样品测量开始时间
-                                    string csSampleMsrStartTime = SMsrData.STMSampleStu.csSampleMsrStartTime;
-                                    //设置样品名称
-                                    if (sampleName != null)
-                                    {
-                                        if (sampleName != "")
-                                        {
-                                            SetSampleName(sampleName);
-                                            //设置开始时间
-                                            SetStartTime(csSampleMsrStartTime);
-                                          
-                                        }
-                                    }
-                                    //切换样品
-                                    m_MeasureApp.SwitchWSample(sampleName);
-                                    //设置样品名称
-                                    m_OTSMeasureResultWindow.SetSampleName(sampleName);
-
-                                    
-                                    
-                                }
-                                else if (runThreadType == MSR_RUN_TYPE.RUNSampleHoleImage)
-                                {
-                                    //获取样品名称
-                                    string sampleName = SMsrData.STMSampleStu.cSampleName;
-                                    //设置样品名称
-                                    if (sampleName == null)
-                                    {
-                                        if (sampleName.Equals(""))
-                                        {
-                                            if (m_MeasureApp.m_ProjParam.GetWorkSample() != null)
-                                            {
-                                                sampleName = m_MeasureApp.m_ProjParam.GetWorkSample().GetName();
-                                            }
-                                        }
-                                    }
-                                    SetSampleName(sampleName);
-                                }
-                                break;
+                            m_OTSMeasureResultWindow.SetSampleName(sampleName);
                         }
-                        break;
-                    case ENUM_MSG_TYPE.MSAMPLERESULT:
-                        //获取测量状态的Field与BSE信息
-                        MSAMPLE_RET retDataType = SMsrData.STMSampleRetData.iRetDataType;
-
-                        //判断测量状态提供Field与BSE信息
-                        switch (retDataType)
-                        {
-                            case MSAMPLE_RET.BSE_DATA:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    //获取显示BSE的图片数据
-                                    byte[] ImageData = SMsrData.STMSampleRetData.BSEData.lpBSEData;
-                                    //图片宽度
-                                    int width = SMsrData.STMSampleRetData.BSEData.iBSEDataWidth;
-                                    //图片高度
-                                    int height = SMsrData.STMSampleRetData.BSEData.iBSEDataHeight;
-                                    //显示状态中的BSE图像控件
-                                    if (!m_MeasureApp.m_MessureStatuWindow.picBox.Visible)
-                                    {
-                                        m_MeasureApp.m_MessureStatuWindow.picBox.Visible = true;
-                                    }
-                                    //调用测量状态TAB中窗体 显示BSE图片
-                                    OTSMeasureStatusWindowFun(width, height, ImageData, m_MeasureApp);
-                                 
-                                  
-
-                                }
-                                else if (runThreadType == MSR_RUN_TYPE.RUNSampleHoleImage)
-                                {
-                                    //获取显示BSE的图片数据
-                                    byte[] ImageData = SMsrData.STMSampleRetData.BSEData.lpBSEData;
-                                    //图片宽度
-                                    int width = SMsrData.STMSampleRetData.BSEData.iBSEDataWidth;
-                                    //图片高度
-                                    int height = SMsrData.STMSampleRetData.BSEData.iBSEDataHeight;
-                                    //Field位置
-                                    Point fieldPos = SMsrData.STMSampleRetData.BSEData.pos;
-                                    int fieldid= SMsrData.STMSampleRetData.BSEData.fieldId;
-                                    //设置样品孔中BSE图像信息
-                                    m_MeasureApp.m_SamplepaceWindow.AddHoleBSEImageData(ImageData, width, height, fieldPos,fieldid);
-                                }
-                                break;
-                            case MSAMPLE_RET.FIELD_DATA:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    //设置测量当前用时
-                                    if (SMsrData.STMSampleRetData.SFieldData.TUsedTime != null)
-                                    {
-                                        SetMeasureTime(SMsrData.STMSampleRetData.SFieldData.TUsedTime);
-                                    }
-
-                                    MeasureStateProgressInfo(SMsrData.STMSampleRetData.SFieldData);
-                                    var sam = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
-                                    m_MeasureApp.m_SamplepaceWindow. ChangeDoneMeasureState(sam,SMsrData.STMSampleRetData.SFieldData.FieldPos, Color.Green);
-                                    m_MeasureApp.m_SamplepaceWindow.Invalidate();
-
-                                }
-                                break;
-                            case MSAMPLE_RET.START_MSR_FIELD:
-                                //当前线程执行类型 1:测量
-                                if (runThreadType == MSR_RUN_TYPE.RUNMEASURE)
-                                {
-                                    var sam = m_MeasureApp.m_SamplepaceWindow.GetWorkingVisualSample();
-                                    m_MeasureApp.m_SamplepaceWindow.ChangeDoneMeasureState(sam,SMsrData.STMSampleRetData.SMsrField.FieldPos, Color.Yellow);
-                                   
-                                    m_MeasureApp.m_SamplepaceWindow.Invalidate();
-                                }
-                                break;
-                        }
-                        break;
-                }
-            }
-            catch (Exception ex)
-            {
-               log.Error("RunMeasureState--The error message:" + ex.ToString()); 
+                        m_MeasureApp.m_SamplepaceWindow.Invalidate();
+                   
+                    //设置开始时间
+                  
+                m_OTSMeasureResultWindow.SetStartTime(csSampleMsrStartTime);
             }
+            
+            //切换样品
+            m_MeasureApp.SwitchWSample(sampleName);
+            //设置样品名称
+            m_OTSMeasureResultWindow.SetSampleName(sampleName);
         }
 
+        public void MeasureStopped(ST_MSTMsg SMsrData)
+        {
+            string stopEndTime = SMsrData.STMThreadStu.csMsrEndTime;
+            //打开测量结果窗口
+            SetMeasureResultInfo(SMsrData);
+            MeasureResultMsrData = SMsrData;
+            m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
+            //激活跳转至报告程序按钮
+            m_MeasureApp.rbPReport.Enabled = true;
+            m_MeasureApp.rbReport.Enabled = true;
+            //测量停止,更新Grid显示的测量信息
+            //获取需显示的grid信息
+            var sample = m_MeasureApp.m_ProjParam.GetWorkSample();
+            var stype = m_MeasureApp.m_ProjParam.GetDefaultParam().GetSysType();
+            OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype);
+            m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
+        }
+
+        public void MeasureFailed(ST_MSTMsg SMsrData)
+        {
+            string failedEndTime = SMsrData.STMThreadStu.csMsrEndTime;
+            SetMeasureResultInfo(SMsrData);
+            MeasureResultMsrData = SMsrData;
+            m_bgWorker.ReportProgress((int)ProgressState.MeasureCheckReport, SMsrData);
+
+
+
+            //测量失败,更新Grid显示的测量信息
+            //获取需显示的grid信息
+            var sample = m_MeasureApp.m_ProjParam.GetWorkSample();
+            var stype = m_MeasureApp.m_ProjParam.GetDefaultParam().GetSysType();
+            OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype);
+            m_MeasureApp.m_SPropertyWindows.DisplaySampleMeasureInfo(MeasureInfo);
+        }
 
         #endregion
 

+ 2 - 1
OTSIncAMeasureApp/OTSIncAMeasureApp.csproj

@@ -277,6 +277,7 @@
     <Compile Include="1-OTSMeasure\Measure\3-MeasureFlow\CSmplMeasure.cs" />
     <Compile Include="1-OTSMeasure\Measure\3-MeasureFlow\CSmplMsrResult.cs" />
     <Compile Include="1-OTSMeasure\Measure\3-MeasureFlow\MsrThreadStatus.cs" />
+    <Compile Include="1-OTSMeasure\Measure\3-MeasureFlow\ST_MSTMsg.cs" />
     <Compile Include="1-OTSMeasure\Measure\4-ReMeasure\SmplMeasureReMeasure.cs" />
     <Compile Include="1-OTSMeasure\Measure\BSEPicData\BSEImgFileMgr.cs" />
     <Compile Include="1-OTSMeasure\Measure\BSEPicData\COTSFieldData.cs" />
@@ -484,7 +485,7 @@
     </Compile>
     <Compile Include="5-OTSMeasureStatuImageFun\ExcelEdit.cs" />
     <Compile Include="1-OTSMeasure\OTSMeasureDisplayResult.cs" />
-    <Compile Include="1-OTSMeasure\CMeasureThreadWrapper.cs" />
+    <Compile Include="1-OTSMeasure\Measure\3-MeasureFlow\CMeasureThreadWrapper.cs" />
     <Compile Include="7-OTSProgMgrInfo\ProgMgrInfoForm.cs">
       <SubType>Form</SubType>
     </Compile>

+ 1 - 9
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -1032,16 +1032,8 @@ namespace OTSMeasureApp
                 return false;
             }
 
-
             OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
-            //if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
-            //{
-            //    log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample)  m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
-            //    return false;
-            //}
-
-            // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
-
+   
             m_SolutionWindows.SwitchSample(sMsrSampleName);
             m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
 

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

@@ -301,23 +301,6 @@ namespace OTSModelSharp.ServiceCenter
             
         }
 
-      
-
-        //public bool Connect()
-        //{
-           
-        //        //if (!eds.Init())
-        //        //{
-        //        //    return false;
-        //        //}
-        //        if (eds.IsConnected())
-        //        {
-        //            return true;
-        //        }
-
-        //        return eds.ConncetSem();
-           
-        //}
 
         public EDSTYPE GetEDSType()
         {