Browse Source

20200918科大测试

@wang_qi0307 5 năm trước cách đây
mục cha
commit
69892bbab8

+ 59 - 46
HOZProject/FormUnitControl.Designer.cs

@@ -107,6 +107,10 @@
             this.btnMILL = new System.Windows.Forms.Button();
             this.btnFIB = new System.Windows.Forms.Button();
             this.panelSEM = new System.Windows.Forms.Panel();
+            this.button1 = new System.Windows.Forms.Button();
+            this.txtVoltage = new System.Windows.Forms.TextBox();
+            this.button2 = new System.Windows.Forms.Button();
+            this.label67 = new System.Windows.Forms.Label();
             this.btnScanRotationSetOn = new System.Windows.Forms.Button();
             this.btnTiltAngleSetOn = new System.Windows.Forms.Button();
             this.panelFIB = new System.Windows.Forms.Panel();
@@ -289,10 +293,7 @@
             this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
             this.lblPs1 = new System.Windows.Forms.Label();
             this.btnPsFile = new System.Windows.Forms.Button();
-            this.button1 = new System.Windows.Forms.Button();
-            this.txtVoltage = new System.Windows.Forms.TextBox();
-            this.button2 = new System.Windows.Forms.Button();
-            this.label67 = new System.Windows.Forms.Label();
+            this.button3 = new System.Windows.Forms.Button();
             this.panelControl.SuspendLayout();
             this.panelSEM.SuspendLayout();
             this.panelFIB.SuspendLayout();
@@ -1190,6 +1191,50 @@
             this.panelSEM.Size = new System.Drawing.Size(780, 509);
             this.panelSEM.TabIndex = 47;
             // 
+            // button1
+            // 
+            this.button1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button1.Location = new System.Drawing.Point(693, 365);
+            this.button1.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(54, 34);
+            this.button1.TabIndex = 97;
+            this.button1.Text = "写";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // txtVoltage
+            // 
+            this.txtVoltage.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
+            this.txtVoltage.Location = new System.Drawing.Point(551, 367);
+            this.txtVoltage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+            this.txtVoltage.Name = "txtVoltage";
+            this.txtVoltage.Size = new System.Drawing.Size(85, 30);
+            this.txtVoltage.TabIndex = 96;
+            this.txtVoltage.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+            // 
+            // button2
+            // 
+            this.button2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button2.Location = new System.Drawing.Point(640, 365);
+            this.button2.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(54, 34);
+            this.button2.TabIndex = 94;
+            this.button2.Text = "读";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // label67
+            // 
+            this.label67.AutoSize = true;
+            this.label67.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label67.Location = new System.Drawing.Point(469, 369);
+            this.label67.Name = "label67";
+            this.label67.Size = new System.Drawing.Size(72, 27);
+            this.label67.TabIndex = 95;
+            this.label67.Text = "电压:";
+            // 
             // btnScanRotationSetOn
             // 
             this.btnScanRotationSetOn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -2503,6 +2548,7 @@
             // 
             // tabPage3
             // 
+            this.tabPage3.Controls.Add(this.button3);
             this.tabPage3.Controls.Add(this.cbbWPZD);
             this.tabPage3.Controls.Add(this.cbbWPZF);
             this.tabPage3.Controls.Add(this.cbbWQGD);
@@ -3272,49 +3318,15 @@
             this.btnPsFile.UseVisualStyleBackColor = true;
             this.btnPsFile.Click += new System.EventHandler(this.btnPsFile_Click);
             // 
-            // button1
-            // 
-            this.button1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button1.Location = new System.Drawing.Point(693, 365);
-            this.button1.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(54, 34);
-            this.button1.TabIndex = 97;
-            this.button1.Text = "写";
-            this.button1.UseVisualStyleBackColor = true;
-            this.button1.Click += new System.EventHandler(this.button1_Click);
-            // 
-            // txtVoltage
+            // button3
             // 
-            this.txtVoltage.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
-            this.txtVoltage.Location = new System.Drawing.Point(551, 367);
-            this.txtVoltage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.txtVoltage.Name = "txtVoltage";
-            this.txtVoltage.Size = new System.Drawing.Size(85, 30);
-            this.txtVoltage.TabIndex = 96;
-            this.txtVoltage.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
-            // 
-            // button2
-            // 
-            this.button2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.button2.Location = new System.Drawing.Point(640, 365);
-            this.button2.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
-            this.button2.Name = "button2";
-            this.button2.Size = new System.Drawing.Size(54, 34);
-            this.button2.TabIndex = 94;
-            this.button2.Text = "读";
-            this.button2.UseVisualStyleBackColor = true;
-            this.button2.Click += new System.EventHandler(this.button2_Click);
-            // 
-            // label67
-            // 
-            this.label67.AutoSize = true;
-            this.label67.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label67.Location = new System.Drawing.Point(469, 369);
-            this.label67.Name = "label67";
-            this.label67.Size = new System.Drawing.Size(72, 27);
-            this.label67.TabIndex = 95;
-            this.label67.Text = "电压:";
+            this.button3.Location = new System.Drawing.Point(120, 149);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(132, 93);
+            this.button3.TabIndex = 76;
+            this.button3.Text = "button3";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
             // 
             // FormUnitControl
             // 
@@ -3609,6 +3621,7 @@
         private System.Windows.Forms.TextBox txtVoltage;
         private System.Windows.Forms.Button button2;
         private System.Windows.Forms.Label label67;
