get order c type info

This commit is contained in:
2025-11-03 17:20:23 +08:00
parent 87fe8027b5
commit 081f3481bd
3 changed files with 4878 additions and 4870 deletions

View File

@@ -37,7 +37,6 @@
this.lbl_Y = new System.Windows.Forms.Label(); this.lbl_Y = new System.Windows.Forms.Label();
this.lbl_X = new System.Windows.Forms.Label(); this.lbl_X = new System.Windows.Forms.Label();
this.lbl_verOcr = new System.Windows.Forms.Label(); this.lbl_verOcr = new System.Windows.Forms.Label();
this.lbl_verOcrShow = new System.Windows.Forms.Label();
this.lbl_XShow = new System.Windows.Forms.Label(); this.lbl_XShow = new System.Windows.Forms.Label();
this.lbl_YShow = new System.Windows.Forms.Label(); this.lbl_YShow = new System.Windows.Forms.Label();
this.lbl_RShow = new System.Windows.Forms.Label(); this.lbl_RShow = new System.Windows.Forms.Label();
@@ -102,6 +101,7 @@
this.menuStrip_topmenu = new System.Windows.Forms.MenuStrip(); this.menuStrip_topmenu = new System.Windows.Forms.MenuStrip();
this.tableLayoutPanel_mainForm = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel_mainForm = new System.Windows.Forms.TableLayoutPanel();
this.panel_midup = new System.Windows.Forms.Panel(); this.panel_midup = new System.Windows.Forms.Panel();
this.listBox1 = new System.Windows.Forms.ListBox();
this.btn_StarDet_manual = new System.Windows.Forms.Button(); this.btn_StarDet_manual = new System.Windows.Forms.Button();
this.panel_log = new System.Windows.Forms.Panel(); this.panel_log = new System.Windows.Forms.Panel();
this.panel_pixshow = new System.Windows.Forms.Panel(); this.panel_pixshow = new System.Windows.Forms.Panel();
@@ -160,7 +160,7 @@
// lbl_R // lbl_R
// //
this.lbl_R.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl_R.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbl_R.Location = new System.Drawing.Point(532, 89); this.lbl_R.Location = new System.Drawing.Point(508, 272);
this.lbl_R.Name = "lbl_R"; this.lbl_R.Name = "lbl_R";
this.lbl_R.Size = new System.Drawing.Size(129, 29); this.lbl_R.Size = new System.Drawing.Size(129, 29);
this.lbl_R.TabIndex = 5; this.lbl_R.TabIndex = 5;
@@ -170,7 +170,7 @@
// lbl_Y // lbl_Y
// //
this.lbl_Y.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl_Y.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbl_Y.Location = new System.Drawing.Point(277, 89); this.lbl_Y.Location = new System.Drawing.Point(253, 272);
this.lbl_Y.Name = "lbl_Y"; this.lbl_Y.Name = "lbl_Y";
this.lbl_Y.Size = new System.Drawing.Size(129, 29); this.lbl_Y.Size = new System.Drawing.Size(129, 29);
this.lbl_Y.TabIndex = 6; this.lbl_Y.TabIndex = 6;
@@ -180,7 +180,7 @@
// lbl_X // lbl_X
// //
this.lbl_X.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl_X.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbl_X.Location = new System.Drawing.Point(36, 89); this.lbl_X.Location = new System.Drawing.Point(12, 272);
this.lbl_X.Name = "lbl_X"; this.lbl_X.Name = "lbl_X";
this.lbl_X.Size = new System.Drawing.Size(129, 29); this.lbl_X.Size = new System.Drawing.Size(129, 29);
this.lbl_X.TabIndex = 7; this.lbl_X.TabIndex = 7;
@@ -190,7 +190,7 @@
// lbl_verOcr // lbl_verOcr
// //
this.lbl_verOcr.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl_verOcr.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbl_verOcr.Location = new System.Drawing.Point(151, 225); this.lbl_verOcr.Location = new System.Drawing.Point(25, 46);
this.lbl_verOcr.Name = "lbl_verOcr"; this.lbl_verOcr.Name = "lbl_verOcr";
this.lbl_verOcr.Size = new System.Drawing.Size(99, 29); this.lbl_verOcr.Size = new System.Drawing.Size(99, 29);
this.lbl_verOcr.TabIndex = 9; this.lbl_verOcr.TabIndex = 9;
@@ -198,24 +198,12 @@
this.lbl_verOcr.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.lbl_verOcr.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.toolTip.SetToolTip(this.lbl_verOcr, "字符从数据表格抓取以做验证使用"); this.toolTip.SetToolTip(this.lbl_verOcr, "字符从数据表格抓取以做验证使用");
// //
// lbl_verOcrShow
//
this.lbl_verOcrShow.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.lbl_verOcrShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl_verOcrShow.Font = new System.Drawing.Font("宋体", 12F);
this.lbl_verOcrShow.Location = new System.Drawing.Point(150, 254);
this.lbl_verOcrShow.Name = "lbl_verOcrShow";
this.lbl_verOcrShow.Size = new System.Drawing.Size(539, 40);
this.lbl_verOcrShow.TabIndex = 10;
this.lbl_verOcrShow.Text = "等待订单确认...";
this.lbl_verOcrShow.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lbl_XShow // lbl_XShow
// //
this.lbl_XShow.BackColor = System.Drawing.SystemColors.ControlLightLight; this.lbl_XShow.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.lbl_XShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lbl_XShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl_XShow.Font = new System.Drawing.Font("宋体", 12F); this.lbl_XShow.Font = new System.Drawing.Font("宋体", 12F);
this.lbl_XShow.Location = new System.Drawing.Point(154, 89); this.lbl_XShow.Location = new System.Drawing.Point(130, 272);
this.lbl_XShow.Name = "lbl_XShow"; this.lbl_XShow.Name = "lbl_XShow";
this.lbl_XShow.Size = new System.Drawing.Size(117, 29); this.lbl_XShow.Size = new System.Drawing.Size(117, 29);
this.lbl_XShow.TabIndex = 11; this.lbl_XShow.TabIndex = 11;
@@ -226,7 +214,7 @@
this.lbl_YShow.BackColor = System.Drawing.SystemColors.ControlLightLight; this.lbl_YShow.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.lbl_YShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lbl_YShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl_YShow.Font = new System.Drawing.Font("宋体", 12F); this.lbl_YShow.Font = new System.Drawing.Font("宋体", 12F);
this.lbl_YShow.Location = new System.Drawing.Point(395, 88); this.lbl_YShow.Location = new System.Drawing.Point(371, 271);
this.lbl_YShow.Name = "lbl_YShow"; this.lbl_YShow.Name = "lbl_YShow";
this.lbl_YShow.Size = new System.Drawing.Size(117, 29); this.lbl_YShow.Size = new System.Drawing.Size(117, 29);
this.lbl_YShow.TabIndex = 12; this.lbl_YShow.TabIndex = 12;
@@ -237,7 +225,7 @@
this.lbl_RShow.BackColor = System.Drawing.SystemColors.ControlLightLight; this.lbl_RShow.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.lbl_RShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lbl_RShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lbl_RShow.Font = new System.Drawing.Font("宋体", 12F); this.lbl_RShow.Font = new System.Drawing.Font("宋体", 12F);
this.lbl_RShow.Location = new System.Drawing.Point(650, 89); this.lbl_RShow.Location = new System.Drawing.Point(626, 272);
this.lbl_RShow.Name = "lbl_RShow"; this.lbl_RShow.Name = "lbl_RShow";
this.lbl_RShow.Size = new System.Drawing.Size(117, 29); this.lbl_RShow.Size = new System.Drawing.Size(117, 29);
this.lbl_RShow.TabIndex = 13; this.lbl_RShow.TabIndex = 13;
@@ -246,7 +234,7 @@
// lbl_readOcrResult // lbl_readOcrResult
// //
this.lbl_readOcrResult.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl_readOcrResult.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbl_readOcrResult.Location = new System.Drawing.Point(147, 307); this.lbl_readOcrResult.Location = new System.Drawing.Point(15, 309);
this.lbl_readOcrResult.Name = "lbl_readOcrResult"; this.lbl_readOcrResult.Name = "lbl_readOcrResult";
this.lbl_readOcrResult.Size = new System.Drawing.Size(127, 29); this.lbl_readOcrResult.Size = new System.Drawing.Size(127, 29);
this.lbl_readOcrResult.TabIndex = 14; this.lbl_readOcrResult.TabIndex = 14;
@@ -507,10 +495,10 @@
// txt_readOcrResultShow // txt_readOcrResultShow
// //
this.txt_readOcrResultShow.Font = new System.Drawing.Font("宋体", 12F); this.txt_readOcrResultShow.Font = new System.Drawing.Font("宋体", 12F);
this.txt_readOcrResultShow.Location = new System.Drawing.Point(150, 339); this.txt_readOcrResultShow.Location = new System.Drawing.Point(18, 341);
this.txt_readOcrResultShow.Multiline = true; this.txt_readOcrResultShow.Multiline = true;
this.txt_readOcrResultShow.Name = "txt_readOcrResultShow"; this.txt_readOcrResultShow.Name = "txt_readOcrResultShow";
this.txt_readOcrResultShow.Size = new System.Drawing.Size(539, 41); this.txt_readOcrResultShow.Size = new System.Drawing.Size(772, 41);
this.txt_readOcrResultShow.TabIndex = 24; this.txt_readOcrResultShow.TabIndex = 24;
this.txt_readOcrResultShow.Text = "等待读取字符..."; this.txt_readOcrResultShow.Text = "等待读取字符...";
// //
@@ -1017,13 +1005,13 @@
// //
// panel_midup // panel_midup
// //
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);
this.panel_midup.Controls.Add(this.lbl_RShow); this.panel_midup.Controls.Add(this.lbl_RShow);
this.panel_midup.Controls.Add(this.lbl_OrderNum); this.panel_midup.Controls.Add(this.lbl_OrderNum);
this.panel_midup.Controls.Add(this.lbl_YShow); this.panel_midup.Controls.Add(this.lbl_YShow);
this.panel_midup.Controls.Add(this.lbl_readOcrResult); this.panel_midup.Controls.Add(this.lbl_readOcrResult);
this.panel_midup.Controls.Add(this.lbl_XShow); this.panel_midup.Controls.Add(this.lbl_XShow);
this.panel_midup.Controls.Add(this.lbl_verOcrShow);
this.panel_midup.Controls.Add(this.txt_readOcrResultShow); this.panel_midup.Controls.Add(this.txt_readOcrResultShow);
this.panel_midup.Controls.Add(this.lbl_verOcr); this.panel_midup.Controls.Add(this.lbl_verOcr);
this.panel_midup.Controls.Add(this.btn_OrderNum); this.panel_midup.Controls.Add(this.btn_OrderNum);
@@ -1037,12 +1025,22 @@
this.panel_midup.Size = new System.Drawing.Size(801, 388); this.panel_midup.Size = new System.Drawing.Size(801, 388);
this.panel_midup.TabIndex = 33; this.panel_midup.TabIndex = 33;
// //
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(9, 85);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(781, 116);
this.listBox1.TabIndex = 26;
//
// btn_StarDet_manual // btn_StarDet_manual
// //
this.btn_StarDet_manual.BackColor = System.Drawing.Color.LimeGreen; this.btn_StarDet_manual.BackColor = System.Drawing.Color.LimeGreen;
this.btn_StarDet_manual.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_StarDet_manual.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_StarDet_manual.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_StarDet_manual.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_StarDet_manual.Location = new System.Drawing.Point(344, 153); this.btn_StarDet_manual.Location = new System.Drawing.Point(339, 210);
this.btn_StarDet_manual.Name = "btn_StarDet_manual"; this.btn_StarDet_manual.Name = "btn_StarDet_manual";
this.btn_StarDet_manual.Size = new System.Drawing.Size(149, 46); this.btn_StarDet_manual.Size = new System.Drawing.Size(149, 46);
this.btn_StarDet_manual.TabIndex = 25; this.btn_StarDet_manual.TabIndex = 25;
@@ -1137,7 +1135,6 @@
private System.Windows.Forms.Label lbl_Y; private System.Windows.Forms.Label lbl_Y;
private System.Windows.Forms.Label lbl_X; private System.Windows.Forms.Label lbl_X;
private System.Windows.Forms.Label lbl_verOcr; private System.Windows.Forms.Label lbl_verOcr;
private System.Windows.Forms.Label lbl_verOcrShow;
private System.Windows.Forms.Label lbl_XShow; private System.Windows.Forms.Label lbl_XShow;
private System.Windows.Forms.Label lbl_YShow; private System.Windows.Forms.Label lbl_YShow;
private System.Windows.Forms.Label lbl_RShow; private System.Windows.Forms.Label lbl_RShow;
@@ -1208,6 +1205,7 @@
private System.Windows.Forms.Button btn_StarDet_manual; private System.Windows.Forms.Button btn_StarDet_manual;
private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.ListView list_Log; private System.Windows.Forms.ListView list_Log;
private System.Windows.Forms.ListBox listBox1;
} }
} }

