Selaa lähdekoodia

更新测量线程,与韩联调。

@wang_qi0307 5 vuotta sitten
vanhempi
commit
fb5c2565e1
2 muutettua tiedostoa jossa 91 lisäystä ja 30 poistoa
  1. 2 2
      HOZProject/Program.cs
  2. 89 28
      MeasureThread/Measure.cs

+ 2 - 2
HOZProject/Program.cs

@@ -17,9 +17,9 @@ namespace HOZProject
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             //Application.Run(new FormUCMain());
-            //Application.Run(new FormHOZMain());
+            Application.Run(new FormHOZMain());
             //Application.Run(new FormMeasureTest());
-            Application.Run(new FormUnitControl());
+            //Application.Run(new FormUnitControl());
         }
     }
 }

+ 89 - 28
MeasureThread/Measure.cs

@@ -33,12 +33,12 @@ namespace MeasureThread
     public class ThreadStatusEventArgs
     {
         //状态
-        public string State
+        public Boolean State
         {
             get { return m_state; }
             set { m_state = value; }
         }
-        private string m_state;
+        private Boolean m_state;
         //时间
         public DateTime Time
         {
@@ -802,35 +802,33 @@ namespace MeasureThread
             {
                 if (DialogResult.Yes == MessageBox.Show("图像自动对焦已完成?", "确认消息", MessageBoxButtons.YesNo))
                 {
-                    return true;
                 }
                 else
                 {
                     return false;
                 }
             }
-            else if (m_measureFile.MParam.FocusMode == 2)//自有自动
+            else if(m_measureFile.MParam.FocusMode == 2)//自有自动
             {
                 //郝工增加自动对焦算法
                 //处理文件夹
-                if(Directory.Exists(focus_path))
+                if (Directory.Exists(focus_path))
                 {
-                    Directory.Delete(focus_path,true);
+                    Directory.Delete(focus_path, true);
                 }
                 Directory.CreateDirectory(focus_path);
                 //1、对焦参数类,2、输出工作距离
                 int wd = 0;
                 AutoFocus(m_MsParam.AutoFocus, out wd);
 
-                LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
+                //LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
                 //设置工作距离
                 iSEM.SetWorkingDistance((float)(wd * 0.00000001));
 
-                return true;
                 //处理图片位置
                 //File.Copy(focus_path + "\\fine\\" + wd.ToString() + ".tif", data_path + "\\" + ImageName);
             }
-            else if (m_MsParam.FocusMode == 3)     //客户自动
+            else if(m_MsParam.FocusMode == 3)     //客户自动
             {
                 //后期和客户对接接口
                 List<string> filenames = new List<string>();
@@ -853,13 +851,15 @@ namespace MeasureThread
             int state = 0;
 
             //1.控制SEM放大600X
-            arg.State = "SEM";
+            arg.Picture_Information.Work_Status = "FIB";
             if (!iSEM.SetMagnification(m_measureFile.MParam.Location_Magnification))
             {
                 arg.Message = "放大" + m_measureFile.MParam.Location_Magnification.ToString("0.0") + "倍失败";
+                arg.State = false;
                 SendMsg("1-1");
                 return false;
             }
+            arg.State = true;
             arg.Message = "放大" + m_measureFile.MParam.Location_Magnification.ToString("0.0") + "倍成功";
             SendMsg("1-1");
             //判断是否停止进程
@@ -872,11 +872,13 @@ namespace MeasureThread
             if(ImageFocus())
             {
                 arg.Message = "自动对焦完成";
+                arg.State = true;
                 SendMsg("1-2");
             }
             else
             {
                 arg.Message = "自动对焦失败";
+                arg.State = false;
                 SendMsg("1-2");
             }
             //判断是否停止进程
@@ -891,9 +893,11 @@ namespace MeasureThread
                 if (!TiltCorrection(54))
                 {
                     arg.Message = "设置SEM进行角度补偿54度失败";
+                    arg.State = false;
                     SendMsg("1-3");
                     return false;
                 }
+                arg.State = true;
                 arg.Message = "设置SEM进行角度补偿54度成功";
                 SendMsg("1-3");
                 Thread.Sleep(5000);
@@ -917,9 +921,11 @@ namespace MeasureThread
             if (!GetImage(ImageMode.SEM, fileName1))
             {
                 arg.Message = "SEM拍照失败";
-                SendMsg("1-5");
+                arg.State = false;
+                SendMsg("1-4");
                 return false;
             }
+            arg.State = true;
             arg.Message = "SEM拍照成功";
             SendMsg("1-4");
             Thread.Sleep(3000);
@@ -937,10 +943,12 @@ namespace MeasureThread
                 if (!iSEM.CmdFIBModeFIB())
                 {
                     arg.Message = "FIB模式切换失败";
+                    arg.State = false;
                     SendMsg("1-5");
                     return false;
                 }
-                arg.State = "FIB";
+                arg.State = true;
+                arg.Picture_Information.Work_Status = "FIB";
                 arg.Message = "FIB模式切换成功";
                 SendMsg("1-5");
                 Thread.Sleep(10000);
@@ -964,9 +972,11 @@ namespace MeasureThread
                 if (!GetImage(ImageMode.FIB, fileName2))
                 {
                     arg.Message = "FIB拍照失败";
+                    arg.State = false;
                     SendMsg("1-6");
                     return false;
                 }
+                arg.State = true;
                 arg.Message = "FIB拍照成功";
                 SendMsg("1-6");
                 Thread.Sleep(3000);
@@ -980,6 +990,7 @@ namespace MeasureThread
                 if (DialogResult.Yes == MessageBox.Show("是否手动移动样品台到指定位置?\n如果点击取消则会调用Web接口。", "确认消息", MessageBoxButtons.YesNo))
                 {
                     arg.Message = "样品台移动到指定位置";
+                    arg.State = true;
                     SendMsg("1-7");
                 }
                 else
@@ -991,6 +1002,7 @@ namespace MeasureThread
                         if (!iSEM.MoveStageXY(x1, y1))
                         {
                             arg.Message = "移动到新(" + x1.ToString() + "," + y1.ToString() + ")位置失败";
+                            arg.State = false;
                             SendMsg("1-7");
                             return false;
                         }
@@ -1004,11 +1016,13 @@ namespace MeasureThread
                             }
                         }
                         arg.Message = "移动到新(" + x1.ToString() + "," + y1.ToString() + ")位置失败";
+                        arg.State = true;
                         SendMsg("1-7");
                     }
                     else
                     {
                         arg.Message = "样品台移动失败";
+                        arg.State = false;
                         SendMsg("1-7");
                         return false;
                     }