+        private System.Windows.Forms.Button button3;
     }
 }
 

+ 50 - 0
HOZProject/FormUnitControl.cs

@@ -1686,5 +1686,55 @@ namespace HOZProject
                 iSEM.SetSEMVoltage(set);
             }
         }
+
+        /// 图像拉直算法
+        /// </summary>
+        /// <param name="Slope">倾斜角度</param>
+        /// <param name="x0">圆心坐标x</param>
+        /// <param name="y0">圆心坐标y</param>
+        /// <param name="x1">倾斜情况下帧图的坐标x</param>
+        /// <param name="y1">倾斜情况下帧图的坐标y</param>
+        /// <param name="Hx">复位到原位置需要移动的x值(返回值)</param>
+        /// <param name="Hy">复位到原位置需要移动的y值(返回值)</param>
+        /// <returns></returns>
+        public bool Straightening(float Slope, float x0, float y0, float x1, float y1, ref float Hx, ref float Hy)
+        {
+            try
+            {
+                double xr = x1 - x0;//倾斜图到中心的距离差x
+                double yr = y1 - y0;//倾斜图到中心的距离差y
+                double R = Math.Sqrt(xr * xr + yr * yr);//圆心到倾斜图的长度
+                //double D = 2 * R * Math.Sin(ScanRotation / 2);//倾斜图与矫正图底边的长度
+                double k = Math.Atan(y1 / x1) / Math.PI * 180;//x1,y1的直角三角形圆心角度
+                double k_S = k - Slope;//通过夹角差求x2,y2
+                int y2 = (int)Math.Round(Math.Sin(Math.PI / (180 / k_S)) * R);
+                int x2 = (int)Math.Round(Math.Cos(Math.PI / (180 / k_S)) * R);
+
+                if (Slope > 0 || Slope < 0)
+                {
+                    Hx = x1 - x2;
+                    Hy = y1 - y2;
+                }
+                else
+                {
+                    Hx = 0;
+                    Hy = 0;
+                }
+
+                return true;
+            }
+            catch (Exception)
+            {
+                return false;
+            }
+        }
+
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            float x1 = 0, y1 = 0;
+            Straightening(5, 65, 65, (float)59.016, (float)58.837, ref x1, ref y1);
+            button3.Text = x1.ToString("0.00") + "\n" + y1.ToString("0.00");
+        }
     }
 }

+ 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());
         }
     }
 }

+ 11 - 8
MeasureThread/Measure.cs

@@ -578,6 +578,7 @@ namespace MeasureThread
                 SendMsg("开始测量。");
             }
 
+            LogManager.AddHardwareLog("开始测量",true);
 
             //检查硬件连接是否正常
             if (!ConnectHardware())
@@ -815,6 +816,8 @@ namespace MeasureThread
                 //1、对焦参数类,2、输出工作距离
                 int wd = 0;
                 AutoFocus(m_MsParam.AutoFocus, out wd);
+
+                LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
                 //设置工作距离
                 iSEM.SetWorkingDistance((float)(wd * 0.00000001));
                 //处理图片位置
@@ -865,7 +868,7 @@ namespace MeasureThread
             {
                 return false;
             }
-
+            
             //3.第一次不需要进行角度补偿,其他需要设置SEM进行角度补偿54度
             if (!isFirst)
             {
@@ -2179,14 +2182,14 @@ namespace MeasureThread
             double nTimes = Math.Ceiling((nDown - nUp) / nStep + 0.5);
 
             SendMsg("粗对焦:最小值" + nUp.ToString() + ",最大值" + nDown.ToString() + ",步长" + nStep.ToString() + "拍照张数" + nTimes.ToString());
-
+            
             //粗拍照
             for (int i = 0; i < nTimes; i++)
             {
 
                 int cWd =(int) Math.Ceiling(nUp + i * nStep + 0.5);
                 iSEM.SetWorkingDistance((float)(cWd * 0.00000001));
-                Thread.Sleep(3000);
+                Thread.Sleep(8000);
 
                 int swd = cWd / 100;
                 SendMsg("wd = " + swd.ToString() +"um");
@@ -2197,7 +2200,7 @@ namespace MeasureThread
                     return false;
                 }
 
-                Thread.Sleep(5000);
+                
             }
 
             //1.2, 选定细拍照的工作距离
@@ -2222,12 +2225,12 @@ namespace MeasureThread
 
             SendMsg("粗对焦:最小值" + nfUp.ToString()  + ",步长" + nfStep.ToString() + "拍照张数" + nfTimes.ToString());
 
-
+            
             for (int i = 0; i < nfTimes; i++)
             {
                 int cWd = (int)Math.Ceiling(nfUp + i * nfStep + 0.5);
                 iSEM.SetWorkingDistance((float)(cWd * 0.00000001));
-                Thread.Sleep(3000);
+                Thread.Sleep(8000);
 
                 int swd = cWd / 100;
                 SendMsg("wd = " + swd.ToString() + "um");
@@ -2238,11 +2241,11 @@ namespace MeasureThread
                     return false;
                 }
 
-                Thread.Sleep(5000);
+                
             }
 
             int fineWd;
-            ChooseBest(path_coarse, out fineWd);
+            ChooseBest(path_fine, out fineWd);
 
             SendMsg("wd fine max = " + fineWd.ToString());