소스 검색

Merge branch 'master' of http://192.168.1.123:10080/SDD1/HOZ

wb_han 5 년 전
부모
커밋
ec79b5486a

+ 26 - 0
AutoDo/AutoDo.csproj

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\build\OpenCvSharp3-AnyCPU.props" Condition="Exists('..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\build\OpenCvSharp3-AnyCPU.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,6 +14,8 @@
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
     <TargetFrameworkProfile />
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -34,8 +37,21 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+      <HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net461\OpenCvSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="OpenCvSharp.Blob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+      <HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net461\OpenCvSharp.Blob.dll</HintPath>
+    </Reference>
+    <Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+      <HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net461\OpenCvSharp.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="OpenCvSharp.UserInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
+      <HintPath>..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\lib\net461\OpenCvSharp.UserInterface.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Windows.Forms.DataVisualization" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
@@ -55,6 +71,9 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="FormAutoDo.resx">
+      <DependentUpon>FormAutoDo.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -65,6 +84,7 @@
       <DependentUpon>Resources.resx</DependentUpon>
       <DesignTime>True</DesignTime>
     </Compile>
+    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -79,4 +99,10 @@
     <None Include="App.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\build\OpenCvSharp3-AnyCPU.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenCvSharp3-AnyCPU.4.0.0.20181129\build\OpenCvSharp3-AnyCPU.props'))" />
+  </Target>
 </Project>

+ 168 - 2
AutoDo/FormAutoDo.Designer.cs

@@ -28,13 +28,179 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.components = new System.ComponentModel.Container();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.tBImgPath = new System.Windows.Forms.TextBox();
+            this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
+            this.button3 = new System.Windows.Forms.Button();
+            this.dataGridView1 = new System.Windows.Forms.DataGridView();
+            this.wd = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.评价函数值 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.label1 = new System.Windows.Forms.Label();
+            this.button4 = new System.Windows.Forms.Button();
+            this.label2 = new System.Windows.Forms.Label();
+            this.button5 = new System.Windows.Forms.Button();
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(43, 24);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(69, 34);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "LoG";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(309, 24);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(141, 34);
+            this.button2.TabIndex = 1;
+            this.button2.Text = "选择图像文件夹";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // tBImgPath
+            // 
+            this.tBImgPath.Location = new System.Drawing.Point(472, 30);
+            this.tBImgPath.Name = "tBImgPath";
+            this.tBImgPath.ReadOnly = true;
+            this.tBImgPath.Size = new System.Drawing.Size(479, 28);
+            this.tBImgPath.TabIndex = 2;
+            // 
+            // chart1
+            // 
+            chartArea6.Name = "ChartArea1";
+            this.chart1.ChartAreas.Add(chartArea6);
+            legend6.Name = "Legend1";
+            this.chart1.Legends.Add(legend6);
+            this.chart1.Location = new System.Drawing.Point(43, 88);
+            this.chart1.Name = "chart1";
+            series6.ChartArea = "ChartArea1";
+            series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
+            series6.Legend = "Legend1";
+            series6.Name = "Series1";
+            this.chart1.Series.Add(series6);
+            this.chart1.Size = new System.Drawing.Size(743, 467);
+            this.chart1.TabIndex = 4;
+            this.chart1.Text = "chart1";
+            // 
+            // button3
+            // 
+            this.button3.Location = new System.Drawing.Point(137, 24);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(69, 34);
+            this.button3.TabIndex = 5;
+            this.button3.Text = "梯度";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
+            // 
+            // dataGridView1
+            // 
+            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.wd,
+            this.评价函数值});
+            this.dataGridView1.Location = new System.Drawing.Point(810, 88);
+            this.dataGridView1.Name = "dataGridView1";
+            this.dataGridView1.RowTemplate.Height = 30;
+            this.dataGridView1.Size = new System.Drawing.Size(345, 467);
+            this.dataGridView1.TabIndex = 6;
+            this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
+            // 
+            // wd
+            // 
+            this.wd.HeaderText = "wd";
+            this.wd.Name = "wd";
+            // 
+            // 评价函数值
+            // 
+            this.评价函数值.HeaderText = "评价函数值";
+            this.评价函数值.Name = "评价函数值";
+            this.评价函数值.Width = 200;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(993, 33);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(62, 18);
+            this.label1.TabIndex = 8;
+            this.label1.Text = "焦距:";
+            // 
+            // button4
+            // 
+            this.button4.Location = new System.Drawing.Point(43, 581);
+            this.button4.Name = "button4";
+            this.button4.Size = new System.Drawing.Size(186, 39);
+            this.button4.TabIndex = 9;
+            this.button4.Text = "多种评价函数比较";
+            this.button4.UseVisualStyleBackColor = true;
+            this.button4.Click += new System.EventHandler(this.button4_Click);
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(265, 591);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(0, 18);
+            this.label2.TabIndex = 10;
+            // 
+            // button5
+            // 
+            this.button5.Location = new System.Drawing.Point(223, 24);
+            this.button5.Name = "button5";
+            this.button5.Size = new System.Drawing.Size(69, 34);
+            this.button5.TabIndex = 11;
+            this.button5.Text = "滤波";
+            this.button5.UseVisualStyleBackColor = true;
+            this.button5.Click += new System.EventHandler(this.button5_Click);
+            // 
+            // FormAutoDo
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.ClientSize = new System.Drawing.Size(1198, 735);
+            this.Controls.Add(this.button5);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.button4);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.dataGridView1);
+            this.Controls.Add(this.button3);
+            this.Controls.Add(this.chart1);
+            this.Controls.Add(this.tBImgPath);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Name = "FormAutoDo";
             this.Text = "Form1";
+            ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
         }
 
         #endregion
+
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.TextBox tBImgPath;
+        private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
+        private System.Windows.Forms.Button button3;
+        private System.Windows.Forms.DataGridView dataGridView1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn wd;
+        private System.Windows.Forms.DataGridViewTextBoxColumn 评价函数值;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Button button4;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Button button5;
     }
 }
 

+ 326 - 0
AutoDo/FormAutoDo.cs