View File

@@ -9,35 +9,35 @@
***********************/ ***********************/
using AVP.CRobot;
using Bjcve.Comm.FFP;
using CLIDelegate;
using Cognex.VisionPro;
using Cognex.VisionPro.Comm;
using Cognex.VisionPro.ImageProcessing;
using Cognex.VisionPro.PMAlign;
using Cognex.VisionPro.QuickBuild;
using Cognex.VisionPro.ToolBlock;
using Cognex.VisionPro.ToolGroup;
using log4net;
using LogShowLib;
using OfficeOpenXml;
using PaddleOCRSharp;
using System; using System;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using OfficeOpenXml;
using Cognex.VisionPro;
using Cognex.VisionPro.Comm;
using Cognex.VisionPro.QuickBuild;
using Cognex.VisionPro.ToolBlock;
using Cognex.VisionPro.PMAlign;
using Cognex.VisionPro.ToolGroup;
using Cognex.VisionPro.ImageProcessing;
using PaddleOCRSharp;
using AVP.CRobot;
using log4net;
using LogShowLib;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Forms;
using TetraParkOCR; using TetraParkOCR;
using Bjcve.Comm.FFP;
using ThridLibray; using ThridLibray;
using CLIDelegate;
namespace TetraPackOCR namespace TetraPackOCR
{ {
@@ -87,7 +87,8 @@ namespace TetraPackOCR
/// <summary> /// <summary>
/// 幅数 包材宽 梯度 X距离 Y距离 /// 幅数 包材宽 梯度 X距离 Y距离
/// </summary> /// </summary>
double NumberOfLanes, width, Gradient, DistX, DistY; int NumberOfLanes;
double width, Gradient, DistX, DistY;
/// <summary> /// <summary>
/// 定位Vpp文件 /// 定位Vpp文件
/// </summary> /// </summary>
@@ -169,7 +170,7 @@ namespace TetraPackOCR
this.btn_manualOcr.Enabled = true; this.btn_manualOcr.Enabled = true;
this.btn_manualDet.Enabled = true; this.btn_manualDet.Enabled = true;
check_Autorun.Enabled = true; check_Autorun.Enabled = true;
btn_StarDet_manual.Enabled = true; //btn_StarDet_manual.Enabled = true;
this.Enabled = true; this.Enabled = true;
})); }));
}); });
@@ -604,8 +605,8 @@ namespace TetraPackOCR
OcrParameter.rec = true; OcrParameter.rec = true;
OcrParameter.use_angle_cls = true;//是否开启方向检测用于检测识别180旋转 OcrParameter.use_angle_cls = true;//是否开启方向检测用于检测识别180旋转
OcrParameter.det_db_score_mode = true;//是否使用多段线,即文字区域是用多段线还是用矩形, OcrParameter.det_db_score_mode = true;//是否使用多段线,即文字区域是用多段线还是用矩形,
OcrParameter.det_db_unclip_ratio = 1.5f; OcrParameter.det_db_unclip_ratio = 1.6f;
OcrParameter.max_side_len = 1280; OcrParameter.max_side_len = 3200;
//初始化OCR //初始化OCR
Engine = new PaddleOCREngine(config, OcrParameter); Engine = new PaddleOCREngine(config, OcrParameter);
@@ -642,11 +643,13 @@ namespace TetraPackOCR
log.Info("PC加载PLC已完成"); log.Info("PC加载PLC已完成");
this.check_Autorun.BackgroundImage = Image.FromFile(Application.StartupPath + "\\logo_image\\ON.png"); this.check_Autorun.BackgroundImage = Image.FromFile(Application.StartupPath + "\\logo_image\\ON.png");
this.panel_Manual.Visible = false; this.panel_Manual.Visible = false;
this.btn_StarDet_manual.Enabled = true; if (orderLoaded)
this.btn_StarDet_manual.Enabled = true;
this.ttls_PCLStatusShow.Visible = true; this.ttls_PCLStatusShow.Visible = true;
} }
} }
private bool orderLoaded = false;
private Dictionary<int, List<string>> ocrTextRequest = new Dictionary<int, List<string>>();
/// <summary> /// <summary>
/// 此按钮事件主要是获取excel表格内的数据 /// 此按钮事件主要是获取excel表格内的数据
/// 包括定位偏移量,需要验证的字符 /// 包括定位偏移量,需要验证的字符
@@ -657,6 +660,10 @@ namespace TetraPackOCR
{ {
try try
{ {
orderLoaded = false;
btn_StarDet_manual.Enabled = false;
listBox1.Items.Clear();
ocrTextRequest.Clear();
ClearData(); ClearData();
ClearDataShow(); ClearDataShow();
this.Invoke(new Action(() => this.Invoke(new Action(() =>
@@ -690,7 +697,7 @@ namespace TetraPackOCR
if (order == null) if (order == null)
{ {
log.Warn("订单号为空,请输入订单号。"); log.Warn("订单号为空,请输入订单号。");
//MessageBox.Show("请输入订单号"); return;
} }
else else
{ {
@@ -707,66 +714,47 @@ namespace TetraPackOCR
{ {
if (sheet1.GetValue(i, 3) != null) if (sheet1.GetValue(i, 3) != null)
{ {
ord = sheet1.Cells[i, 3].Value.ToString(); if (sheet1.Cells[i, 3].Value.ToString() == order)
}
else
{
ord = null;
}
if (ord == order)
{
Sequence = sheet1.Cells[i, 2].Value.ToString();
QSV = sheet1.Cells[i, 4].Value.ToString();
this.lbl_QSVShow.Text = QSV;
log.Info("当前订单QSV:" + QSV);
NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
log.Info("当前订单Number Of Lanes:" + NumberOfLanes);
this.lbl_NOFShow.Text = sheet1.Cells[i, 5].Value.ToString();
////获取字符 并显示在界面还需处理先预留在这 共印订单不在这取字符
//Design = sheet1.Cells[i, 7].Value.ToString();
//Layers = sheet1.Cells[i, 8].Value.ToString();
//Colours = sheet1.Cells[i, 9].Value.ToString();
//lbl_verOcrShow.Text = ExecelGetOcrDealWithForShow(Design, Layers, Colours);
break;
}
}
if (Sequence != null)
{
for (int i = 1; i < sheet1.Dimension.Rows; i++)
{
string seq;
if (sheet1.GetValue(i, 2) != null)
{
seq = sheet1.Cells[i, 2].Value.ToString();
}
else
{
seq = null;
}
if (seq == Sequence)
{ {
Sequence = sheet1.Cells[i, 2].Value.ToString();
QSV = sheet1.Cells[i, 4].Value.ToString();
this.lbl_QSVShow.Text = QSV;
log.Info("当前订单QSV:" + QSV);
NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
log.Info("当前订单Number Of Lanes:" + NumberOfLanes);
this.lbl_NOFShow.Text = sheet1.Cells[i, 5].Value.ToString();
Design = sheet1.Cells[i, 7].Value.ToString(); Design = sheet1.Cells[i, 7].Value.ToString();
Layers = sheet1.Cells[i, 8].Value.ToString(); Layers = sheet1.Cells[i, 8].Value.ToString();
Colours = sheet1.Cells[i, 9].Value.ToString(); Colours = sheet1.Cells[i, 9].Value.ToString();
string Lane = sheet1.Cells[i, 6].Value.ToString();
Lane = Lane.Replace("[", ""); Lane = Lane.Replace("]", ""); int num = 0;
string[] lans = Lane.Split(','); for (int k = 0; k < 10; k++)
for (int j = 0; j < lans.Length; j++)
{ {
verocr[Convert.ToInt32(lans[j])] = ExecelGetOcrDealWithForShow(Design, Layers); string lanes = sheet1.Cells[i + k, 6].Value.ToString();
string design = sheet1.Cells[i + k, 7].Value.ToString();
string layers = sheet1.Cells[i + k, 8].Value.ToString();
string colours = sheet1.Cells[i + k, 9].Value.ToString();
lanes = lanes.Substring(1, lanes.Length - 2);
string[] tmp = lanes.Split(',');
num += tmp.Length;
foreach (string lan in tmp)
{
int lanInt = Convert.ToInt32(lan);
ocrTextRequest[lanInt] = ExecelGetOcrText(design, layers);
}
listBox1.Items.Add(sheet1.Cells[i + k, 6].Value.ToString());
listBox1.Items.Add(string.Join(",", ocrTextRequest[Convert.ToInt32(tmp[0])]));
if (num >= NumberOfLanes)
break;
} }
break;
} }
} }
} }
if (QSV != null) if (!string.IsNullOrEmpty(QSV))
{ {
string qsv; string qsv;
//根据得到的QSV遍历sheet2 找产品规格和宽度梯度 //根据得到的QSV遍历sheet2 找产品规格和宽度梯度
@@ -784,45 +772,46 @@ namespace TetraPackOCR
Gradient = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString()); Gradient = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString());
this.lbl_GradientShow.Text = sheet2.Cells[j, 4].Value.ToString(); this.lbl_GradientShow.Text = sheet2.Cells[j, 4].Value.ToString();
log.Info("当前订单梯度:" + Gradient); log.Info("当前订单梯度:" + Gradient);
break;
} }
} }
string str, ps; if (string.IsNullOrEmpty(ProductStandard))
{
log.Debug("请检查订单号是否正确");
return;
}
//根据产品规格获取距离坐标 //根据产品规格获取距离坐标
for (int n = 1; n < sheet3.Dimension.Rows; n++) for (int n = 1; n < sheet3.Dimension.Rows; n++)
{ {
if (sheet3.GetValue(n, 1) != null) if (sheet3.GetValue(n, 1) != null)
{ {
ps = sheet3.Cells[n, 1].Value.ToString(); if (sheet3.Cells[n, 1].Value.ToString() == ProductStandard)
} {
else string str = sheet3.Cells[n + Layers.Split(',').Length - 1, 4].Value.ToString();
{ string[] x_y = str.Split(',');
ps = null; string[] X = x_y[0].Split(':');
} string[] Y = x_y[1].Split(':');
if (ps == null) DistX = Convert.ToDouble(X[1].Replace("mm", ""));
{ this.lbl_DistXShow.Text = X[1].Replace("mm", "");
continue; log.Info("当前订单X偏移:" + DistX);
} DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
else if (ps == ProductStandard)//应该有另一个条件一同决定 this.lbl_DistYShow.Text = Y[1].Replace("mm", "");
{ log.Info("当前订单Y偏移:" + DistY);
str = sheet3.Cells[n, 4].Value.ToString(); break;
string[] x_y = str.Split(','); }
string[] X = x_y[0].Split(':');
string[] Y = x_y[1].Split(':');
DistX = Convert.ToDouble(X[1].Replace("mm", ""));
this.lbl_DistXShow.Text = X[1].Replace("mm", "");
log.Info("当前订单X偏移:" + DistX);
DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
this.lbl_DistYShow.Text = Y[1].Replace("mm", "");
log.Info("当前订单Y偏移:" + DistY);
} }
} }
if (DistX == 0 || DistY == 0)
{
log.Debug("请检查订单号是否正确");
return;
}
log.Info("相关数据已获取完成,且已显示在界面中,请查看。"); log.Info("相关数据已获取完成,且已显示在界面中,请查看。");
} }
else else
{ {
log.Debug("请检查订单号是否正确"); log.Debug("请检查订单号是否正确");
return;
} }
} }
} }
@@ -833,7 +822,7 @@ namespace TetraPackOCR
if (order == null) if (order == null)
{ {
log.Warn("订单号为空,请输入订单号。"); log.Warn("订单号为空,请输入订单号。");
//MessageBox.Show("请输入订单号"); return;
} }
else else
{ {
@@ -850,31 +839,31 @@ namespace TetraPackOCR
{ {
if (sheet1.GetValue(i, 3) != null) if (sheet1.GetValue(i, 3) != null)
{ {
ord = sheet1.Cells[i, 3].Value.ToString(); if (sheet1.Cells[i, 3].Value.ToString() == order)
} {
else QSV = sheet1.Cells[i, 4].Value.ToString();
{ this.lbl_QSVShow.Text = QSV;
ord = null; log.Info("当前订单QSV:" + QSV);
} NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
if (ord == order) log.Info("当前订单Number Of Lanes:" + NumberOfLanes);
{ this.lbl_NOFShow.Text = sheet1.Cells[i, 5].Value.ToString();
QSV = sheet1.Cells[i, 4].Value.ToString();
this.lbl_QSVShow.Text = QSV;
log.Info("当前订单QSV:" + QSV);
NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
log.Info("当前订单Number Of Lanes:" + NumberOfLanes);
this.lbl_NOFShow.Text = sheet1.Cells[i, 5].Value.ToString();
//获取字符 并显示在界面还需处理先预留在这 //获取字符 并显示在界面还需处理先预留在这
Design = sheet1.Cells[i, 7].Value.ToString(); Design = sheet1.Cells[i, 7].Value.ToString();
Layers = sheet1.Cells[i, 8].Value.ToString(); Layers = sheet1.Cells[i, 8].Value.ToString();
Colours = sheet1.Cells[i, 9].Value.ToString(); Colours = sheet1.Cells[i, 9].Value.ToString();
lbl_verOcrShow.Text = ExecelGetOcrDealWithForShow(Design, Layers); for (int lan = 1; lan <= NumberOfLanes; lan++)
{
ocrTextRequest[lan] = ExecelGetOcrText(Design, Layers);
}
listBox1.Items.Add(sheet1.Cells[i, 6].Value.ToString());
listBox1.Items.Add(string.Join(",", ocrTextRequest[1]));
break;
}
} }
} }
if (QSV != null) if (!string.IsNullOrEmpty(QSV))
{ {
string qsv; string qsv;
//根据得到的QSV遍历sheet2 找产品规格和宽度梯度 //根据得到的QSV遍历sheet2 找产品规格和宽度梯度
@@ -892,45 +881,46 @@ namespace TetraPackOCR
Gradient = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString()); Gradient = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString());
this.lbl_GradientShow.Text = sheet2.Cells[j, 4].Value.ToString(); this.lbl_GradientShow.Text = sheet2.Cells[j, 4].Value.ToString();
log.Info("当前订单梯度:" + Gradient); log.Info("当前订单梯度:" + Gradient);
break;
} }
} }
string str, ps; if (string.IsNullOrEmpty(ProductStandard))
{
log.Debug("请检查订单号是否正确");
return;
}
//根据产品规格获取距离坐标 //根据产品规格获取距离坐标
for (int n = 1; n < sheet3.Dimension.Rows; n++) for (int n = 1; n < sheet3.Dimension.Rows; n++)
{ {
if (sheet3.GetValue(n, 1) != null) if (sheet3.GetValue(n, 1) != null)
{ {
ps = sheet3.Cells[n, 1].Value.ToString(); if (sheet3.Cells[n, 1].Value.ToString() == ProductStandard)
} {
else string str = sheet3.Cells[n + Layers.Split(',').Length - 1, 4].Value.ToString();
{ string[] x_y = str.Split(',');
ps = null; string[] X = x_y[0].Split(':');
} string[] Y = x_y[1].Split(':');
if (ps == null) DistX = Convert.ToDouble(X[1].Replace("mm", ""));
{ this.lbl_DistXShow.Text = X[1].Replace("mm", "");
continue; log.Info("当前订单X偏移:" + DistX);
} DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
else if (ps == ProductStandard)//应该有另一个条件一同决定 this.lbl_DistYShow.Text = Y[1].Replace("mm", "");
{ log.Info("当前订单Y偏移:" + DistY);
str = sheet3.Cells[n, 4].Value.ToString(); break;
string[] x_y = str.Split(','); }
string[] X = x_y[0].Split(':');
string[] Y = x_y[1].Split(':');
DistX = Convert.ToDouble(X[1].Replace("mm", ""));
this.lbl_DistXShow.Text = X[1].Replace("mm", "");
log.Info("当前订单X偏移:" + DistX);
DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
this.lbl_DistYShow.Text = Y[1].Replace("mm", "");
log.Info("当前订单Y偏移:" + DistY);
} }
} }
if (DistX == 0 || DistY == 0)
{
log.Debug("请检查订单号是否正确");
return;
}
log.Info("相关数据已获取完成,且已显示在界面中,请查看。"); log.Info("相关数据已获取完成,且已显示在界面中,请查看。");
} }
else else
{ {
log.Debug("请检查订单号是否正确"); log.Debug("请检查订单号是否正确");
return;
} }
} }
} }
@@ -1077,7 +1067,8 @@ namespace TetraPackOCR
} }
this.btn_OrderNum.Enabled = true; this.btn_OrderNum.Enabled = true;
orderLoaded = true;
btn_StarDet_manual.Enabled = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1136,6 +1127,23 @@ namespace TetraPackOCR
} }
return rescult; return rescult;
} }
private List<string> ExecelGetOcrText(string design, string layer)
{
List<string> result = new List<string>();
string[] dd = design.Split('-');
if (dd.Length < 2)
return result;
string[] ll = layer.Replace("[", "").Replace("]", "").Split(',');
for (int i = 0; i < ll.Length; i++)
{
ll[i] = ll[i].Replace(" ", "");
string[] str = ll[i].Split('-');
if (str.Length < 2)
continue;
result.Add(dd[1] + str[1] + str[0]);
}
return result;
}
/// <summary> /// <summary>
/// 清空上次订单数据 /// 清空上次订单数据
/// </summary> /// </summary>
@@ -1157,9 +1165,6 @@ namespace TetraPackOCR
lbl_GradientShow.Text = ""; lbl_GradientShow.Text = "";
lbl_DistXShow.Text = ""; lbl_DistXShow.Text = "";
lbl_DistYShow.Text = ""; lbl_DistYShow.Text = "";
lbl_verOcrShow.Text = "";
} }
private void txt_OrderNum_KeyDown(object sender, KeyEventArgs e) private void txt_OrderNum_KeyDown(object sender, KeyEventArgs e)
@@ -1489,7 +1494,6 @@ namespace TetraPackOCR
List<string> lastocr = new List<string>(); List<string> lastocr = new List<string>();
OCRResult ocrResult = Engine.DetectText(ocrimagebyte); OCRResult ocrResult = Engine.DetectText(ocrimagebyte);
// log.Debug("读取原始数据1" + ocrResult.JsonText); // log.Debug("读取原始数据1" + ocrResult.JsonText);
List<Point> pointsList = new List<Point>(); List<Point> pointsList = new List<Point>();
@@ -1505,7 +1509,6 @@ namespace TetraPackOCR
//lastocr.Add(item.Text); //lastocr.Add(item.Text);
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text)); pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
} }
} }
@@ -2037,12 +2040,10 @@ namespace TetraPackOCR
#region #region
private void sendToPLC(double x, double y, double r) private void sendToPLC(double x, double y, double r)
{ {
try try
{ {
string[] col = Colours.Split(','); string[] col = Colours.Split(',');
float xx = (float)x; float xx = (float)x;
float yy = (float)y; float yy = (float)y;
@@ -2050,9 +2051,6 @@ namespace TetraPackOCR
List<float> ocrxx = new List<float>(); List<float> ocrxx = new List<float>();
List<float> ocryy = new List<float>(); List<float> ocryy = new List<float>();
switch (ProductStandard) switch (ProductStandard)
{ {
case "TBA1000Slim": case "TBA1000Slim":
@@ -2150,11 +2148,6 @@ namespace TetraPackOCR
} }
float ocrx = 0, ocry = 0; float ocrx = 0, ocry = 0;
List<float> l = new List<float>(); List<float> l = new List<float>();
l.Add((float)NumberOfLanes); l.Add((float)NumberOfLanes);
@@ -2184,6 +2177,22 @@ namespace TetraPackOCR
} }
log.Info("第" + (item + 1) + "组坐标为X" + ocrxx[item] + ",Y:" + ocryy[item] + "。"); log.Info("第" + (item + 1) + "组坐标为X" + ocrxx[item] + ",Y:" + ocryy[item] + "。");
if (ocrxx[item] < 0 || ocrxx[item] > 1200)
{
log.Error("x范围 0,1200");
byte[] datax = DataConverter.FloatToByte(0.0f, true);
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
return;
}
if (ocryy[item] < -50 || ocryy[item] > 400)
{
log.Error("y范围 -50,400");
byte[] datax = DataConverter.FloatToByte(0.0f, true);
cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0);
return;
}
} }
if (this.check_Autorun.Checked == false) if (this.check_Autorun.Checked == false)
@@ -2215,7 +2224,6 @@ namespace TetraPackOCR
log.Error(ex.Message + "未检测到K标志"); log.Error(ex.Message + "未检测到K标志");
if (check_Autorun.Checked == false) if (check_Autorun.Checked == false)
{ {
byte[] datax = DataConverter.FloatToByte(0.0f, true); byte[] datax = DataConverter.FloatToByte(0.0f, true);
cc24?.NotifyCamInspectionComplete(0, datax); cc24?.NotifyCamInspectionComplete(0, datax);
cc24?.NotifyCamAcqComplete(0); cc24?.NotifyCamAcqComplete(0);

File diff suppressed because it is too large Load Diff