Browse Source

optimize the otscontrol dll api.(don't call the disconnect method in the measure app except the main measure flow.)

shiyanshi 3 years ago
parent
commit
ffa962d6f6

+ 19 - 12
OTSIncAMeasureApp/0-OTSModel/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -44,6 +44,8 @@ namespace OTSModelSharp
             // second step :filter the finded particles.
             log.Info("Begin to filter particles!");
             FilterParticles();
+
+            CalculateParticlePos();
       
             if (pXRayParam.GetUsingXray() == (int)OTS_USING_X_RAY.Yes)
             {
@@ -129,18 +131,8 @@ namespace OTSModelSharp
             COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
             curFldData.FilterParticles(pImgProcessParam, dPixelSize );
 
-          //calculate the real sem position of the particle
-            CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
-            foreach (var p in curFldData.ListAnalysisParticles)
-            {
-                var r = (Rectangle)p.GetParticleRect();
-                Point fldLeftTopOTSPos = new Point(curFldData.PoiPos.X - curFldData.Width / 2, curFldData.PoiPos.Y + curFldData.Height / 2);//OTS coordinate
-                Point Partcenter = new Point(r.Top + r.Height / 2, r.Left + r.Width / 2);//screen coordinate
-                Point otsPartCenter = new Point((int)(fldLeftTopOTSPos.X + Partcenter.X * dPixelSize), (int)(fldLeftTopOTSPos.Y + Partcenter.Y * dPixelSize));
-                Point sempoint = new Point();
-                pCSEMStageData.ConverOTSToSEMPoint(otsPartCenter, ref sempoint);
-                p.SetAbsolutPos(sempoint);
-            }
+         
+     
             // make sure the particles list is not empty
             if (curFldData.NoAnalysisParticle())
             {
@@ -149,6 +141,21 @@ namespace OTSModelSharp
             }
             return ;
         }
+        //calculate the real sem position of the particle
+        public void CalculateParticlePos()
+        {
+            double dPixelSize = m_Sample.CalculatePixelSize();
+            CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
+            foreach (var p in curFldData.ListAnalysisParticles)
+            {
+               
+                Point fldOtsPos = new Point(curFldData.PoiPos.X, curFldData.PoiPos.Y);
+                Point semPos = new Point();
+                pCSEMStageData.ConverOTSToSEMPoint(fldOtsPos, ref semPos);
+                p.SetAbsolutPos(semPos);
+            }
+
+        }
 
         public void CollectParticlesXrayData()
         {

+ 1 - 0
OTSIncAMeasureApp/0-OTSModel/Measure/GetBSEPic/COTSFieldData.cs

@@ -116,6 +116,7 @@ namespace OTSModelSharp
             m_ImagePro = new CImageHandler();
             foreach (COTSParticleClr part in particles)
             {
+               
                 m_ImagePro.CalParticleImageProp( part, m_pixelSize);
             }
             return true;

+ 11 - 49
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -3575,7 +3575,7 @@ namespace OTSMeasureApp
                     CMStrip.Items[(int)MenuIndex.SetSemData].Enabled = true;
                     
                 }
-                m_SEMDATAFieldManage.CloseSEM();
+              
               
             }
            