@@ -10,14 +10,340 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using System.IO;
+using OpenCvSharp;
+using System.Windows.Forms.DataVisualization.Charting;
+
 
 namespace AutoDo
 {
     public partial class FormAutoDo : Form
     {
+        //全局只有一个fatorySEM
+        //static FactoryHardware factorySEM = FactoryHardware.Instance;
+        //ISEMControl iSEM = factorySEM.ISEM;
+
+        //图像文件夹
+        public string  m_strImgPath;
+
+        //显示处理结果
+        public Bitmap m_bitmap; 
+
         public FormAutoDo()
         {
             InitializeComponent();
         }
+
+        //自动对焦过程
+        private void button1_Click(object sender, EventArgs e)
+        {
+            //第一种方法
+            var files = Directory.GetFiles(m_strImgPath, "*.tif");
+            float[] values = new float[files.Length];
+            
+            this.dataGridView1.Rows.Clear();
+            Series series = chart1.Series[0];
+            series.Points.Clear();
+
+            int x = 0;
+
+            double smax = LoGMean(files[0]);
+            int wdmax = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+            foreach (var file in files)
+            {
+               
+                int wd = int.Parse(file.Substring(file.Length - 8, 4));
+                double svalue = LoGMean(file);
+
+                if (smax < svalue)
+                {
+                    smax = svalue;
+                    wdmax = wd;
+                }
+
+                ShowData(wd, svalue);
+
+                x++;
+            }
+
+            this.label1.Text = "焦距:" + wdmax.ToString();
+        }
+
+        //选择图像文件夹
+        private void button2_Click(object sender, EventArgs e)
+        {
+            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
+            dialog.Description = "选择拍图保存的文件夹";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                if (string.IsNullOrEmpty(dialog.SelectedPath))
+                {
+                    MessageBox.Show("图像文件夹不能为空");
+                    return;
+                }
+
+                m_strImgPath = dialog.SelectedPath;
+                tBImgPath.Text = dialog.SelectedPath;
+
+            }
+        }
+
+        //LoG算子计算
+        private double LoGMean(string a_strImgPath)
+        {
+            //读入Img文件
+            if (!File.Exists(a_strImgPath))
+            {
+                return 0;
+            }
+
+            Mat src, gray_src;
+            int kernel_size = 3;
+
+            src = Cv2.ImRead(a_strImgPath);
+            gray_src = new Mat();
+           
+            src.CvtColor(ColorConversionCodes.BGR2GRAY);  
+
+            Mat kernel = Cv2.GetStructuringElement(MorphShapes.Cross, new OpenCvSharp.Size(10, 10));
+            Cv2.MorphologyEx(src, src, MorphTypes.Close, kernel);
+
+            Cv2.GaussianBlur(src, src, new OpenCvSharp.Size(3, 3), 0, 0);
+            Cv2.Laplacian(src, src, MatType.CV_8UC3, kernel_size);
+            Cv2.ConvertScaleAbs(src, src);
+
+            //图像的平均灰度
+
+            double meanValue = 0.0;
+            meanValue = Cv2.Mean(src)[0];
+            return meanValue;
+        }
+
+        //梯度计算
+        private double Tenengrad(string a_strImgPath)
+        {
+            //读入Img文件
+            if (!File.Exists(a_strImgPath))
+            {
+                return 0;
+            }
+
+            Mat src;
+            src = Cv2.ImRead(a_strImgPath);
+          
+            src.CvtColor(ColorConversionCodes.BGR2GRAY);
+
+            Mat kernel = Cv2.GetStructuringElement(MorphShapes.Cross, new OpenCvSharp.Size(10, 10));
+            Cv2.MorphologyEx(src, src, MorphTypes.Close, kernel);
+
+            Cv2.GaussianBlur(src, src, new OpenCvSharp.Size(3, 3), 0, 0);
+            Cv2.Sobel(src, src, MatType.CV_8UC1, 1, 1);
+            //图像的平均灰度
+            double meanValue = 0.0;
+            meanValue = Cv2.Mean(src)[0];
+            return meanValue;
+        }
+
+        //梯度计算
+        private double TTgrad(string a_strImgPath)
+        {
+            //读入Img文件
+            if (!File.Exists(a_strImgPath))
+            {
+                return 0;
+            }
+
+            Mat src;
+            src = Cv2.ImRead(a_strImgPath);
+
+            src.CvtColor(ColorConversionCodes.BGR2GRAY);
+
+            Mat kernel = Cv2.GetStructuringElement(MorphShapes.Cross, new OpenCvSharp.Size(10, 10));
+            Cv2.MorphologyEx(src, src, MorphTypes.Close, kernel);
+
+            Mat scalex = new Mat();
+            Mat scaley = new Mat();
+
+            Cv2.Scharr(src, src, src.Depth(),1, 0);
+            Cv2.ConvertScaleAbs(src, scalex);
+
+            Cv2.Scharr(src, src, src.Depth(), 0, 1);
+            Cv2.ConvertScaleAbs(src, scaley);
+
+            Cv2.AddWeighted(scalex, 0.5, scaley, 0.5, 0, src);
+
+            //图像的平均灰度
+            double meanValue = 0.0;
+            meanValue = Cv2.Mean(src)[0];
+            return meanValue;
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            //第二种方法
+            var files = Directory.GetFiles(m_strImgPath, "*.tif");
+            float[] values = new float[files.Length];
+
+            this.dataGridView1.Rows.Clear();
+            Series series = chart1.Series[0];
+            series.Points.Clear();
+
+
+            double smax = Tenengrad(files[0]);
+            int wdmax = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+
+            int x = 0;
+            foreach (var file in files)
+            {
+                
+                int wd = int.Parse(file.Substring(file.Length - 8, 4));
+                double svalue = Tenengrad(file);
+
+
+                if (smax < svalue)
+                {
+                    smax = svalue;
+                    wdmax = wd;
+                }
+
+                ShowData(wd, svalue);
+                x++;
+            }
+
+            this.label1.Text = "焦距:" + wdmax.ToString();
+        }
+
+        //显示数据
+        private void ShowData(int wd, double svalue)
+        {
+            //绘制评价函数曲线s
+            Series series = chart1.Series[0];            
+            series.Points.AddXY(wd, svalue);
+
+            //显示评价函数数值
+            
+            int index = this.dataGridView1.Rows.Add();
+            this.dataGridView1.Rows[index].Cells[0].Value = wd;
+            this.dataGridView1.Rows[index].Cells[1].Value = svalue;
+        }
+
+        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
+        {
+
+        }
+
+        private void button4_Click(object sender, EventArgs e)
+        {
+            var files = Directory.GetFiles(m_strImgPath, "*.tif");
+            float[] values = new float[files.Length];
+
+ 
+            double smax1 = LoGMean(files[0]);
+            int wdmax1 = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+            double smax2 = Tenengrad(files[0]);
+            int wdmax2 = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+            double smax3 = TTgrad(files[0]);
+            int wdmax3 = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+
+
+            int x = 0;
+            foreach (var file in files)
+            {
+
+                int wd = int.Parse(file.Substring(file.Length - 8, 4));
+                double svalue1 = LoGMean(file);
+                double svalue2 = Tenengrad(file);
+                double svalue3 = TTgrad(file);
+
+
+                if (smax1 < svalue1)
+                {
+                    smax1 = svalue1;
+                    wdmax1= wd;
+                }
+
+                if (smax2 < svalue2)
+                {
+                    smax2 = svalue2;
+                    wdmax2 = wd;
+                }
+
+                if (smax3 < svalue3)
+                {
+                    smax3 = svalue3;
+                    wdmax3 = wd;
+                }
+
+                x++;
+            }
+
+            this.label2.Text = "";
+            this.label2.Text = "LoG = " + wdmax1.ToString() + ",梯度 = " + wdmax2.ToString() + ",滤波 = " + wdmax3.ToString();
+
+            
+            if (wdmax1 == wdmax2 || wdmax1 == wdmax3)
+            {
+                
+                this.label2.Text += ",焦距 = " + wdmax1.ToString();
+            }
+            else if (wdmax1 == wdmax2 || wdmax2 == wdmax3)
+            {
+                
+                this.label2.Text += ",焦距 = " + wdmax2.ToString();
+            }
+            else if (wdmax3 == wdmax2 || wdmax1 == wdmax3)
+            {
+               
+                this.label2.Text += ",焦距 = " + wdmax3.ToString();
+            }
+            else
+            {
+                this.label2.Text += ",对焦失败。";
+            }
+
+
+
+            
+        }
+
+        private void button5_Click(object sender, EventArgs e)
+        {
+            //第一种方法
+            var files = Directory.GetFiles(m_strImgPath, "*.tif");
+            float[] values = new float[files.Length];
+
+            this.dataGridView1.Rows.Clear();
+            Series series = chart1.Series[0];
+            series.Points.Clear();
+
+            int x = 0;
+
+            double smax = TTgrad(files[0]);
+            int wdmax = int.Parse(files[0].Substring(files[0].Length - 8, 4));
+
+            foreach (var file in files)
+            {
+
+                int wd = int.Parse(file.Substring(file.Length - 8, 4));
+                double svalue = TTgrad(file);
+
+                if (smax < svalue)
+                {
+                    smax = svalue;
+                    wdmax = wd;
+                }
+
+                ShowData(wd, svalue);
+
+                x++;
+            }
+
+            this.label1.Text = "焦距:" + wdmax.ToString();
+        }
     }
 }

