From 58493dff9629a168168b63fa0c08f7b2a9cb1ad0 Mon Sep 17 00:00:00 2001
From: patrick.xu <patrick.xu@broconcentric.com>
Date: 星期三, 02 六月 2021 18:02:51 +0800
Subject: [PATCH] 1. 添加高度OK图片保存开关和动作

---
 ConfigForm.Designer.cs     |  286 +++++++++++++++++++++++++----------------------
 ConfigForm.cs              |    2 
 HeightDetection.cs         |   21 +++
 Properties/AssemblyInfo.cs |    4 
 OPCConfigStruct.cs         |    1 
 5 files changed, 174 insertions(+), 140 deletions(-)

diff --git a/ConfigForm.Designer.cs b/ConfigForm.Designer.cs
index 0c795fb..41c9a89 100644
--- a/ConfigForm.Designer.cs
+++ b/ConfigForm.Designer.cs
@@ -227,6 +227,16 @@
             this.btnXYStop = new System.Windows.Forms.Button();
             this.btnTableAction = new System.Windows.Forms.Button();
             this.tbSoft = new System.Windows.Forms.TabPage();
+            this.groupBox31 = new System.Windows.Forms.GroupBox();
+            this.nudCellMinWidth = new System.Windows.Forms.NumericUpDown();
+            this.nudCellMinLength = new System.Windows.Forms.NumericUpDown();
+            this.label149 = new System.Windows.Forms.Label();
+            this.label150 = new System.Windows.Forms.Label();
+            this.groupBox30 = new System.Windows.Forms.GroupBox();
+            this.nudCellMaxWidth = new System.Windows.Forms.NumericUpDown();
+            this.nudCellMaxLength = new System.Windows.Forms.NumericUpDown();
+            this.label148 = new System.Windows.Forms.Label();
+            this.label147 = new System.Windows.Forms.Label();
             this.chkSaveOKLWImage = new System.Windows.Forms.CheckBox();
             this.btnClearCheck = new System.Windows.Forms.Button();
             this.btnHandInit = new System.Windows.Forms.Button();
@@ -446,16 +456,7 @@
             this.groupBox27 = new System.Windows.Forms.GroupBox();
             this.groupBox28 = new System.Windows.Forms.GroupBox();
             this.groupBox29 = new System.Windows.Forms.GroupBox();
-            this.groupBox30 = new System.Windows.Forms.GroupBox();
-            this.label147 = new System.Windows.Forms.Label();
-            this.label148 = new System.Windows.Forms.Label();
-            this.nudCellMaxLength = new System.Windows.Forms.NumericUpDown();
-            this.nudCellMaxWidth = new System.Windows.Forms.NumericUpDown();
-            this.groupBox31 = new System.Windows.Forms.GroupBox();
-            this.nudCellMinWidth = new System.Windows.Forms.NumericUpDown();
-            this.nudCellMinLength = new System.Windows.Forms.NumericUpDown();
-            this.label149 = new System.Windows.Forms.Label();
-            this.label150 = new System.Windows.Forms.Label();
+            this.chkSaveHeightOK = new System.Windows.Forms.CheckBox();
             this.tabControl1.SuspendLayout();
             this.tpSetConfig.SuspendLayout();
             this.groupBox4.SuspendLayout();
@@ -471,6 +472,12 @@
             this.groupBox7.SuspendLayout();
             this.tpPLC.SuspendLayout();
             this.tbSoft.SuspendLayout();
+            this.groupBox31.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinWidth)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinLength)).BeginInit();
+            this.groupBox30.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxWidth)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxLength)).BeginInit();
             this.groupBox14.SuspendLayout();
             this.groupBox5.SuspendLayout();
             this.groupBox9.SuspendLayout();
@@ -490,12 +497,6 @@
             this.groupBox27.SuspendLayout();
             this.groupBox28.SuspendLayout();
             this.groupBox29.SuspendLayout();
-            this.groupBox30.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxLength)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxWidth)).BeginInit();
-            this.groupBox31.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinWidth)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinLength)).BeginInit();
             this.SuspendLayout();
             // 
             // btnSaveConfig
@@ -2593,6 +2594,7 @@
             // 
             this.tbSoft.Controls.Add(this.groupBox31);
             this.tbSoft.Controls.Add(this.groupBox30);