@@ -1030,9 +1044,11 @@ namespace MeasureThread
                     if (Math.Abs(x0 - x1) > fMin && Math.Abs(y0 - y1) > fMin)
                     {
                         arg.Message = "目标位置(" + x0.ToString() + "," + y0.ToString() + ")移动失败";
+                        arg.State = false;
                         SendMsg("1-8");
                         return false;
                     }
+                    arg.State = true;
                     arg.Message = "目标位置(" + x0.ToString() + "," + y0.ToString() + ")移动成功";
                     SendMsg("1-8");
                     //判断是否停止进程
@@ -1045,9 +1061,11 @@ namespace MeasureThread
                     if (!PTWork())
                     {
                         arg.Message = "PT沉积失败";
+                        arg.State = false;
                         SendMsg("1-9");
                         return false;
                     }
+                    arg.State = true;
                     arg.Message = "PT沉积成功";
                     SendMsg("1-9");
                     //判断是否停止进程
@@ -1078,6 +1096,7 @@ namespace MeasureThread
                 + firstPosition[3].ToString() + ","
                 + firstPosition[4].ToString() + ","
                 + firstPosition[5].ToString() + ")";
+            arg.State = true;
             SendMsg("1-10");
             //判断是否停止进程
             if (key_stop)
@@ -1107,9 +1126,11 @@ namespace MeasureThread
             if (!GetImage(ImageMode.FIB, fileName31))
             {
                 arg.Message = "FIB切割前拍照失败";
+                arg.State = false;
                 SendMsg("1-11");
                 return false;
             }
