From 1a54dcdf2cbf9d7dd99662e3a32032dffe15baba Mon Sep 17 00:00:00 2001 From: gebo Date: Wed, 5 Nov 2025 14:48:41 +0800 Subject: [PATCH] add debug checkbox for test --- TetraParkOCR/Form1.Designer.cs | 29 ++++++++++++-------------- TetraParkOCR/Form1.cs | 38 ++++++++++++++-------------------- TetraParkOCR/Form1.resx | 3 +++ 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/TetraParkOCR/Form1.Designer.cs b/TetraParkOCR/Form1.Designer.cs index 3e4e459..b99ce95 100644 --- a/TetraParkOCR/Form1.Designer.cs +++ b/TetraParkOCR/Form1.Designer.cs @@ -109,9 +109,9 @@ this.panel_auto = new System.Windows.Forms.Panel(); this.panel_locationDisplay = new System.Windows.Forms.Panel(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.button2 = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); this.lbl_height = new System.Windows.Forms.Label(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); this.tableLayoutPanel_productInformtion.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.Location_Display)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Ocr_picBox)).BeginInit(); @@ -1011,7 +1011,7 @@ // // panel_midup // - this.panel_midup.Controls.Add(this.button2); + this.panel_midup.Controls.Add(this.checkBox1); this.panel_midup.Controls.Add(this.button1); this.panel_midup.Controls.Add(this.listBox1); this.panel_midup.Controls.Add(this.btn_StarDet_manual); @@ -1113,19 +1113,6 @@ this.panel_locationDisplay.Size = new System.Drawing.Size(478, 388); this.panel_locationDisplay.TabIndex = 0; // - // button2 - // - this.button2.BackColor = System.Drawing.Color.LimeGreen; - this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.button2.Location = new System.Drawing.Point(26, 219); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(149, 46); - this.button2.TabIndex = 28; - this.button2.Text = "测试坐标"; - this.toolTip.SetToolTip(this.button2, "此操作为当前暂定方式"); - this.button2.UseVisualStyleBackColor = false; - // // label5 // this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -1149,6 +1136,16 @@ this.lbl_height.TabIndex = 29; this.lbl_height.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(106, 237); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(84, 16); + this.checkBox1.TabIndex = 28; + this.checkBox1.Text = "仅计算坐标"; + this.checkBox1.UseVisualStyleBackColor = true; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1266,9 +1263,9 @@ private System.Windows.Forms.ListView list_Log; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; private System.Windows.Forms.Label lbl_height; private System.Windows.Forms.Label label5; + private System.Windows.Forms.CheckBox checkBox1; } } diff --git a/TetraParkOCR/Form1.cs b/TetraParkOCR/Form1.cs index 2353e7b..ddbe13a 100644 --- a/TetraParkOCR/Form1.cs +++ b/TetraParkOCR/Form1.cs @@ -976,6 +976,7 @@ namespace TetraPackOCR log.Info("手动触发定位"); } private bool autorunFlag = false; + private bool debugFlag = false; private void btn_StarDet_manual_Click(object sender, EventArgs e) { if (camOCROpened == false || camDETOpened == false) @@ -998,6 +999,7 @@ namespace TetraPackOCR InitLableColumn(); ocrAcc.Clear(); + debugFlag = checkBox1.Checked; autorunFlag = check_Autorun.Checked; btn_StarDet_manual.Enabled = false; button1.Enabled = true; @@ -1157,12 +1159,7 @@ namespace TetraPackOCR { EnableStartDetect(); log.Error(ex.Message + "未检测到K标志"); - if (check_Autorun.Checked == false) - { - byte[] datax = DataConverter.FloatToByte(0.0f, true); - cc24?.NotifyCamInspectionComplete(0, datax); - cc24?.NotifyCamAcqComplete(0); - } + NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true)); } } @@ -1417,6 +1414,14 @@ namespace TetraPackOCR cc24?.NotifyCamAcqComplete(1); } } + private void NoticePLCCompleteDet(byte[] datax) + { + if (autorunFlag == false) + { + cc24?.NotifyCamInspectionComplete(0, datax); + cc24?.NotifyCamAcqComplete(0); + } + } private OCRTextResult OCRBytes(byte[] ocrimagebyte) { try @@ -2053,23 +2058,19 @@ namespace TetraPackOCR { EnableStartDetect(); log.Error("x范围 0,1600!"); - byte[] datax = DataConverter.FloatToByte(0.0f, true); - cc24?.NotifyCamInspectionComplete(0, datax); - cc24?.NotifyCamAcqComplete(0); + NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true)); return; } if (ocryy[item] < -50 || ocryy[item] > 400) { EnableStartDetect(); log.Error("y范围 -50,400!"); - byte[] datax = DataConverter.FloatToByte(0.0f, true); - cc24?.NotifyCamInspectionComplete(0, datax); - cc24?.NotifyCamAcqComplete(0); + NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true)); return; } } - if (check_Autorun.Checked == false) + if (check_Autorun.Checked == false && !debugFlag) { List d = new List(); for (int i = 0; i < l.Count; i++) @@ -2084,9 +2085,7 @@ namespace TetraPackOCR d.Add(l[l.Count - i]); } } - byte[] datax = DataConverter.FloatToByte(d, true); - cc24?.NotifyCamInspectionComplete(0, datax); - cc24?.NotifyCamAcqComplete(0); + NoticePLCCompleteDet(DataConverter.FloatToByte(d, true)); log.Info("坐标已发送完成。"); } } @@ -2094,12 +2093,7 @@ namespace TetraPackOCR { EnableStartDetect(); log.Error(ex.Message + "未检测到K标志"); - if (check_Autorun.Checked == false) - { - byte[] datax = DataConverter.FloatToByte(0.0f, true); - cc24?.NotifyCamInspectionComplete(0, datax); - cc24?.NotifyCamAcqComplete(0); - } + NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true)); } } #endregion diff --git a/TetraParkOCR/Form1.resx b/TetraParkOCR/Form1.resx index fb26f55..2f51d37 100644 --- a/TetraParkOCR/Form1.resx +++ b/TetraParkOCR/Form1.resx @@ -4866,6 +4866,9 @@ 162, 17 + + 335, 17 + 25