+ 12 - 0
AutoDo/FormAutoDo.resx

@@ -117,4 +117,16 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="wd.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="评价函数值.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="wd.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="评价函数值.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 3 - 0
HOZProject/App.config

@@ -44,4 +44,7 @@
       <!--是否PT沉积-->
       <add key="PT_Depostion" value="False"/>
     </appSettings>
+  <DefaultParam>
+    <add key ="FIB" value ="C:/HOZ/FIB.ELY"/>
+    </DefaultParam>
 </configuration>

+ 306 - 49
ManulDo/MainForm.Designer.cs

@@ -59,10 +59,33 @@
             this.R = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.T = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.listmsg = new System.Windows.Forms.ListBox();
+            this.tbAutoFocus = new System.Windows.Forms.Button();
+            this.groupBox5 = new System.Windows.Forms.GroupBox();
+            this.btImgPath = new System.Windows.Forms.Button();
+            this.tBImgPath = new System.Windows.Forms.TextBox();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.label7 = new System.Windows.Forms.Label();
+            this.label8 = new System.Windows.Forms.Label();
+            this.tB = new System.Windows.Forms.TextBox();
+            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.textBox3 = new System.Windows.Forms.TextBox();
+            this.textBox4 = new System.Windows.Forms.TextBox();
+            this.textBox5 = new System.Windows.Forms.TextBox();
+            this.textBox6 = new System.Windows.Forms.TextBox();
+            this.label9 = new System.Windows.Forms.Label();
+            this.label10 = new System.Windows.Forms.Label();
+            this.label11 = new System.Windows.Forms.Label();
+            this.label12 = new System.Windows.Forms.Label();
+            this.label13 = new System.Windows.Forms.Label();
+            this.label14 = new System.Windows.Forms.Label();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
             this.groupBox3.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.CutHoleGridView)).BeginInit();
+            this.groupBox5.SuspendLayout();
             this.SuspendLayout();
             // 
             // groupBox1
@@ -70,21 +93,21 @@
             this.groupBox1.Controls.Add(this.btnOpenFile);
             this.groupBox1.Controls.Add(this.btnSaveFile);
             this.groupBox1.Controls.Add(this.btnNewFile);
-            this.groupBox1.Location = new System.Drawing.Point(11, 10);
+            this.groupBox1.Location = new System.Drawing.Point(12, 12);
             this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.groupBox1.Size = new System.Drawing.Size(404, 67);
+            this.groupBox1.Size = new System.Drawing.Size(454, 80);
             this.groupBox1.TabIndex = 1;
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "测量文件操作";
             // 
             // btnOpenFile
             // 
-            this.btnOpenFile.Location = new System.Drawing.Point(209, 23);
+            this.btnOpenFile.Location = new System.Drawing.Point(235, 28);
             this.btnOpenFile.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnOpenFile.Name = "btnOpenFile";
-            this.btnOpenFile.Size = new System.Drawing.Size(91, 31);
+            this.btnOpenFile.Size = new System.Drawing.Size(102, 37);
             this.btnOpenFile.TabIndex = 2;
             this.btnOpenFile.Text = "打开";
             this.btnOpenFile.UseVisualStyleBackColor = true;
@@ -92,10 +115,10 @@
             // 
             // btnSaveFile
             // 
-            this.btnSaveFile.Location = new System.Drawing.Point(113, 23);
+            this.btnSaveFile.Location = new System.Drawing.Point(127, 28);
             this.btnSaveFile.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnSaveFile.Name = "btnSaveFile";