+            arg.State = true;
             arg.Message = "FIB切割前拍照成功";
             SendMsg("1-11");
             //判断是否停止进程
@@ -1125,9 +1146,11 @@ namespace MeasureThread
             if (!FIBWork())
             {
                 arg.Message = "FIB切割失败";
+                arg.State = false;
                 SendMsg("1-12");
                 return false;
             }
+            arg.State = true;
             arg.Message = "FIB切割成功";
             SendMsg("1-12");
             Thread.Sleep(5000);
@@ -1152,9 +1175,11 @@ namespace MeasureThread
             if (!GetImage(ImageMode.FIB, fileName32))
             {
                 arg.Message = "FIB切割后拍照失败";
+                arg.State = false;
                 SendMsg("1-13"); 
                 return false;
             }
+            arg.State = true;
             arg.Message = "FIB切割后拍照成功";
             SendMsg("1-13");
 
@@ -1170,9 +1195,11 @@ namespace MeasureThread
             if(state == 0)
             {
                 arg.Message = "FIB切割校验失败";
+                arg.State = false;
                 SendMsg("1-14");
                 return false;
             }
+            arg.State = true;
             arg.Message = "FIB切割校验成功";
             SendMsg("1-14");
             //判断是否停止进程
@@ -1200,12 +1227,14 @@ namespace MeasureThread
             if (!iSEM.CmdFIBModeSEM())
             {
                 arg.Message = "SEM模式切换失败";
+                arg.State = false;
                 SendMsg("1-16");
                 return false;
             }
+            arg.State = false;
             arg.Message = "SEM模式切换成功";
             SendMsg("1-16");
-            arg.State = "SEM";
+            arg.Picture_Information.Work_Status = "SEM";
             Thread.Sleep(10000);
             //判断是否停止进程
             if (key_stop)
@@ -1217,9 +1246,11 @@ namespace MeasureThread
             if (!iSEM.SetMagnification(m_measureFile.MParam.Location_Magnification/2))
             {
                 arg.Message = "放大" + (m_measureFile.MParam.Location_Magnification / 2).ToString("0.0") + "倍失败";
+                arg.State = false;
                 SendMsg("1-17");
                 return false;
             }
+            arg.State = false;
             arg.Message = "放大" + (m_measureFile.MParam.Location_Magnification/2).ToString("0.0") + "倍成功";
             SendMsg("1-17");
             //判断是否停止进程
@@ -1232,11 +1263,13 @@ namespace MeasureThread
             if (ImageFocus())
             {
                 arg.Message = "自动对焦完成";
+                arg.State = true;
                 SendMsg("1-18");
             }
             else
             {
                 arg.Message = "自动对焦失败";
+                arg.State = false;
                 SendMsg("1-18");
             }
             Thread.Sleep(5000);
@@ -1258,10 +1291,12 @@ namespace MeasureThread
             Thread.Sleep(1000);
             if (!GetImage(ImageMode.SEM, fileName4))
             {
+                arg.State = false;
                 arg.Message = "SEM拍照失败";
                 SendMsg("1-19");
                 return false;
             }
+            arg.State = true;
             arg.Message = "SEM拍照成功";
             SendMsg("1-19");
 
@@ -1277,6 +1312,7 @@ namespace MeasureThread
             //这里是否用到拉直操作,我没有加
             if (DialogResult.Yes == MessageBox.Show("是否手动移动样品台到指定位置?\n如果点击取消则会调用Web接口。", "确认消息", MessageBoxButtons.YesNo))
             {
+                arg.State = true;
                 arg.Message = "样品台移动到指定位置";
                 SendMsg("1-20");
             }
