Explorar o código

连拍功能待测试

cxs hai 1 ano
pai
achega
e2035dd535

+ 89 - 36
OTSSysMgrApp/ControllerSettingForm.Designer.cs

@@ -59,6 +59,9 @@
             this.lblResolution = new System.Windows.Forms.Label();
             this.tabImage2 = new System.Windows.Forms.TabPage();
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.label3 = new System.Windows.Forms.Label();
+            this.tB_scanFieldSize100 = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
             this.btn_confirm = new System.Windows.Forms.Button();
             this.cb_Ydirection = new System.Windows.Forms.ComboBox();
             this.label_y = new System.Windows.Forms.Label();
@@ -69,9 +72,10 @@
             this.pictureBox4 = new System.Windows.Forms.PictureBox();
             this.pictureBox2 = new System.Windows.Forms.PictureBox();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.label1 = new System.Windows.Forms.Label();
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.label3 = new System.Windows.Forms.Label();
+            this.Pic_height = new System.Windows.Forms.TextBox();
+            this.Pic_width = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
             this.tabSetting.SuspendLayout();
             this.tabXRay.SuspendLayout();
             this.groupBox1.SuspendLayout();
@@ -121,7 +125,7 @@
             this.tabXRay.Margin = new System.Windows.Forms.Padding(2);
             this.tabXRay.Name = "tabXRay";
             this.tabXRay.Padding = new System.Windows.Forms.Padding(2);
-            this.tabXRay.Size = new System.Drawing.Size(825, 660);
+            this.tabXRay.Size = new System.Drawing.Size(825, 705);
             this.tabXRay.TabIndex = 0;
             this.tabXRay.Text = "X-Ray设置";
             this.tabXRay.UseVisualStyleBackColor = true;
@@ -292,7 +296,7 @@
             this.tabImage.Margin = new System.Windows.Forms.Padding(2);
             this.tabImage.Name = "tabImage";
             this.tabImage.Padding = new System.Windows.Forms.Padding(2);
-            this.tabImage.Size = new System.Drawing.Size(825, 660);
+            this.tabImage.Size = new System.Drawing.Size(825, 705);
             this.tabImage.TabIndex = 1;
             this.tabImage.Text = "BSE设置";
             this.tabImage.UseVisualStyleBackColor = true;
@@ -450,8 +454,12 @@
             // 
             // splitContainer1.Panel1
             // 
+            this.splitContainer1.Panel1.Controls.Add(this.label5);
+            this.splitContainer1.Panel1.Controls.Add(this.Pic_height);
+            this.splitContainer1.Panel1.Controls.Add(this.Pic_width);
+            this.splitContainer1.Panel1.Controls.Add(this.label4);
             this.splitContainer1.Panel1.Controls.Add(this.label3);
-            this.splitContainer1.Panel1.Controls.Add(this.textBox1);
+            this.splitContainer1.Panel1.Controls.Add(this.tB_scanFieldSize100);
             this.splitContainer1.Panel1.Controls.Add(this.label1);
             this.splitContainer1.Panel1.Controls.Add(this.btn_confirm);
             this.splitContainer1.Panel1.Controls.Add(this.cb_Ydirection);
@@ -470,14 +478,41 @@
             this.splitContainer1.SplitterDistance = 85;
             this.splitContainer1.TabIndex = 2;
             // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(533, 11);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(29, 12);
+            this.label3.TabIndex = 8;
+            this.label3.Text = "毫米";
+            // 
+            // tB_scanFieldSize100
+            // 
+            this.tB_scanFieldSize100.Location = new System.Drawing.Point(427, 7);
+            this.tB_scanFieldSize100.Name = "tB_scanFieldSize100";
+            this.tB_scanFieldSize100.Size = new System.Drawing.Size(100, 21);
+            this.tB_scanFieldSize100.TabIndex = 7;
+            this.tB_scanFieldSize100.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(327, 11);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(107, 12);
+            this.label1.TabIndex = 6;
+            this.label1.Text = "100倍下屏幕宽度:";
+            // 
             // btn_confirm
             // 