-            this.btnSaveFile.Size = new System.Drawing.Size(91, 31);
+            this.btnSaveFile.Size = new System.Drawing.Size(102, 37);
             this.btnSaveFile.TabIndex = 1;
             this.btnSaveFile.Text = "保存";
             this.btnSaveFile.UseVisualStyleBackColor = true;
@@ -103,10 +126,10 @@
             // 
             // btnNewFile
             // 
-            this.btnNewFile.Location = new System.Drawing.Point(17, 23);
+            this.btnNewFile.Location = new System.Drawing.Point(19, 28);
             this.btnNewFile.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnNewFile.Name = "btnNewFile";
-            this.btnNewFile.Size = new System.Drawing.Size(91, 31);
+            this.btnNewFile.Size = new System.Drawing.Size(102, 37);
             this.btnNewFile.TabIndex = 0;
             this.btnNewFile.Text = "新建";
             this.btnNewFile.UseVisualStyleBackColor = true;
@@ -121,21 +144,21 @@
             this.groupBox2.Controls.Add(this.button4);
             this.groupBox2.Controls.Add(this.button3);
             this.groupBox2.Controls.Add(this.btnLoadCutHoles);
-            this.groupBox2.Location = new System.Drawing.Point(11, 82);
+            this.groupBox2.Location = new System.Drawing.Point(12, 98);
             this.groupBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.groupBox2.Name = "groupBox2";
             this.groupBox2.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.groupBox2.Size = new System.Drawing.Size(404, 108);
+            this.groupBox2.Size = new System.Drawing.Size(454, 130);
             this.groupBox2.TabIndex = 2;
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "测量流程";
             // 
             // button1
             // 
-            this.button1.Location = new System.Drawing.Point(305, 67);
+            this.button1.Location = new System.Drawing.Point(343, 80);
             this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(91, 31);
+            this.button1.Size = new System.Drawing.Size(102, 37);
             this.button1.TabIndex = 6;
             this.button1.Text = "截面";
             this.button1.UseVisualStyleBackColor = true;
@@ -143,10 +166,10 @@
             // 
             // button7
             // 
-            this.button7.Location = new System.Drawing.Point(209, 67);
+            this.button7.Location = new System.Drawing.Point(235, 80);
             this.button7.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button7.Name = "button7";
-            this.button7.Size = new System.Drawing.Size(91, 31);
+            this.button7.Size = new System.Drawing.Size(102, 37);
             this.button7.TabIndex = 5;
             this.button7.Text = "分析位置";
             this.button7.UseVisualStyleBackColor = true;
@@ -154,10 +177,10 @@
             // 
             // button6
             // 
-            this.button6.Location = new System.Drawing.Point(113, 67);
+            this.button6.Location = new System.Drawing.Point(127, 80);
             this.button6.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button6.Name = "button6";
-            this.button6.Size = new System.Drawing.Size(91, 31);
+            this.button6.Size = new System.Drawing.Size(102, 37);
             this.button6.TabIndex = 4;
             this.button6.Text = "切割";
             this.button6.UseVisualStyleBackColor = true;
@@ -165,10 +188,10 @@
             // 
             // button5
             // 
-            this.button5.Location = new System.Drawing.Point(17, 67);
+            this.button5.Location = new System.Drawing.Point(19, 80);
             this.button5.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button5.Name = "button5";
-            this.button5.Size = new System.Drawing.Size(91, 31);
+            this.button5.Size = new System.Drawing.Size(102, 37);
             this.button5.TabIndex = 3;
             this.button5.Text = "定位";
             this.button5.UseVisualStyleBackColor = true;
@@ -176,10 +199,10 @@
             // 
             // button4
             // 
-            this.button4.Location = new System.Drawing.Point(209, 32);
+            this.button4.Location = new System.Drawing.Point(235, 38);
             this.button4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button4.Name = "button4";
-            this.button4.Size = new System.Drawing.Size(91, 31);
+            this.button4.Size = new System.Drawing.Size(102, 37);
             this.button4.TabIndex = 2;
             this.button4.Text = "停止";
             this.button4.UseVisualStyleBackColor = true;
@@ -187,10 +210,10 @@
             // 
             // button3
             // 
-            this.button3.Location = new System.Drawing.Point(113, 32);
+            this.button3.Location = new System.Drawing.Point(127, 38);
             this.button3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.button3.Name = "button3";
-            this.button3.Size = new System.Drawing.Size(91, 31);
+            this.button3.Size = new System.Drawing.Size(102, 37);
             this.button3.TabIndex = 1;
             this.button3.Text = "启动";
             this.button3.UseVisualStyleBackColor = true;
@@ -198,10 +221,10 @@
             // 
             // btnLoadCutHoles
             // 
-            this.btnLoadCutHoles.Location = new System.Drawing.Point(17, 32);
+            this.btnLoadCutHoles.Location = new System.Drawing.Point(19, 38);
             this.btnLoadCutHoles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnLoadCutHoles.Name = "btnLoadCutHoles";
-            this.btnLoadCutHoles.Size = new System.Drawing.Size(91, 31);
+            this.btnLoadCutHoles.Size = new System.Drawing.Size(102, 37);
             this.btnLoadCutHoles.TabIndex = 0;
             this.btnLoadCutHoles.Text = "导入切孔";
             this.btnLoadCutHoles.UseVisualStyleBackColor = true;
@@ -217,21 +240,21 @@
             this.groupBox3.Controls.Add(this.tBSampleName);
             this.groupBox3.Controls.Add(this.cBIsManul);
             this.groupBox3.Controls.Add(this.cBIsPT);
-            this.groupBox3.Location = new System.Drawing.Point(12, 196);
+            this.groupBox3.Location = new System.Drawing.Point(14, 235);
             this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.groupBox3.Name = "groupBox3";
             this.groupBox3.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.groupBox3.Size = new System.Drawing.Size(404, 91);
+            this.groupBox3.Size = new System.Drawing.Size(454, 109);
             this.groupBox3.TabIndex = 3;
             this.groupBox3.TabStop = false;
             this.groupBox3.Text = "测量参数";
             // 
             // btParamOK
             // 
-            this.btParamOK.Location = new System.Drawing.Point(304, 56);
+            this.btParamOK.Location = new System.Drawing.Point(342, 67);
             this.btParamOK.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btParamOK.Name = "btParamOK";
-            this.btParamOK.Size = new System.Drawing.Size(91, 31);
+            this.btParamOK.Size = new System.Drawing.Size(102, 37);
             this.btParamOK.TabIndex = 7;
             this.btParamOK.Text = "确定";
             this.btParamOK.UseVisualStyleBackColor = true;