@@ -1291,6 +1327,7 @@ namespace MeasureThread
                     //1. 根据客户PT沉积坐标控制FIB调整到中心位置???????
                     if (!iSEM.MoveStageXY(x2, y2))
                     {
+                        arg.State = false;
                         arg.Message = "移动到新(" + x1.ToString() + "," + y1.ToString() + ")位置失败";
                         SendMsg("1-20");
                         return false;
@@ -1304,6 +1341,7 @@ namespace MeasureThread
                             break;
                         }
                     }
+                    arg.State = true;
                     arg.Message = "移动到新(" + x2.ToString() + "," + y2.ToString() + ")位置失败";
                     SendMsg("1-20");
                     
@@ -1311,6 +1349,7 @@ namespace MeasureThread
                 else
                 {
                     arg.Message = "样品台移动失败";
+                    arg.State = false;
                     SendMsg("1-20");
                     return false;
                 }
@@ -1327,9 +1366,11 @@ namespace MeasureThread
             if (Math.Abs(x0 - x1) > fMin && Math.Abs(y0 - y1) > fMin)
             {
                 arg.Message = "位置校验失败";
+                arg.State = false;
                 SendMsg("1-21");
                 return false;
             }
+            arg.State = true;
             arg.Message = "位置校验成功";
             SendMsg("1-21");
 
@@ -1356,10 +1397,12 @@ namespace MeasureThread
             if (!iSEM.SetMagnification(m_MsParam.Photograph_Magnification))
             {
                 arg.Message = "放大倍数调整失败";
+                arg.State = false;
                 SendMsg("1-22");
                 return false;
             }
             arg.Message = "放大倍数调整成功";
+            arg.State = true;
             SendMsg("1-22");
             //判断是否停止进程
             if (key_stop)
@@ -1371,11 +1414,13 @@ namespace MeasureThread
             if (ImageFocus())
             {
                 arg.Message = "自动对焦完成";
+                arg.State = true;
                 SendMsg("1-23");
             }
             else
             {
                 arg.Message = "自动对焦失败";
+                arg.State = false;
                 SendMsg("1-23");
             }
             //判断是否停止进程
@@ -1388,9 +1433,11 @@ namespace MeasureThread
             if (!TiltCorrection(m_measureFile.MParam.Correction_Angle))
             {
                 arg.Message = "设置SEM进行角度补偿" + m_measureFile.MParam.Correction_Angle.ToString("0") + "度失败";
+                arg.State = false;
                 SendMsg("1-24");
                 return false;
             }
+            arg.State = true;
             arg.Message = "设置SEM进行角度补偿" + m_measureFile.MParam.Correction_Angle.ToString("0") + "度成功";
             SendMsg("1-24");
             Thread.Sleep(5000);
@@ -1413,9 +1460,11 @@ namespace MeasureThread
             if (!GetImage(ImageMode.SEM, fileName5))
             {
                 arg.Message = "SEM拍照失败";
+                arg.State = false;
                 SendMsg("1-25");
                 return false;
             }
+            arg.State = true;
             arg.Message = "SEM拍照成功";
             SendMsg("1-25");
             Thread.Sleep(3000);
@@ -1429,6 +1478,7 @@ namespace MeasureThread
             if (DialogResult.Yes == MessageBox.Show("是否手动移动样品台到指定位置?\n如果点击取消则会调用Web接口。", "确认消息", MessageBoxButtons.YesNo))
             {
                 arg.Message = "样品台移动到指定位置";
+                arg.State = true;
                 SendMsg("1-26");
             }
             else