-            this.btn_confirm.Location = new System.Drawing.Point(730, 5);
+            this.btn_confirm.Location = new System.Drawing.Point(730, 11);
             this.btn_confirm.Name = "btn_confirm";
-            this.btn_confirm.Size = new System.Drawing.Size(75, 23);
+            this.btn_confirm.Size = new System.Drawing.Size(75, 60);
             this.btn_confirm.TabIndex = 5;
-            this.btn_confirm.Text = "确定";
+            this.btn_confirm.Text = "上传参数";
             this.btn_confirm.UseVisualStyleBackColor = true;
+            this.btn_confirm.Click += new System.EventHandler(this.btn_confirm_Click);
             // 
             // cb_Ydirection
             // 
@@ -515,9 +550,9 @@
             // 
             // bn_continuousshot
             // 
-            this.bn_continuousshot.Location = new System.Drawing.Point(649, 4);
+            this.bn_continuousshot.Location = new System.Drawing.Point(649, 11);
             this.bn_continuousshot.Name = "bn_continuousshot";
-            this.bn_continuousshot.Size = new System.Drawing.Size(75, 23);
+            this.bn_continuousshot.Size = new System.Drawing.Size(75, 61);
             this.bn_continuousshot.TabIndex = 0;
             this.bn_continuousshot.Text = "连拍";
             this.bn_continuousshot.UseVisualStyleBackColor = true;
@@ -567,30 +602,44 @@
             this.pictureBox1.TabIndex = 1;
             this.pictureBox1.TabStop = false;
             // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(327, 11);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(107, 12);
-            this.label1.TabIndex = 6;
-            this.label1.Text = "100倍下屏幕宽度:";
-            // 
-            // textBox1
-            // 
-            this.textBox1.Location = new System.Drawing.Point(427, 7);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(100, 21);
-            this.textBox1.TabIndex = 7;
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(533, 11);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(29, 12);
-            this.label3.TabIndex = 8;
-            this.label3.Text = "毫米";
+            // Pic_height
+            // 
+            this.Pic_height.Location = new System.Drawing.Point(137, 44);
+            this.Pic_height.Margin = new System.Windows.Forms.Padding(2);
+            this.Pic_height.Name = "Pic_height";
+            this.Pic_height.Size = new System.Drawing.Size(48, 21);
+            this.Pic_height.TabIndex = 12;
+            this.Pic_height.Text = "768";
+            this.Pic_height.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+            // 
+            // Pic_width
+            // 
+            this.Pic_width.Location = new System.Drawing.Point(68, 44);
+            this.Pic_width.Margin = new System.Windows.Forms.Padding(2);
+            this.Pic_width.Name = "Pic_width";
+            this.Pic_width.Size = new System.Drawing.Size(48, 21);
+            this.Pic_width.TabIndex = 11;
+            this.Pic_width.Text = "1024";
+            this.Pic_width.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(7, 48);
+            this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(47, 12);
+            this.label4.TabIndex = 13;
+            this.label4.Text = "分辨率:";
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(121, 48);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(11, 12);
+            this.label5.TabIndex = 14;
+            this.label5.Text = "*";
             // 
             // ControllerSettingForm
             // 
@@ -671,7 +720,11 @@
         private System.Windows.Forms.ComboBox cb_Ydirection;
         private System.Windows.Forms.Label label_y;
         private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.TextBox tB_scanFieldSize100;
         private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.TextBox Pic_height;
+        private System.Windows.Forms.TextBox Pic_width;
+        private System.Windows.Forms.Label label4;
     }
 }

+ 129 - 52
OTSSysMgrApp/ControllerSettingForm.cs

@@ -151,11 +151,13 @@ namespace OTSSysMgrApp
             int height =Convert.ToInt32(tbRHeight.Text);
             m_EDSHardwareMgr = EDSController.GetEDSController(width,height,5000);
 