@@ -239,10 +262,10 @@
             // 
             // btFIB
             // 
-            this.btFIB.Location = new System.Drawing.Point(164, 50);
+            this.btFIB.Location = new System.Drawing.Point(184, 60);
             this.btFIB.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btFIB.Name = "btFIB";
-            this.btFIB.Size = new System.Drawing.Size(38, 22);
+            this.btFIB.Size = new System.Drawing.Size(43, 26);
             this.btFIB.TabIndex = 6;
             this.btFIB.Text = "...";
             this.btFIB.UseVisualStyleBackColor = true;
@@ -250,46 +273,46 @@
             // 
             // tBFIBTemp
             // 
-            this.tBFIBTemp.Location = new System.Drawing.Point(76, 49);
+            this.tBFIBTemp.Location = new System.Drawing.Point(86, 59);
             this.tBFIBTemp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.tBFIBTemp.Name = "tBFIBTemp";
             this.tBFIBTemp.ReadOnly = true;
-            this.tBFIBTemp.Size = new System.Drawing.Size(89, 25);
+            this.tBFIBTemp.Size = new System.Drawing.Size(100, 28);
             this.tBFIBTemp.TabIndex = 5;
             // 
             // label2
             // 
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(15, 57);
+            this.label2.Location = new System.Drawing.Point(17, 68);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(61, 15);
+            this.label2.Size = new System.Drawing.Size(71, 18);
             this.label2.TabIndex = 4;
             this.label2.Text = "FIB模板";
             // 
             // label1
             // 
             this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(183, 26);
+            this.label1.Location = new System.Drawing.Point(206, 31);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(67, 15);
+            this.label1.Size = new System.Drawing.Size(80, 18);
             this.label1.TabIndex = 3;
             this.label1.Text = "样品名称";
             // 
             // tBSampleName
             // 
-            this.tBSampleName.Location = new System.Drawing.Point(256, 23);
+            this.tBSampleName.Location = new System.Drawing.Point(288, 28);
             this.tBSampleName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.tBSampleName.Name = "tBSampleName";
-            this.tBSampleName.Size = new System.Drawing.Size(89, 25);
+            this.tBSampleName.Size = new System.Drawing.Size(100, 28);
             this.tBSampleName.TabIndex = 2;
             // 
             // cBIsManul
             // 
             this.cBIsManul.AutoSize = true;
-            this.cBIsManul.Location = new System.Drawing.Point(84, 23);
+            this.cBIsManul.Location = new System.Drawing.Point(94, 28);
             this.cBIsManul.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cBIsManul.Name = "cBIsManul";
-            this.cBIsManul.Size = new System.Drawing.Size(89, 19);
+            this.cBIsManul.Size = new System.Drawing.Size(106, 22);
             this.cBIsManul.TabIndex = 1;
             this.cBIsManul.Text = "手动对焦";
             this.cBIsManul.UseVisualStyleBackColor = true;
@@ -297,10 +320,10 @@
             // cBIsPT
             // 
             this.cBIsPT.AutoSize = true;
-            this.cBIsPT.Location = new System.Drawing.Point(16, 23);
+            this.cBIsPT.Location = new System.Drawing.Point(18, 28);
             this.cBIsPT.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cBIsPT.Name = "cBIsPT";
-            this.cBIsPT.Size = new System.Drawing.Size(60, 19);
+            this.cBIsPT.Size = new System.Drawing.Size(70, 22);
             this.cBIsPT.TabIndex = 0;
             this.cBIsPT.Text = "有PT";
             this.cBIsPT.UseVisualStyleBackColor = true;
@@ -319,12 +342,12 @@
             this.M,
             this.R,
             this.T});
-            this.CutHoleGridView.Location = new System.Drawing.Point(11, 292);
+            this.CutHoleGridView.Location = new System.Drawing.Point(12, 350);
             this.CutHoleGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.CutHoleGridView.Name = "CutHoleGridView";
             this.CutHoleGridView.ReadOnly = true;
             this.CutHoleGridView.RowTemplate.Height = 30;
-            this.CutHoleGridView.Size = new System.Drawing.Size(690, 219);
+            this.CutHoleGridView.Size = new System.Drawing.Size(776, 263);
             this.CutHoleGridView.TabIndex = 16;
             // 
             // Name
@@ -365,17 +388,227 @@
             // listmsg
             // 
             this.listmsg.FormattingEnabled = true;
-            this.listmsg.ItemHeight = 15;
-            this.listmsg.Location = new System.Drawing.Point(713, 10);
+            this.listmsg.ItemHeight = 18;
+            this.listmsg.Location = new System.Drawing.Point(802, 12);
+            this.listmsg.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.listmsg.Name = "listmsg";
-            this.listmsg.Size = new System.Drawing.Size(697, 604);
+            this.listmsg.Size = new System.Drawing.Size(784, 832);
             this.listmsg.TabIndex = 17;
             // 
