Browse Source

update FormUnitControl.cs

@wang_qi0307 5 years ago
parent
commit
b0e7c39ce1
1 changed files with 98 additions and 16 deletions
  1. 98 16
      HOZProject/FormUnitControl.cs

+ 98 - 16
HOZProject/FormUnitControl.cs

@@ -727,54 +727,136 @@ namespace HOZProject
         private void AutoFunction()
         private void AutoFunction()
         {
         {
             float ret = 111;
             float ret = 111;
+            Boolean state = false;
             while(true)
             while(true)
             {
             {
-                Thread.Sleep(1000);
+                //Thread.Sleep(1000);
                 ret = iSEM.GetAutoFunction();
                 ret = iSEM.GetAutoFunction();
                 if(ret==0)
                 if(ret==0)
                 {
                 {
-                    if (st_flag == 1)
+                    if (st_flag == 1 && state == true)
                     {
                     {
                         btnAutoFocus1.BackColor = Color.Lime;
                         btnAutoFocus1.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
-                    else if(st_flag==2)
+                    else if(st_flag==2 && state)
                     {
                     {
                         btnAutoFocus2.BackColor = Color.Lime;
                         btnAutoFocus2.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
                     else if (st_flag == 3)
                     else if (st_flag == 3)
                     {
                     {
                         btnAutoBrightness.BackColor = Color.Lime;
                         btnAutoBrightness.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
                     else if (st_flag == 4)
                     else if (st_flag == 4)
                     {
                     {
                         btnAutoContrast.BackColor = Color.Lime;
                         btnAutoContrast.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
                     else if (st_flag == 5)
                     else if (st_flag == 5)
                     {
                     {
                         btnAutoBrightness.BackColor = Color.Lime;
                         btnAutoBrightness.BackColor = Color.Lime;
                         btnAutoContrast.BackColor = Color.Lime;
                         btnAutoContrast.BackColor = Color.Lime;
                         btnAutoBC.BackColor = Color.Lime;
                         btnAutoBC.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
-                    else if (st_flag == 6)
+                    else if (st_flag == 6 && state)
                     {
                     {
                         btnAutoBCCancle.BackColor = Color.Lime;
                         btnAutoBCCancle.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
-                    else if (st_flag == 7)
+                    else if (st_flag == 7 && state)
                     {
                     {
                         btnAutoStig.BackColor = Color.Lime;
                         btnAutoStig.BackColor = Color.Lime;
+                        Thread.Sleep(1000);
+                        //抓图1
+                        iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                        if (File.Exists(path + "\\test2.tif"))
+                        {
+                            FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                            pictureBox2.Image = Image.FromStream(fileStream);
+                            fileStream.Close();
+                            fileStream.Dispose();
+                        }
+                        break;
                     }
                     }
 
 
-                    //抓图1
-                    iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
-                    if (File.Exists(path + "\\test2.tif"))
-                    {
-                        FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
-                        pictureBox2.Image = Image.FromStream(fileStream);
-                        fileStream.Close();
-                        fileStream.Dispose();
-                    }
-
-                    break;
+                    ////抓图1
+                    //iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
+                    //if (File.Exists(path + "\\test2.tif"))
+                    //{
+                    //    FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
+                    //    pictureBox2.Image = Image.FromStream(fileStream);
+                    //    fileStream.Close();
+                    //    fileStream.Dispose();
+                    //}
+
+                    
+                }
+                else if(ret>0 && ret<12)
+                {
+                    state = true;
                 }
                 }
             }
             }
         }
         }