+            this.tbSoft.Controls.Add(this.chkSaveHeightOK);
             this.tbSoft.Controls.Add(this.chkSaveOKLWImage);
             this.tbSoft.Controls.Add(this.btnClearCheck);
             this.tbSoft.Location = new System.Drawing.Point(4, 22);
@@ -2603,6 +2605,120 @@
             this.tbSoft.TabIndex = 2;
             this.tbSoft.Text = "杞欢";
             this.tbSoft.UseVisualStyleBackColor = true;
+            // 
+            // groupBox31
+            // 
+            this.groupBox31.Controls.Add(this.nudCellMinWidth);
+            this.groupBox31.Controls.Add(this.nudCellMinLength);
+            this.groupBox31.Controls.Add(this.label149);
+            this.groupBox31.Controls.Add(this.label150);
+            this.groupBox31.Location = new System.Drawing.Point(236, 105);
+            this.groupBox31.Name = "groupBox31";
+            this.groupBox31.Size = new System.Drawing.Size(200, 100);
+            this.groupBox31.TabIndex = 2;
+            this.groupBox31.TabStop = false;
+            this.groupBox31.Text = "鐢垫睜闀垮涓嬮檺";
+            // 
+            // nudCellMinWidth
+            // 
+            this.nudCellMinWidth.DecimalPlaces = 2;
+            this.nudCellMinWidth.Increment = new decimal(new int[] {
+            1,
+            0,
+            0,
+            131072});
+            this.nudCellMinWidth.Location = new System.Drawing.Point(49, 60);
+            this.nudCellMinWidth.Name = "nudCellMinWidth";
+            this.nudCellMinWidth.Size = new System.Drawing.Size(120, 21);
+            this.nudCellMinWidth.TabIndex = 1;
+            // 
+            // nudCellMinLength
+            // 
+            this.nudCellMinLength.DecimalPlaces = 2;
+            this.nudCellMinLength.Increment = new decimal(new int[] {
+            1,
+            0,
+            0,
+            131072});
+            this.nudCellMinLength.Location = new System.Drawing.Point(49, 29);
+            this.nudCellMinLength.Name = "nudCellMinLength";
+            this.nudCellMinLength.Size = new System.Drawing.Size(120, 21);
+            this.nudCellMinLength.TabIndex = 1;
+            // 
+            // label149
+            // 
+            this.label149.AutoSize = true;
+            this.label149.Location = new System.Drawing.Point(13, 65);
+            this.label149.Name = "label149";
+            this.label149.Size = new System.Drawing.Size(17, 12);
+            this.label149.TabIndex = 0;
+            this.label149.Text = "瀹�";
+            // 
+            // label150
+            // 
+            this.label150.AutoSize = true;
+            this.label150.Location = new System.Drawing.Point(13, 31);
+            this.label150.Name = "label150";
+            this.label150.Size = new System.Drawing.Size(17, 12);
+            this.label150.TabIndex = 0;
+            this.label150.Text = "闀�";
+            // 
+            // groupBox30
+            // 
+            this.groupBox30.Controls.Add(this.nudCellMaxWidth);
+            this.groupBox30.Controls.Add(this.nudCellMaxLength);
+            this.groupBox30.Controls.Add(this.label148);
+            this.groupBox30.Controls.Add(this.label147);
+            this.groupBox30.Location = new System.Drawing.Point(15, 104);
+            this.groupBox30.Name = "groupBox30";
+            this.groupBox30.Size = new System.Drawing.Size(200, 100);
+            this.groupBox30.TabIndex = 2;
+            this.groupBox30.TabStop = false;
+            this.groupBox30.Text = "鐢垫睜闀垮涓婇檺";
+            // 
+            // nudCellMaxWidth
+            // 
+            this.nudCellMaxWidth.DecimalPlaces = 2;
+            this.nudCellMaxWidth.Increment = new decimal(new int[] {
+            1,
+            0,
+            0,
+            131072});
+            this.nudCellMaxWidth.Location = new System.Drawing.Point(49, 60);
+            this.nudCellMaxWidth.Name = "nudCellMaxWidth";
+            this.nudCellMaxWidth.Size = new System.Drawing.Size(120, 21);
+            this.nudCellMaxWidth.TabIndex = 1;
+            // 
+            // nudCellMaxLength
+            // 
+            this.nudCellMaxLength.DecimalPlaces = 2;
+            this.nudCellMaxLength.Increment = new decimal(new int[] {
+            1,
+            0,
+            0,
+            131072});
+            this.nudCellMaxLength.Location = new System.Drawing.Point(49, 29);
+            this.nudCellMaxLength.Name = "nudCellMaxLength";
+            this.nudCellMaxLength.Size = new System.Drawing.Size(120, 21);
+            this.nudCellMaxLength.TabIndex = 1;
+            // 
+            // label148
+            // 
+            this.label148.AutoSize = true;
+            this.label148.Location = new System.Drawing.Point(13, 65);
+            this.label148.Name = "label148";
+            this.label148.Size = new System.Drawing.Size(17, 12);
+            this.label148.TabIndex = 0;
+            this.label148.Text = "瀹�";
+            // 
+            // label147
+            // 
+            this.label147.AutoSize = true;
+            this.label147.Location = new System.Drawing.Point(13, 31);
+            this.label147.Name = "label147";
+            this.label147.Size = new System.Drawing.Size(17, 12);
+            this.label147.TabIndex = 0;
+            this.label147.Text = "闀�";
             // 
             // chkSaveOKLWImage
             // 