+            // tbAutoFocus
+            // 
+            this.tbAutoFocus.Location = new System.Drawing.Point(630, 158);
+            this.tbAutoFocus.Name = "tbAutoFocus";
+            this.tbAutoFocus.Size = new System.Drawing.Size(114, 32);
+            this.tbAutoFocus.TabIndex = 18;
+            this.tbAutoFocus.Text = "对焦";
+            this.tbAutoFocus.UseVisualStyleBackColor = true;
+            // 
+            // groupBox5
+            // 
+            this.groupBox5.Controls.Add(this.label14);
+            this.groupBox5.Controls.Add(this.label13);
+            this.groupBox5.Controls.Add(this.label12);
+            this.groupBox5.Controls.Add(this.label11);
+            this.groupBox5.Controls.Add(this.label10);
+            this.groupBox5.Controls.Add(this.label9);
+            this.groupBox5.Controls.Add(this.textBox6);
+            this.groupBox5.Controls.Add(this.textBox5);
+            this.groupBox5.Controls.Add(this.textBox4);
+            this.groupBox5.Controls.Add(this.textBox3);
+            this.groupBox5.Controls.Add(this.textBox2);
+            this.groupBox5.Controls.Add(this.tB);
+            this.groupBox5.Controls.Add(this.label8);
+            this.groupBox5.Controls.Add(this.label7);
+            this.groupBox5.Controls.Add(this.label6);
+            this.groupBox5.Controls.Add(this.label5);
+            this.groupBox5.Controls.Add(this.label4);
+            this.groupBox5.Controls.Add(this.label3);
+            this.groupBox5.Controls.Add(this.tBImgPath);
+            this.groupBox5.Controls.Add(this.btImgPath);
+            this.groupBox5.Controls.Add(this.tbAutoFocus);
+            this.groupBox5.Location = new System.Drawing.Point(17, 636);
+            this.groupBox5.Name = "groupBox5";
+            this.groupBox5.Size = new System.Drawing.Size(771, 207);
+            this.groupBox5.TabIndex = 19;
+            this.groupBox5.TabStop = false;
+            this.groupBox5.Text = "自动对焦";
+            // 
+            // btImgPath
+            // 
+            this.btImgPath.Location = new System.Drawing.Point(17, 25);
+            this.btImgPath.Name = "btImgPath";
+            this.btImgPath.Size = new System.Drawing.Size(266, 35);
+            this.btImgPath.TabIndex = 20;
+            this.btImgPath.Text = "选择图像存储路径";
+            this.btImgPath.UseVisualStyleBackColor = true;
+            this.btImgPath.Click += new System.EventHandler(this.btImgPath_Click);
+            // 
+            // tBImgPath
+            // 
+            this.tBImgPath.Location = new System.Drawing.Point(302, 27);
+            this.tBImgPath.Name = "tBImgPath";
+            this.tBImgPath.ReadOnly = true;
+            this.tBImgPath.Size = new System.Drawing.Size(450, 28);
+            this.tBImgPath.TabIndex = 21;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(33, 83);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(80, 18);
+            this.label3.TabIndex = 8;
+            this.label3.Text = "调节上限";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(299, 83);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(80, 18);
+            this.label4.TabIndex = 22;
+            this.label4.Text = "调节下限";
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(530, 83);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(80, 18);
+            this.label5.TabIndex = 23;
+            this.label5.Text = "调节步长";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(36, 119);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(80, 18);
+            this.label6.TabIndex = 24;
+            this.label6.Text = "精调范围";
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Location = new System.Drawing.Point(305, 119);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(80, 18);
+            this.label7.TabIndex = 25;
+            this.label7.Text = "精调步长";
+            // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(530, 119);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(44, 18);
+            this.label8.TabIndex = 26;
+            this.label8.Text = "焦距";
+            // 
+            // tB
+            // 
+            this.tB.Location = new System.Drawing.Point(119, 78);
+            this.tB.Name = "tB";
+            this.tB.Size = new System.Drawing.Size(96, 28);
+            this.tB.TabIndex = 27;
+            // 
+            // textBox2
+            // 
+            this.textBox2.Location = new System.Drawing.Point(385, 80);
+            this.textBox2.Name = "textBox2";
+            this.textBox2.Size = new System.Drawing.Size(96, 28);
+            this.textBox2.TabIndex = 28;
+            // 
+            // textBox3
+            // 
+            this.textBox3.Location = new System.Drawing.Point(616, 78);
+            this.textBox3.Name = "textBox3";
+            this.textBox3.Size = new System.Drawing.Size(96, 28);
+            this.textBox3.TabIndex = 29;
+            // 
+            // textBox4
+            // 
+            this.textBox4.Location = new System.Drawing.Point(120, 116);
+            this.textBox4.Name = "textBox4";
+            this.textBox4.Size = new System.Drawing.Size(96, 28);
+            this.textBox4.TabIndex = 30;
+            // 
+            // textBox5
+            // 
+            this.textBox5.Location = new System.Drawing.Point(385, 119);
+            this.textBox5.Name = "textBox5";
+            this.textBox5.Size = new System.Drawing.Size(96, 28);
+            this.textBox5.TabIndex = 31;
+            // 
+            // textBox6
+            // 
+            this.textBox6.Location = new System.Drawing.Point(616, 118);
+            this.textBox6.Name = "textBox6";
+            this.textBox6.ReadOnly = true;
+            this.textBox6.Size = new System.Drawing.Size(96, 28);
+            this.textBox6.TabIndex = 32;
+            // 
+            // label9
+            // 
+            this.label9.AutoSize = true;
+            this.label9.Location = new System.Drawing.Point(218, 84);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(26, 18);
+            this.label9.TabIndex = 33;
+            this.label9.Text = "um";
+            // 
+            // label10
+            // 
+            this.label10.AutoSize = true;
+            this.label10.Location = new System.Drawing.Point(487, 84);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(26, 18);
+            this.label10.TabIndex = 34;
+            this.label10.Text = "um";
+            // 
+            // label11
+            // 
+            this.label11.AutoSize = true;
+            this.label11.Location = new System.Drawing.Point(718, 84);
+            this.label11.Name = "label11";
+            this.label11.Size = new System.Drawing.Size(26, 18);
+            this.label11.TabIndex = 35;
+            this.label11.Text = "um";
+            // 
+            // label12
+            // 
+            this.label12.AutoSize = true;
+            this.label12.Location = new System.Drawing.Point(222, 121);
+            this.label12.Name = "label12";
+            this.label12.Size = new System.Drawing.Size(26, 18);
+            this.label12.TabIndex = 36;
+            this.label12.Text = "um";
+            // 
+            // label13
+            // 
+            this.label13.AutoSize = true;
+            this.label13.Location = new System.Drawing.Point(487, 126);
+            this.label13.Name = "label13";
+            this.label13.Size = new System.Drawing.Size(26, 18);
+            this.label13.TabIndex = 37;
+            this.label13.Text = "um";
+            // 
+            // label14
+            // 
+            this.label14.AutoSize = true;
+            this.label14.Location = new System.Drawing.Point(718, 122);
+            this.label14.Name = "label14";
+            this.label14.Size = new System.Drawing.Size(26, 18);
+            this.label14.TabIndex = 38;
+            this.label14.Text = "um";
+            // 
             // MainForm
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1422, 628);
+            this.ClientSize = new System.Drawing.Size(1600, 854);
+            this.Controls.Add(this.groupBox5);
             this.Controls.Add(this.listmsg);
             this.Controls.Add(this.CutHoleGridView);
             this.Controls.Add(this.groupBox3);
@@ -389,6 +622,8 @@
             this.groupBox3.ResumeLayout(false);
             this.groupBox3.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.CutHoleGridView)).EndInit();
+            this.groupBox5.ResumeLayout(false);
+            this.groupBox5.PerformLayout();
             this.ResumeLayout(false);
 
         }
