add debug checkbox for test

This commit is contained in:
2025-11-05 14:48:41 +08:00
parent 292075db7f
commit 1a54dcdf2c
3 changed files with 32 additions and 38 deletions

View File

@@ -109,9 +109,9 @@
this.panel_auto = new System.Windows.Forms.Panel(); this.panel_auto = new System.Windows.Forms.Panel();
this.panel_locationDisplay = new System.Windows.Forms.Panel(); this.panel_locationDisplay = new System.Windows.Forms.Panel();
this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.button2 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.lbl_height = new System.Windows.Forms.Label(); this.lbl_height = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel_productInformtion.SuspendLayout(); this.tableLayoutPanel_productInformtion.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.Location_Display)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Location_Display)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.Ocr_picBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.Ocr_picBox)).BeginInit();
@@ -1011,7 +1011,7 @@
// //
// panel_midup // 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.button1);
this.panel_midup.Controls.Add(this.listBox1); this.panel_midup.Controls.Add(this.listBox1);
this.panel_midup.Controls.Add(this.btn_StarDet_manual); 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.Size = new System.Drawing.Size(478, 388);
this.panel_locationDisplay.TabIndex = 0; 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 // label5
// //
this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.TabIndex = 29;
this.lbl_height.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 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 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1266,9 +1263,9 @@
private System.Windows.Forms.ListView list_Log; private System.Windows.Forms.ListView list_Log;
private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label lbl_height; private System.Windows.Forms.Label lbl_height;
private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox checkBox1;
} }
} }

View File

@@ -976,6 +976,7 @@ namespace TetraPackOCR
log.Info("手动触发定位"); log.Info("手动触发定位");
} }
private bool autorunFlag = false; private bool autorunFlag = false;
private bool debugFlag = false;
private void btn_StarDet_manual_Click(object sender, EventArgs e) private void btn_StarDet_manual_Click(object sender, EventArgs e)
{ {
if (camOCROpened == false || camDETOpened == false) if (camOCROpened == false || camDETOpened == false)
@@ -998,6 +999,7 @@ namespace TetraPackOCR
InitLableColumn(); InitLableColumn();
ocrAcc.Clear(); ocrAcc.Clear();
debugFlag = checkBox1.Checked;
autorunFlag = check_Autorun.Checked; autorunFlag = check_Autorun.Checked;
btn_StarDet_manual.Enabled = false; btn_StarDet_manual.Enabled = false;
button1.Enabled = true; button1.Enabled = true;
@@ -1157,12 +1159,7 @@ namespace TetraPackOCR
{ {
EnableStartDetect(); EnableStartDetect();
log.Error(ex.Message + "未检测到K标志"); log.Error(ex.Message + "未检测到K标志");
if (check_Autorun.Checked == false) NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
{
byte[] datax = DataConverter.FloatToByte(0.0f, true);
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
}
} }
} }
@@ -1417,6 +1414,14 @@ namespace TetraPackOCR
cc24?.NotifyCamAcqComplete(1); cc24?.NotifyCamAcqComplete(1);
} }
} }
private void NoticePLCCompleteDet(byte[] datax)
{
if (autorunFlag == false)
{
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
}
}
private OCRTextResult OCRBytes(byte[] ocrimagebyte) private OCRTextResult OCRBytes(byte[] ocrimagebyte)
{ {
try try
@@ -2053,23 +2058,19 @@ namespace TetraPackOCR
{ {
EnableStartDetect(); EnableStartDetect();
log.Error("x范围 0,1600"); log.Error("x范围 0,1600");
byte[] datax = DataConverter.FloatToByte(0.0f, true); NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
return; return;
} }
if (ocryy[item] < -50 || ocryy[item] > 400) if (ocryy[item] < -50 || ocryy[item] > 400)
{ {
EnableStartDetect(); EnableStartDetect();
log.Error("y范围 -50,400"); log.Error("y范围 -50,400");
byte[] datax = DataConverter.FloatToByte(0.0f, true); NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
return; return;
} }
} }
if (check_Autorun.Checked == false) if (check_Autorun.Checked == false && !debugFlag)
{ {
List<float> d = new List<float>(); List<float> d = new List<float>();
for (int i = 0; i < l.Count; i++) for (int i = 0; i < l.Count; i++)
@@ -2084,9 +2085,7 @@ namespace TetraPackOCR
d.Add(l[l.Count - i]); d.Add(l[l.Count - i]);
} }
} }
byte[] datax = DataConverter.FloatToByte(d, true); NoticePLCCompleteDet(DataConverter.FloatToByte(d, true));
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
log.Info("坐标已发送完成。"); log.Info("坐标已发送完成。");
} }
} }
@@ -2094,12 +2093,7 @@ namespace TetraPackOCR
{ {
EnableStartDetect(); EnableStartDetect();
log.Error(ex.Message + "未检测到K标志"); log.Error(ex.Message + "未检测到K标志");
if (check_Autorun.Checked == false) NoticePLCCompleteDet(DataConverter.FloatToByte(0.0f, true));
{
byte[] datax = DataConverter.FloatToByte(0.0f, true);
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
}
} }
} }
#endregion #endregion

View File

@@ -4866,6 +4866,9 @@
<metadata name="menuStrip_topmenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip_topmenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>162, 17</value> <value>162, 17</value>
</metadata> </metadata>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>335, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value> <value>25</value>
</metadata> </metadata>