@@ -4680,119 +4796,16 @@
             this.groupBox29.TabStop = false;
             this.groupBox29.Text = "FAI 10";
             // 
-            // groupBox30
+            // chkSaveHeightOK
             // 
-            this.groupBox30.Controls.Add(this.nudCellMaxWidth);
-            this.groupBox30.Controls.Add(this.nudCellMaxLength);
-            this.groupBox30.Controls.Add(this.label148);
-            this.groupBox30.Controls.Add(this.label147);
-            this.groupBox30.Location = new System.Drawing.Point(15, 104);
-            this.groupBox30.Name = "groupBox30";
-            this.groupBox30.Size = new System.Drawing.Size(200, 100);
-            this.groupBox30.TabIndex = 2;
-            this.groupBox30.TabStop = false;
-            this.groupBox30.Text = "鐢垫睜闀垮涓婇檺";
-            // 
-            // label147
-            // 
-            this.label147.AutoSize = true;
-            this.label147.Location = new System.Drawing.Point(13, 31);
-            this.label147.Name = "label147";
-            this.label147.Size = new System.Drawing.Size(17, 12);
-            this.label147.TabIndex = 0;
-            this.label147.Text = "闀�";
-            // 
-            // label148
-            // 
-            this.label148.AutoSize = true;
-            this.label148.Location = new System.Drawing.Point(13, 65);
-            this.label148.Name = "label148";
-            this.label148.Size = new System.Drawing.Size(17, 12);
-            this.label148.TabIndex = 0;
-            this.label148.Text = "瀹�";
-            // 
-            // nudCellMaxLength
-            // 
-            this.nudCellMaxLength.DecimalPlaces = 2;
-            this.nudCellMaxLength.Increment = new decimal(new int[] {
-            1,
-            0,
-            0,
-            131072});
-            this.nudCellMaxLength.Location = new System.Drawing.Point(49, 29);
-            this.nudCellMaxLength.Name = "nudCellMaxLength";
-            this.nudCellMaxLength.Size = new System.Drawing.Size(120, 21);
-            this.nudCellMaxLength.TabIndex = 1;
-            // 
-            // nudCellMaxWidth
-            // 
-            this.nudCellMaxWidth.DecimalPlaces = 2;
-            this.nudCellMaxWidth.Increment = new decimal(new int[] {
-            1,
-            0,
-            0,
-            131072});
-            this.nudCellMaxWidth.Location = new System.Drawing.Point(49, 60);
-            this.nudCellMaxWidth.Name = "nudCellMaxWidth";
-            this.nudCellMaxWidth.Size = new System.Drawing.Size(120, 21);
-            this.nudCellMaxWidth.TabIndex = 1;
-            // 
-            // groupBox31
-            // 
-            this.groupBox31.Controls.Add(this.nudCellMinWidth);
-            this.groupBox31.Controls.Add(this.nudCellMinLength);
-            this.groupBox31.Controls.Add(this.label149);
-            this.groupBox31.Controls.Add(this.label150);
-            this.groupBox31.Location = new System.Drawing.Point(236, 105);
-            this.groupBox31.Name = "groupBox31";
-            this.groupBox31.Size = new System.Drawing.Size(200, 100);
-            this.groupBox31.TabIndex = 2;
-            this.groupBox31.TabStop = false;
-            this.groupBox31.Text = "鐢垫睜闀垮涓嬮檺";
-            // 
-            // nudCellMinWidth
-            // 
-            this.nudCellMinWidth.DecimalPlaces = 2;
-            this.nudCellMinWidth.Increment = new decimal(new int[] {
-            1,
-            0,
-            0,
-            131072});
-            this.nudCellMinWidth.Location = new System.Drawing.Point(49, 60);
-            this.nudCellMinWidth.Name = "nudCellMinWidth";
-            this.nudCellMinWidth.Size = new System.Drawing.Size(120, 21);
-            this.nudCellMinWidth.TabIndex = 1;
-            // 
-            // nudCellMinLength
-            // 
-            this.nudCellMinLength.DecimalPlaces = 2;
-            this.nudCellMinLength.Increment = new decimal(new int[] {
-            1,
-            0,
-            0,
-            131072});
-            this.nudCellMinLength.Location = new System.Drawing.Point(49, 29);
-            this.nudCellMinLength.Name = "nudCellMinLength";
-            this.nudCellMinLength.Size = new System.Drawing.Size(120, 21);
-            this.nudCellMinLength.TabIndex = 1;
-            // 
-            // label149
-            // 
-            this.label149.AutoSize = true;
-            this.label149.Location = new System.Drawing.Point(13, 65);
-            this.label149.Name = "label149";
-            this.label149.Size = new System.Drawing.Size(17, 12);
-            this.label149.TabIndex = 0;
-            this.label149.Text = "瀹�";
-            // 
-            // label150
-            // 
-            this.label150.AutoSize = true;
-            this.label150.Location = new System.Drawing.Point(13, 31);
-            this.label150.Name = "label150";
-            this.label150.Size = new System.Drawing.Size(17, 12);
-            this.label150.TabIndex = 0;
-            this.label150.Text = "闀�";
+            this.chkSaveHeightOK.AutoSize = true;
+            this.chkSaveHeightOK.Location = new System.Drawing.Point(172, 65);
+            this.chkSaveHeightOK.Name = "chkSaveHeightOK";
+            this.chkSaveHeightOK.Size = new System.Drawing.Size(132, 16);
+            this.chkSaveHeightOK.TabIndex = 1;
+            this.chkSaveHeightOK.Text = "淇濆瓨楂樺害妫�娴婳K鍥剧墖";
+            this.chkSaveHeightOK.UseVisualStyleBackColor = true;
+            this.chkSaveHeightOK.CheckedChanged += new System.EventHandler(this.chkSaveOKLWImage_CheckedChanged);
             // 
             // ConfigForm
             // 