@@ -424,6 +659,28 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn R;
         private System.Windows.Forms.DataGridViewTextBoxColumn T;
         private System.Windows.Forms.ListBox listmsg;
+        private System.Windows.Forms.Button tbAutoFocus;
+        private System.Windows.Forms.GroupBox groupBox5;
+        private System.Windows.Forms.Button btImgPath;
+        private System.Windows.Forms.TextBox tBImgPath;
+        private System.Windows.Forms.Label label9;
+        private System.Windows.Forms.TextBox textBox6;
+        private System.Windows.Forms.TextBox textBox5;
+        private System.Windows.Forms.TextBox textBox4;
+        private System.Windows.Forms.TextBox textBox3;
+        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.TextBox tB;
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label14;
+        private System.Windows.Forms.Label label13;
+        private System.Windows.Forms.Label label12;
+        private System.Windows.Forms.Label label11;
+        private System.Windows.Forms.Label label10;
     }
 }
 

+ 22 - 1
ManulDo/MainForm.cs

@@ -25,7 +25,10 @@ namespace WindowsFormsApp1
         
         /// 测量线程  
         public Measure m_Ms;
-        
+
+        //图像文件夹
+        public string m_strImgPath;
+
         #endregion
         #region 构造函数
         public MainForm()
@@ -265,5 +268,23 @@ namespace WindowsFormsApp1
         {
 
         }
+
+        private void btImgPath_Click(object sender, EventArgs e)
+        {
+            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
+            dialog.Description = "选择拍图保存的文件夹";
+            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                if (string.IsNullOrEmpty(dialog.SelectedPath))
+                {
+                    MessageBox.Show("图像文件夹不能为空");
+                    return;
+                }
+
+                m_strImgPath = dialog.SelectedPath;
+                tBImgPath.Text = dialog.SelectedPath;
+
+            }
+        }
     }
 }

+ 26 - 57
MeasureData/ConfigFile.cs

@@ -13,6 +13,22 @@ namespace MeasureData
     public class ConfigFile : ISlo
     {
         #region 内容
+        //文件名
+        private string m_fileName;
+        public string FileName
+        {
+            get { return this.m_fileName; }
+            set { this.m_fileName = value; }
+        }
+
+        //文件路径
+        private string m_filepath;
+        public string FilePath
+        {
+            get { return this.m_filepath; }
+            set { this.m_filepath = value; }
+        }
+
         public MeasureParam m_Config;
         #endregion
 
@@ -93,46 +109,14 @@ namespace MeasureData
         {
             Slo sFile = new Slo();
 
-            xBool isPhotograph = new xBool();
-            xBool ptDepostion = new xBool();
-            isPhotograph.AssignValue(m_Config.Is_Photograph);
-            ptDepostion.AssignValue(m_Config.PT);
-            sFile.Register("Is_Photograph", isPhotograph);
-            sFile.Register("PT_Depostion", ptDepostion);
-
-            xString ptELYFile = new xString();
-            xString fibELYFile = new xString();
-            ptELYFile.AssignValue(m_Config.PTTemp);
-            fibELYFile.AssignValue(m_Config.FIBTemp);
-            sFile.Register("PT_ELYFile", ptELYFile);
-            sFile.Register("FIB_ELYFile", fibELYFile);
-
-            xDouble stretchMagnification = new xDouble();
-            xDouble locationMagnification = new xDouble();
-            xDouble locationVoltage = new xDouble();
-            xDouble photographMagnification = new xDouble();
-            xDouble photographVoltage = new xDouble();
-            stretchMagnification.AssignValue(m_Config.Stretch_Magnification);
-            locationMagnification.AssignValue(m_Config.Location_Magnification);
-            locationVoltage.AssignValue(m_Config.Location_Voltage);
-            photographMagnification.AssignValue(m_Config.Photograph_Magnification);
-            photographVoltage.AssignValue(m_Config.Photograph_Voltage);
-            sFile.Register("Strectch_Magnification", stretchMagnification);
-            sFile.Register("Locatio_Magnification", locationMagnification);
-            sFile.Register("Location_Voltage", locationVoltage);
-            sFile.Register("Photograph_Magnification", photographMagnification);
-            sFile.Register("Photograph_Voltage", photographVoltage);
-
-            xDouble correctionAngle = new xDouble();
-            correctionAngle.AssignValue(m_Config.Correction_Angle);
-            sFile.Register("Correction_Angle", correctionAngle);
-
-            xString sampleType = new xString();
-            xString _firm = new xString();
-            sampleType.AssignValue(m_Config.SampleName);
-            _firm.AssignValue(m_Config.Firm);
-            sFile.Register("Sample_Type", sampleType);
-            sFile.Register("Firm", _firm);
+            xString filename = new xString();
+            xString filepath = new xString();
+            filename.AssignValue(this.m_fileName);
+            filepath.AssignValue(this.m_filepath);
+            sFile.Register("FileName", filename);
+            sFile.Register("FilePath", filepath);
+
+            sFile.Register("Param", this.m_Config);
 
             if (isStoring)
             {
@@ -141,23 +125,8 @@ namespace MeasureData
             else
             {
                 sFile.Serialize(false, xml, rootNode);
-
-                m_Config.Is_Photograph = isPhotograph.value();
-                m_Config.PT = ptDepostion.value();
-
-                m_Config.PTTemp = ptELYFile.value();
-                m_Config.FIBTemp = fibELYFile.value();
-
-                m_Config.Stretch_Magnification = stretchMagnification.value();
-                m_Config.Location_Magnification = locationMagnification.value();
-                m_Config.Location_Voltage = locationVoltage.value();
-                m_Config.Photograph_Magnification = photographMagnification.value();
-                m_Config.Photograph_Voltage = photographVoltage.value();
-
-                m_Config.Correction_Angle = correctionAngle.value();
-
-                m_Config.SampleName = sampleType.value();
-                m_Config.Firm = _firm.value();
+                this.m_fileName = filename.value();
+                this.m_filepath = filepath.value();
             }
         }
     }

+ 25 - 0
MeasureData/FocusParam.cs

@@ -0,0 +1,25 @@
+//时间:20200911
+//作者:郝爽
+//功能:测量参数
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using FileManager;
+using System.Xml;
+using System.IO;
+
+namespace MeasureData
+{
+    public class FocusParam : ISlo
+    {
+        //XML文件保存测量参数
+        public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
+        {
+            Slo slo_msparam = new Slo();
+
+        }
+    }
+}

+ 1 - 0
MeasureData/MeasureData.csproj

@@ -49,6 +49,7 @@
   <ItemGroup>
     <Compile Include="ConfigFile.cs" />
     <Compile Include="CutHole.cs" />
+    <Compile Include="FocusParam.cs" />
     <Compile Include="MeasureFile.cs" />
     <Compile Include="MeasureParam.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 82 - 26
MeasureData/MeasureParam.cs

@@ -124,6 +124,12 @@ namespace MeasureData
         }
 
         //对焦参数