@@ -1442,6 +1492,7 @@ namespace MeasureThread
                     if (!iSEM.MoveStageXY(x1, y1))
                     {
                         arg.Message = "移动到新(" + x1.ToString() + "," + y1.ToString() + ")位置失败";
+                        arg.State = false;
                         SendMsg("1-26");
                         return false;
                     }
@@ -1454,12 +1505,14 @@ namespace MeasureThread
                             break;
                         }
                     }
+                    arg.State = true;
                     arg.Message = "移动到新(" + x1.ToString() + "," + y1.ToString() + ")位置失败";
                     SendMsg("1-26");
                 }
                 else
                 {
                     arg.Message = "样品台移动失败";
+                    arg.State = false;
                     SendMsg("1-26");
                     return false;
                 }
@@ -1476,9 +1529,11 @@ namespace MeasureThread
             if (Math.Abs(x0 - x1) > fMin && Math.Abs(y0 - y1) > fMin)
             {
                 arg.Message = "位置校验失败";
+                arg.State = false;
                 SendMsg("1-27");
                 return false;
             }
+            arg.State = true;
             arg.Message = "位置校验成功";
             SendMsg("1-27");
             //判断是否停止进程
@@ -1492,11 +1547,13 @@ namespace MeasureThread
             if (ImageFocus())
             {
                 arg.Message = "自动对焦完成";
+                arg.State = true;
                 SendMsg("1-28");
             }
             else
             {
                 arg.Message = "自动对焦失败";
+                arg.State = false;
                 SendMsg("1-28");
             }
             //判断是否停止进程
@@ -1518,9 +1575,11 @@ namespace MeasureThread
             if (!GetImage(ImageMode.SEM, fileName6))
             {
                 arg.Message = "SEM拍照失败";
+                arg.State = false;
                 SendMsg("1-29");
                 return false;
             }
+            arg.State = true;
             image18 = fileName6;
             arg.Message = "SEM拍照成功";
             SendMsg("1-29");
@@ -1535,6 +1594,7 @@ namespace MeasureThread
             iSEM.SetBeamShiftY(0);
             Thread.Sleep(3000);
             arg.Message = "光束复位成功";
+            arg.State = true;
             SendMsg("1-30");
             //判断是否停止进程
             if (key_stop)
@@ -1550,7 +1610,7 @@ namespace MeasureThread
             MeasureData.CutHole firstHole = m_cutHoles[0];
 
             //首先默认为SEM模式