@@ -4831,6 +4844,14 @@
             this.tpPLC.ResumeLayout(false);
             this.tbSoft.ResumeLayout(false);
             this.tbSoft.PerformLayout();
+            this.groupBox31.ResumeLayout(false);
+            this.groupBox31.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinWidth)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinLength)).EndInit();
+            this.groupBox30.ResumeLayout(false);
+            this.groupBox30.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxWidth)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxLength)).EndInit();
             this.groupBox14.ResumeLayout(false);
             this.groupBox5.ResumeLayout(false);
             this.groupBox5.PerformLayout();
@@ -4866,14 +4887,6 @@
             this.groupBox28.PerformLayout();
             this.groupBox29.ResumeLayout(false);
             this.groupBox29.PerformLayout();
-            this.groupBox30.ResumeLayout(false);
-            this.groupBox30.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxLength)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMaxWidth)).EndInit();
-            this.groupBox31.ResumeLayout(false);
-            this.groupBox31.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinWidth)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.nudCellMinLength)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -5308,5 +5321,6 @@
         private System.Windows.Forms.NumericUpDown nudCellMaxLength;
         private System.Windows.Forms.Label label148;
         private System.Windows.Forms.Label label147;
+        private System.Windows.Forms.CheckBox chkSaveHeightOK;
     }
 }