+        private FocusParam focusP;
+        public FocusParam AutoFocus
+        {
+            get { return this.focusP; }
+            set { this.focusP = value; }
+        }
 
         //能谱参数
 
@@ -141,44 +147,94 @@ namespace MeasureData
             this.PT = false;
             this.FIBTemp = @"";
             this.PTTemp = @"";
+            this.AutoFocus = new FocusParam();
         }
 
         //XML文件保存测量参数
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
-            Slo slo_msparam = new Slo();
-
-            xString sampleName = new xString();
-            xBool pt = new xBool();
-            xString FIBtemp = new xString();
-            xString PTtemp = new xString();
-            xBool FocMode = new xBool();
-
-            sampleName.AssignValue(this.SampleName);
-            pt.AssignValue(this.PT);
-            FIBtemp.AssignValue(this.FIBTemp);
-            PTtemp.AssignValue(this.PTTemp);
-            FocMode.AssignValue(this.FocusMode);
-
-            slo_msparam.Register("SampleName", sampleName);
-            slo_msparam.Register("PT", pt);
-            slo_msparam.Register("FIBTemp", FIBtemp);
-            slo_msparam.Register("PTTemp", PTtemp);
-            slo_msparam.Register("FocusMode", FocMode);
+            Slo sFile = new Slo();
+
+            //是否拍照和PT
+            xBool isPhotograph = new xBool();
+            xBool ptDepostion = new xBool();
+            isPhotograph.AssignValue(this.is_Photograph);
+            ptDepostion.AssignValue(this.m_pt);
+            sFile.Register("Is_Photograph", isPhotograph);
+            sFile.Register("PT_Depostion", ptDepostion);
+
+            //ELY文件
+            xString ptELYFile = new xString();
+            xString fibELYFile = new xString();
+            ptELYFile.AssignValue(this.m_ptTemp);
+            fibELYFile.AssignValue(this.m_fibTemp);
+            sFile.Register("PT_ELYFile", ptELYFile);
+            sFile.Register("FIB_ELYFile", fibELYFile);
+
+            //对焦方式
+            xBool focusmode = new xBool();
+            focusmode.AssignValue(this.m_fMode);
+            sFile.Register("FocusMode", focusmode);
+
+            //放大倍数和电压参数
+            xDouble stretchMagnification = new xDouble();
+            xDouble locationMagnification = new xDouble();
+            xDouble locationVoltage = new xDouble();
+            xDouble photographMagnification = new xDouble();
+            xDouble photographVoltage = new xDouble();
+            stretchMagnification.AssignValue(this.stretch_Magnification);
+            locationMagnification.AssignValue(this.location_Magnification);
+            locationVoltage.AssignValue(this.location_Voltage);
+            photographMagnification.AssignValue(this.photograph_Magnification);
+            photographVoltage.AssignValue(this.photograph_Voltage);
+            sFile.Register("Strectch_Magnification", stretchMagnification);
+            sFile.Register("Locatio_Magnification", locationMagnification);
+            sFile.Register("Location_Voltage", locationVoltage);
+            sFile.Register("Photograph_Magnification", photographMagnification);
+            sFile.Register("Photograph_Voltage", photographVoltage);
+
+            //校正角度
+            xDouble correctionAngle = new xDouble();
+            correctionAngle.AssignValue(this.correction_Angle);
+            sFile.Register("Correction_Angle", correctionAngle);
+
+            //样品名称和厂商
+            xString sampleType = new xString();
+            xString _firm = new xString();
+            sampleType.AssignValue(this.m_SampleName);
+            _firm.AssignValue(this.firm);
+            sFile.Register("Sample_Type", sampleType);
+            sFile.Register("Firm", _firm);
+
+            //对焦参数
+            sFile.Register("Focus_Param", this.focusP);
 
             if (isStoring)
             {
-                slo_msparam.Serialize(true, xml, rootNode);
+                sFile.Serialize(true, xml, rootNode);
             }
             else
             {
-                slo_msparam.Serialize(false, xml, rootNode);
+                sFile.Serialize(false, xml, rootNode);
+
+                this.is_Photograph = isPhotograph.value();
+                this.m_pt = ptDepostion.value();
+
+                this.m_ptTemp = ptELYFile.value();
+                this.m_fibTemp = fibELYFile.value();
+
+                this.m_fMode = focusmode.value();
+
+                this.stretch_Magnification = stretchMagnification.value();
+                this.location_Magnification = locationMagnification.value();
+                this.location_Voltage = locationVoltage.value();
+                this.photograph_Magnification = photographMagnification.value();
+                this.photograph_Voltage = photographVoltage.value();
+
+                this.correction_Angle = correctionAngle.value();
 
-                this.SampleName = sampleName.value();
-                this.PT = pt.value();
-                this.FIBTemp = FIBtemp.value();
-                this.PTTemp = PTtemp.value();
-                this.FocusMode = FocMode.value();
+                this.m_SampleName = sampleType.value();
+                this.firm = _firm.value();
             }
         }
 

+ 17 - 1
MeasureThread/Measure.cs

@@ -58,6 +58,14 @@ namespace MeasureThread
         }
         private String message;
 
+        //孔名
+        public String HoleName
+        {
+            get { return this.holeName; }
+            set { this.holeName = value; }
+        }
+        private String holeName;
+
         //图片信息
         public class PictureInformation
         {
@@ -1608,7 +1616,15 @@ namespace MeasureThread
 
             return true;
         }
-        
 
+        //自动聚焦
+        public bool AutoFocus(string a_strPath, out int a_nWd)
+        {
+            a_nWd = 0;
+            a_nWd = (int)Math.Ceiling(iSEM.GetWorkingDistance() * 100000000 + 0.5);//获取当前的工作距离
+
+            return true;
+
+        }
     }
 }