-            cb_Xdirection.Items.Add("left");
-            cb_Xdirection.Items.Add("right");
-            cb_Ydirection.Items.Add("up");
-            cb_Ydirection.Items.Add("down");
-
+            cb_Xdirection.Items.Add("LEFT_TOWARD");
+            cb_Xdirection.Items.Add("RIGHT_TOWARD");
+            cb_Ydirection.Items.Add("UP_TOWARD");
+            cb_Ydirection.Items.Add("DOWN_TOWARD");
+            tB_scanFieldSize100.Text = "1270";
+            cb_Xdirection.SelectedIndex = 0;
+            cb_Ydirection.SelectedIndex = 0;
         }
 
         Thread ScanThread = null;
@@ -1151,6 +1153,15 @@ namespace OTSSysMgrApp
 
         private void bn_continuousshot_Click(object sender, EventArgs e)
         {
+            pictureBox1.Image = null;
+            pictureBox2.Image = null;
+            pictureBox3.Image = null;
+            pictureBox4.Image = null;
+
+
+            bn_continuousshot.Enabled = false;
+            this.Refresh();
+
             ISemController m_Sem= SemController.GetSEMController();
 
             //电镜设置对象
@@ -1160,83 +1171,149 @@ namespace OTSSysMgrApp
 
             double Magnification = 0;
             m_Sem.GetMagnification(ref Magnification);
+
             double a_dScanFieldSizeX = 0;
             double a_dScanFieldSizeY = 0;
             m_Sem.GetScanFieldSize(ref a_dScanFieldSizeX,ref a_dScanFieldSizeY);
 
+            double scanFieldSize100 = 0;
+            double.TryParse(tB_scanFieldSize100.Text, out scanFieldSize100);
+            double scanFieldSize = scanFieldSize100 / 100 * Magnification;
+
             double PositionX = 0;
             double PositionY = 0;
             double PositionR = 0;
             m_Sem.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR);
-            for(int i=0;i<4;i++)
-            {
-                PositionX += a_dScanFieldSizeX;
-                PositionY += a_dScanFieldSizeY;
-                m_Sem.MoveSEMToPoint(PositionX, PositionY);
-            }
 
+            //设置图像分辨率
+            int width = Convert.ToInt32(Pic_width.Text);
+            int height = Convert.ToInt32(Pic_height.Text);
 