@@ -3905,8 +3905,7 @@ namespace OTSMeasureApp
         public bool SetSEMDATAMParameter(double magnification, double semWorkingDistance)
         {
             #region 获取电镜参数
-            //电镜设置对象
-            //COTSControlFunExport cfun = new COTSControlFunExport();
+          
 
             //获取Field操作类对象
             if (m_SEMDATAFieldManage == null)
@@ -3920,17 +3919,10 @@ namespace OTSMeasureApp
                 List<double> semParameters = m_SEMDATAFieldManage.GetSEMMagAndWDParameter();
                 bool mFlag = false;
                 bool wFlag = false;
-                //放大倍数
-                //mFlag = cfun.SetSemMagnification(magnification);
-                //wFlag = cfun.SetSemWorkingDistance(semWorkingDistance);
-                //if  (wFlag)
-                //{
-                //    MessageBox.Show(cfun.GetMagnification().ToString());
-                //}
+         
                 mFlag = m_SEMDATAFieldManage.SetSEMMagnificationParameter(magnification);
                 wFlag = m_SEMDATAFieldManage.SetSEMWorkingDistanceParameter(semWorkingDistance);
-                //关闭电镜连接
-                m_SEMDATAFieldManage.CloseSEM();
+          
                
                 if (mFlag || wFlag)
                 {
@@ -3957,8 +3949,7 @@ namespace OTSMeasureApp
                 //放大倍数
                 magnification = semParameters[0];
                 WorkingDistance = semParameters[1];
-                //关闭电镜连接
-                m_SEMDATAFieldManage.CloseSEM();
+           
                
                 return true;
             }
@@ -4038,8 +4029,7 @@ namespace OTSMeasureApp
         #region   驱动SEM到当前位置
         public bool SetSEMCurrentLocation()
         {
-            //try
-            //{
+           
                 bool bret=false;
                 //获取Field操作类对象
                 if (m_SEMDATAFieldManage == null)
@@ -4051,18 +4041,12 @@ namespace OTSMeasureApp
                 {
                      bret = m_SEMDATAFieldManage.SetSEMCurrentLocation(m_MouseDownLocation, m_RectangleGDIObjects, m_OTSSampleStageData, IsWidth, Width, Height);
 
-                     m_SEMDATAFieldManage.CloseSEM();
+                  
                 }
            
                 return bret;
                 
-            //}
-            //catch (Exception ex)
-            //{
-            //    //string message = table["message3"].ToString();
-            //    log.Error("OTSSamplespaceWindow_" + message + ":" + ex.ToString() + "");
-            //    //return false;
-            //}
+         
         }
         #endregion
 
@@ -4082,8 +4066,7 @@ namespace OTSMeasureApp
                 {
                     bret = (m_SEMDATAFieldManage.DriveSEMToLocation(m_MouseDownLocation, m_RectangleGDIObjects, m_SingleGDIObjects, m_OTSSampleStageData, IsWidth, Width, Height));
 
-                    //关闭电镜连接
-                    m_SEMDATAFieldManage.CloseSEM();
+              
                        
                     
                 }
@@ -4114,7 +4097,7 @@ namespace OTSMeasureApp
                 {
                      bret = m_SEMDATAFieldManage.GetSemLocation(ref SemLocation);
                     
-                    m_SEMDATAFieldManage.CloseSEM();
+                   
 
                 }
             return bret;
@@ -4191,28 +4174,7 @@ namespace OTSMeasureApp
         }
         #endregion
 
-        #region 关闭电镜连接
-        public bool CloseSEM()
-        {
-            if (m_SEMDATAFieldManage == null)
-            {
-                m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
-            }
-            //关闭电镜连接
-            bool result = m_SEMDATAFieldManage.CloseSEM();
-            return result;
-        }
-        public bool CloseSEM(SEMDATAFieldManage m_SEMDATAFieldManage)
-        {
-            bool result = false;
-            if (m_SEMDATAFieldManage != null)
-            {
-                //关闭电镜连接
-                result = m_SEMDATAFieldManage.CloseSEM();
-            }
-            return result;
-        }
-        #endregion
+      
 
         #region 显示标尺
         /// <summary>

+ 13 - 13
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/SEMDATAFieldManage.cs

@@ -83,19 +83,19 @@ namespace OTSMeasureApp
  
 
         #region 关闭电镜连接
-        public bool CloseSEM()
-        {
-            try
-            {
-                cSemfun.DisConnect();
-                return true;
-            }
-            catch (Exception ex)
-            {
-                log.Error("CloseSEM:--Error:" + ex.ToString() + "");
-                return false;
-            }
-        }
+        //public bool CloseSEM()
+        //{
+        //    try
+        //    {
+        //        cSemfun.DisConnect();
+        //        return true;
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        log.Error("CloseSEM:--Error:" + ex.ToString() + "");
+        //        return false;
+        //    }
+        //}
         #endregion
 
         #region 获取放大倍数