-            arg.State = "SEM";
+            arg.Picture_Information.Work_Status = "SEM";
             //12.根据样品类型参数确定是否需要PT沉积,控制PT针插入
             if (m_MsParam.Is_Photograph == false && m_MsParam.PT == true)
             {
@@ -1845,7 +1905,7 @@ namespace MeasureThread
         public bool CommonWork()
         {
             //首先默认为SEM模式
-            arg.State = "SEM";
+            arg.Picture_Information.Work_Status = "SEM";
             //12.根据样品类型参数确定是否需要PT沉积,控制PT针插入
             if (m_MsParam.Is_Photograph == false && m_MsParam.PT == true)
             {
@@ -2250,7 +2310,8 @@ namespace MeasureThread
         public bool AutoFocus(FocusParam a_param, out int a_nWd)
         {
             a_nWd = 0;
-            a_nWd = (int)Math.Ceiling(iSEM.GetWorkingDistance() * 100000000 + 0.5);//获取当前的工作距离
+            float wd = iSEM.GetWorkingDistance();
+            a_nWd = (int)Math.Ceiling(wd * 100000000 + 0.5);//获取当前的工作距离
 
             if (a_param == null)
             {
@@ -2282,7 +2343,7 @@ namespace MeasureThread
             double nStep = a_param.Step * 100.0;
             double nTimes = Math.Ceiling((nDown - nUp) / nStep + 0.5);
 
-            SendMsg("粗对焦:最小值" + nUp.ToString() + ",最大值" + nDown.ToString() + ",步长" + nStep.ToString() + "拍照张数" + nTimes.ToString());
+            //SendMsg("粗对焦:最小值" + nUp.ToString() + ",最大值" + nDown.ToString() + ",步长" + nStep.ToString() + "拍照张数" + nTimes.ToString());
             
             //粗拍照
             for (int i = 0; i < nTimes; i++)
@@ -2293,7 +2354,7 @@ namespace MeasureThread
                 Thread.Sleep(8000);
 
                 int swd = cWd / 100;
-                SendMsg("wd = " + swd.ToString() +"um");
+                //SendMsg("wd = " + swd.ToString() +"um");
 
                 String fileName = path_coarse + "\\" + cWd.ToString() + ".tif";
                 if (!GetImage(ImageMode.SEM, fileName))
@@ -2310,7 +2371,7 @@ namespace MeasureThread
 
             a_nWd = CorWd;
 
-            SendMsg("粗选工作距离wd = " + a_nWd.ToString() );
+            //SendMsg("粗选工作距离wd = " + a_nWd.ToString() );
             
 
             //1.3, 细拍照
@@ -2324,7 +2385,7 @@ namespace MeasureThread
             double nfTimes = Math.Ceiling((a_param.Range * 100.0 * 2) / nfStep + 0.5);
 
 
-            SendMsg("粗对焦:最小值" + nfUp.ToString()  + ",步长" + nfStep.ToString() + "拍照张数" + nfTimes.ToString());
+            //SendMsg("粗对焦:最小值" + nfUp.ToString()  + ",步长" + nfStep.ToString() + "拍照张数" + nfTimes.ToString());
 
             
             for (int i = 0; i < nfTimes; i++)
@@ -2334,7 +2395,7 @@ namespace MeasureThread
                 Thread.Sleep(8000);
 
                 int swd = cWd / 100;
-                SendMsg("wd = " + swd.ToString() + "um");
+                //SendMsg("wd = " + swd.ToString() + "um");
 
                 String fileName = path_fine + "\\" + cWd.ToString() + ".tif";
                 if (!GetImage(ImageMode.SEM, fileName))
@@ -2348,11 +2409,11 @@ namespace MeasureThread
             int fineWd;
             ChooseBest(path_fine, out fineWd);
 
-            SendMsg("wd fine max = " + fineWd.ToString());
+            //SendMsg("wd fine max = " + fineWd.ToString());
 
             a_nWd = fineWd;
 
-            SendMsg("细选工作距离wd = " + a_nWd.ToString());
+            //SendMsg("细选工作距离wd = " + a_nWd.ToString());
 
             return true;
 
@@ -2499,27 +2560,27 @@ namespace MeasureThread
                 x++;
             }
 
-            SendMsg("LoG = " + wdmax1.ToString() + ",梯度 = " + wdmax2.ToString() + ",滤波 = " + wdmax3.ToString());
+            //SendMsg("LoG = " + wdmax1.ToString() + ",梯度 = " + wdmax2.ToString() + ",滤波 = " + wdmax3.ToString());
 
 
             if (wdmax1 == wdmax2 || wdmax1 == wdmax3)
             {
                 a_nWd = wdmax1;
-                SendMsg("焦距 = " + wdmax1.ToString());
+                //SendMsg("焦距 = " + wdmax1.ToString());
             }
             else if (wdmax1 == wdmax2 || wdmax2 == wdmax3)
             {
                 a_nWd = wdmax2;
-                SendMsg("焦距 = " + wdmax2.ToString());
+                //SendMsg("焦距 = " + wdmax2.ToString());
             }
             else if (wdmax3 == wdmax2 || wdmax1 == wdmax3)
             {
                 a_nWd = wdmax3;
-                SendMsg("焦距 = " + wdmax3.ToString());
+                //SendMsg("焦距 = " + wdmax3.ToString());
             }
             else
             {
-                SendMsg("对焦失败。");
+                //SendMsg("对焦失败。");
             }
         }
     }