+            double scanFieldSizeH = scanFieldSize * height / width;
+
+            m_Sem.SetScanExternal(true);
 
             try
             {
-                string str1 = table["str1"].ToString();
-                btnDisplay.Text = str1;
-                btnDisplay.Enabled = false;
-                btnDisplay.Refresh();
-                if (pbImage.Image != null)
+                for (int i = 0; i < 4; i++)
                 {
-                    pbImage.Image = null;
-                    pbImage.Refresh();
-                }
-                Thread.Sleep(100);
+                    if (i == 0)
+                    {
 
-                //设置图像分辨率
-                int width = 0;
-                int height = 0;
-                //获取宽度
-                width = Convert.ToInt32(tbRWidth.Text);
-                height = Convert.ToInt32(tbRHeight.Text);
-
-                byte[] ImageByte = new byte[width * height];
-                Bitmap bitmap = null;
-                int iWidth = Convert.ToInt32(tbRWidth.Text);
-                int iHeight = Convert.ToInt32(tbRHeight.Text);
-                bool resultValue = GetScanImage(iWidth, iHeight, ddlDwellTime.Text, ref ImageByte);
-                string str2 = table["str2"].ToString();
-
-                if (resultValue)
-                {
-                    if (ImageByte != null)
+                    }
+                    else if (i == 1)
+                    {
+                        switch (cb_Xdirection.SelectedItem.ToString())
+                        {
+                            case "RIGHT_TOWARD": PositionX += scanFieldSize; break;
+                            default: PositionX -= scanFieldSize; break;
+                        }
+                    }
+                    else if(i==2)
                     {
-                        bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
-                        pbImage.Image = bitmap;
-                        btnSaveImage.Enabled = true;
-                        log.Info("Image capture success!\nImage resolution:" + tbRWidth.Text + "X" + tbRHeight.Text + ";");
+                        switch (cb_Ydirection.SelectedItem.ToString())
+                        {
+                            case "UP_TOWARD": PositionY -= scanFieldSizeH; break;
+                            default: PositionY += scanFieldSizeH; break;
+                        }
                     }
                     else
                     {
-                        MessageBox.Show(str2, "Tip");
+                        switch (cb_Xdirection.SelectedItem.ToString())
+                        {
+                            case "RIGHT_TOWARD": PositionX -= scanFieldSize; break;
+                            default: PositionX += scanFieldSize; break;
+                        }
                     }
-                }
-                else
-                {
-                    MessageBox.Show(str2, "Tip");
-                }
+                    m_Sem.MoveSEMToPoint(PositionX, PositionY);
 
+                    byte[] ImageByte = new byte[width * height];
+                    bool resultValue = GetScanImage(Width, height, "4", ref ImageByte);
+                    string str2 = table["str2"].ToString();
 
+                    if (resultValue)
+                    {
+                        if (ImageByte != null)
+                        {
+                            var bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
+                            switch(i)
+                            {
+                                case 0:
+                                    pictureBox1.Image = bitmap;
+                                    break;
+                                case 1:
+                                    pictureBox2.Image = bitmap;
+                                    break;
+                                case 2:
+                                    pictureBox3.Image = bitmap;
+                                    break;
+                                case 3:
+                                    pictureBox4.Image = bitmap;
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show(str2, "Tip");
+                        }
+                    }
+                    else
+                    {
+                        MessageBox.Show(str2, "Tip");
+                    }
+                }
 
             }
             catch (Exception ex)
             {
-                log.Error("ControllerSettingForm_btnDisplay_Click--错误信息:" + ex.ToString());
+                log.Error("continuousshot--错误信息:" + ex.ToString());
             }
             finally
             {
-                string str = table["btndisplay"].ToString();
-                btnDisplay.Text = str;
-                btnDisplay.Enabled = true;
-                btnDisplay.Refresh();
+                m_Sem.SetScanExternal(false);
+                m_Sem.DisConnect();
+                bn_continuousshot.Enabled = true;
+                bn_continuousshot.Refresh();
             }
         }
+
+
+        bool SaveConfigXml(string xmlpath,string xAxisDir, string yAxisDir, string scanFieldSize)
+        {
+            try
+            {
+                XmlDocument xmlDocument = new XmlDocument();
+                xmlDocument.Load(xmlpath);
+                XmlNodeList nodeList = xmlDocument.SelectSingleNode("XMLData").ChildNodes;//获取Employees节点的所有子节点
+
+                foreach (XmlNode xn in nodeList)//遍历
+                {
+                    XmlElement xe = (XmlElement)xn;
+                    if (xe.GetAttribute("RegName") == "StageData")
+                    {
+                        xe.SetAttribute("scanFieldSize", scanFieldSize);
+                        xe.SetAttribute("xAxisDir", xAxisDir);
+                        xe.SetAttribute("yAxisDir", yAxisDir);
+                        break;
+                    }
+                }
+
+                xmlDocument.Save(xmlpath);
+            }
+            catch(Exception ex)
+            {
+                MessageBox.Show(ex.ToString());
+                return false;
+            }
+            return true;
+        }
+
+        private void btn_confirm_Click(object sender, EventArgs e)
+        {
+            string xmlpath = Application.StartupPath + @"\Config\SysData\OTSProgMgrParam.pmf";
+            string xAxisDir = "1:" + cb_Xdirection.SelectedItem.ToString(); ;
+            string yAxisDir = "0:"+cb_Ydirection.Text;
+            SaveConfigXml(xmlpath, xAxisDir, yAxisDir, tB_scanFieldSize100.Text);
+        }
     }
 }