\ No newline at end of file
diff --git a/ConfigForm.cs b/ConfigForm.cs
index 4f81488..fa059f4 100644
--- a/ConfigForm.cs
+++ b/ConfigForm.cs
@@ -117,6 +117,7 @@
             LoadDeviceStatus();
 
             chkSaveOKLWImage.Checked = config.IsSaveSizeOKImage;
+            chkSaveHeightOK.Checked = config.IsSaveHeightOKImage;
 
             nudCellMaxLength.Value = (decimal)config.MaxLength;
             nudCellMaxWidth.Value = (decimal)config.MaxWidth;
@@ -803,6 +804,7 @@
         private void chkSaveOKLWImage_CheckedChanged(object sender, EventArgs e)
         {
             config.IsSaveSizeOKImage = chkSaveOKLWImage.Checked;
+            config.IsSaveHeightOKImage = chkSaveHeightOK.Checked;
         }
         #endregion
     }
diff --git a/HeightDetection.cs b/HeightDetection.cs
index c237cda..2df4a4a 100644
--- a/HeightDetection.cs
+++ b/HeightDetection.cs
@@ -125,7 +125,10 @@
 
                     CommonUtil.mainForm.Invoke(new Action(() => CommonUtil.mainForm.AppendDetectionData(productNo)));
                     int detectID = CommonUtil.StepControl.GetDetectHeightID();
-                    string tempFileName = CommonUtil.mainForm.PlateID.ToString() + "_" + productNo.Trim().Replace("/", "").Replace("\"", "'") + "_" + DateTime.Now.ToString("HHmmssff") + "_" + detectID.ToString();
+
+                    int slotNum = (CommonUtil.mainForm.PlateID + 1) % 5 + 1;
+
+                    string tempFileName = slotNum.ToString() + "_" + productNo.Trim().Replace("/", "").Replace("\"", "'") + "_" + DateTime.Now.ToString("HHmmssff") + "_" + detectID.ToString();
                     if (productNo.Trim().Length == CommonUtil.ProductNoLength)
                     {
                         string productNoFileName = CommonUtil.ProductNoImageDir + @"\" + productNo + "_" + detectID.ToString();
@@ -165,7 +168,7 @@
                                 double compv = 0.0;
                                 Type t = opcConfig.compensationZ.GetType();
 
-                                int slotNum = (CommonUtil.mainForm.PlateID + 1) % 5 + 1;
+
                                 FieldInfo fi = t.GetField(string.Format("station{0}", slotNum));
                                 compv = (double)fi.GetValue(opcConfig.compensationZ);
 
@@ -227,6 +230,20 @@
                         {
                             heightFileName = VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + $"_{heightResult.ToString()}\\{ tempFileName}");
                         }
+                        else
+                        {
+                            if (opcConfig.IsSaveHeightOKImage)
+                            {
+                                //DateTime dt = DateTime.Now;
+
+                                //if (dt.Second >= 10 && dt.Second <= 15)
+                                {
+                                    VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + @"_OK\" + tempFileName);
+                                }
+                            }
+
+                        }
+
                         CommonUtil.WriteLog(LogType.Inf, string.Format("楂樺害妫�娴嬪畬鎴�,缁撴灉锛歿0} H:{1:F4}, {2:F4}, {3}, {4}", productNo,
                             batteryHeight[0], batteryHeight[1], timeStr, CommonUtil.StepControl.ToString()));
                     }
diff --git a/OPCConfigStruct.cs b/OPCConfigStruct.cs
index e6b705a..2c17c53 100644
--- a/OPCConfigStruct.cs
+++ b/OPCConfigStruct.cs
@@ -207,6 +207,7 @@
 
         #region add by Patrick
         public bool IsSaveSizeOKImage;
+        public bool IsSaveHeightOKImage;
         public float MaxLength;
         public float MaxWidth;
         public float MinLength;
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 90a2bfd..1e323d3 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
 // 鍙互鎸囧畾鎵�鏈夎繖浜涘�硷紝涔熷彲浠ヤ娇鐢ㄢ�滃唴閮ㄧ増鏈彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊硷紝
 // 鏂规硶鏄寜濡備笅鎵�绀轰娇鐢ㄢ��*鈥�:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("1.0.3.0")]

--
Gitblit v1.8.0