修改mes

This commit is contained in:
YZJ 2024-07-15 17:15:28 +08:00
commit feeda6a550
3 changed files with 373 additions and 396 deletions

View File

@ -154,13 +154,14 @@
InitMachine = new Button(); InitMachine = new Button();
tabPage3 = new TabPage(); tabPage3 = new TabPage();
panel2 = new Panel(); panel2 = new Panel();
button1 = new Button();
contextMenuStrip1 = new ContextMenuStrip(components);
WhiteBanCbx = new CheckBox(); WhiteBanCbx = new CheckBox();
label33 = new Label(); label33 = new Label();
label28 = new Label(); label28 = new Label();
openModelBtn = new Button(); openModelBtn = new Button();
modelChangeCbx = new TextBox(); modelChangeCbx = new TextBox();
label34 = new Label(); label34 = new Label();
button4 = new Button();
OpenTwoDirBtn = new Button(); OpenTwoDirBtn = new Button();
OpenDirBtn = new Button(); OpenDirBtn = new Button();
Cam2MatCbx = new TextBox(); Cam2MatCbx = new TextBox();
@ -168,15 +169,7 @@
Cam1MatCbx = new TextBox(); Cam1MatCbx = new TextBox();
label23 = new Label(); label23 = new Label();
QueryoneBtn = new Button(); QueryoneBtn = new Button();
DetectBArMatbox = new TextBox();
label24 = new Label();
InsertBtn = new Button(); InsertBtn = new Button();
moveTwoZbox = new TextBox();
label25 = new Label();
moveTwoYbox = new TextBox();
label26 = new Label();
moveTwoXbox = new TextBox();
label27 = new Label();
moveZbox = new TextBox(); moveZbox = new TextBox();
moveYbox = new TextBox(); moveYbox = new TextBox();
label29 = new Label(); label29 = new Label();
@ -195,7 +188,6 @@
timer5 = new System.Windows.Forms.Timer(components); timer5 = new System.Windows.Forms.Timer(components);
timer6 = new System.Windows.Forms.Timer(components); timer6 = new System.Windows.Forms.Timer(components);
richTextBox1 = new RichTextBox(); richTextBox1 = new RichTextBox();
contextMenuStrip1 = new ContextMenuStrip(components);
backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
panel1.SuspendLayout(); panel1.SuspendLayout();
@ -1561,13 +1553,13 @@
// //
// panel2 // panel2
// //
panel2.Controls.Add(button1);
panel2.Controls.Add(WhiteBanCbx); panel2.Controls.Add(WhiteBanCbx);
panel2.Controls.Add(label33); panel2.Controls.Add(label33);
panel2.Controls.Add(label28); panel2.Controls.Add(label28);
panel2.Controls.Add(openModelBtn); panel2.Controls.Add(openModelBtn);
panel2.Controls.Add(modelChangeCbx); panel2.Controls.Add(modelChangeCbx);
panel2.Controls.Add(label34); panel2.Controls.Add(label34);
panel2.Controls.Add(button4);
panel2.Controls.Add(OpenTwoDirBtn); panel2.Controls.Add(OpenTwoDirBtn);
panel2.Controls.Add(OpenDirBtn); panel2.Controls.Add(OpenDirBtn);
panel2.Controls.Add(Cam2MatCbx); panel2.Controls.Add(Cam2MatCbx);
@ -1575,15 +1567,7 @@
panel2.Controls.Add(Cam1MatCbx); panel2.Controls.Add(Cam1MatCbx);
panel2.Controls.Add(label23); panel2.Controls.Add(label23);
panel2.Controls.Add(QueryoneBtn); panel2.Controls.Add(QueryoneBtn);
panel2.Controls.Add(DetectBArMatbox);
panel2.Controls.Add(label24);
panel2.Controls.Add(InsertBtn); panel2.Controls.Add(InsertBtn);
panel2.Controls.Add(moveTwoZbox);
panel2.Controls.Add(label25);
panel2.Controls.Add(moveTwoYbox);
panel2.Controls.Add(label26);
panel2.Controls.Add(moveTwoXbox);
panel2.Controls.Add(label27);
panel2.Controls.Add(moveZbox); panel2.Controls.Add(moveZbox);
panel2.Controls.Add(moveYbox); panel2.Controls.Add(moveYbox);
panel2.Controls.Add(label29); panel2.Controls.Add(label29);
@ -1602,12 +1586,30 @@
panel2.TabIndex = 1; panel2.TabIndex = 1;
panel2.Paint += panel2_Paint; panel2.Paint += panel2_Paint;
// //
// button1
//
button1.ContextMenuStrip = contextMenuStrip1;
button1.Location = new Point(493, 46);
button1.Margin = new Padding(4, 2, 4, 2);
button1.Name = "button1";
button1.Size = new Size(96, 38);
button1.TabIndex = 41;
button1.Text = "获取";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click_1;
//
// contextMenuStrip1
//
contextMenuStrip1.ImageScalingSize = new Size(24, 24);
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(61, 4);
//
// WhiteBanCbx // WhiteBanCbx
// //
WhiteBanCbx.AutoSize = true; WhiteBanCbx.AutoSize = true;
WhiteBanCbx.Checked = true; WhiteBanCbx.Checked = true;
WhiteBanCbx.CheckState = CheckState.Checked; WhiteBanCbx.CheckState = CheckState.Checked;
WhiteBanCbx.Location = new Point(742, 231); WhiteBanCbx.Location = new Point(867, 146);
WhiteBanCbx.Margin = new Padding(4, 2, 4, 2); WhiteBanCbx.Margin = new Padding(4, 2, 4, 2);
WhiteBanCbx.Name = "WhiteBanCbx"; WhiteBanCbx.Name = "WhiteBanCbx";
WhiteBanCbx.Size = new Size(59, 29); WhiteBanCbx.Size = new Size(59, 29);
@ -1618,7 +1620,7 @@
// label33 // label33
// //
label33.AutoSize = true; label33.AutoSize = true;
label33.Location = new Point(471, 232); label33.Location = new Point(596, 147);
label33.Margin = new Padding(4, 0, 4, 0); label33.Margin = new Padding(4, 0, 4, 0);
label33.Name = "label33"; label33.Name = "label33";
label33.Size = new Size(243, 25); label33.Size = new Size(243, 25);
@ -1648,7 +1650,7 @@
// //
// modelChangeCbx // modelChangeCbx
// //
modelChangeCbx.Location = new Point(1059, 14); modelChangeCbx.Location = new Point(750, 14);
modelChangeCbx.Margin = new Padding(4, 2, 4, 2); modelChangeCbx.Margin = new Padding(4, 2, 4, 2);
modelChangeCbx.Name = "modelChangeCbx"; modelChangeCbx.Name = "modelChangeCbx";
modelChangeCbx.Size = new Size(241, 31); modelChangeCbx.Size = new Size(241, 31);
@ -1658,27 +1660,16 @@
// label34 // label34
// //
label34.AutoSize = true; label34.AutoSize = true;
label34.Location = new Point(923, 19); label34.Location = new Point(597, 14);
label34.Margin = new Padding(4, 0, 4, 0); label34.Margin = new Padding(4, 0, 4, 0);
label34.Name = "label34"; label34.Name = "label34";
label34.Size = new Size(138, 25); label34.Size = new Size(138, 25);
label34.TabIndex = 33; label34.TabIndex = 33;
label34.Text = "面板语言选择"; label34.Text = "面板语言选择";
// //
// button4
//
button4.Location = new Point(896, 104);
button4.Margin = new Padding(4, 2, 4, 2);
button4.Name = "button4";
button4.Size = new Size(96, 34);
button4.TabIndex = 32;
button4.Text = "打开文件";
button4.UseVisualStyleBackColor = true;
button4.Click += button4_Click_1;
//
// OpenTwoDirBtn // OpenTwoDirBtn
// //
OpenTwoDirBtn.Location = new Point(895, 184); OpenTwoDirBtn.Location = new Point(1066, 105);
OpenTwoDirBtn.Margin = new Padding(4, 2, 4, 2); OpenTwoDirBtn.Margin = new Padding(4, 2, 4, 2);
OpenTwoDirBtn.Name = "OpenTwoDirBtn"; OpenTwoDirBtn.Name = "OpenTwoDirBtn";
OpenTwoDirBtn.Size = new Size(96, 35); OpenTwoDirBtn.Size = new Size(96, 35);
@ -1689,7 +1680,7 @@
// //
// OpenDirBtn // OpenDirBtn
// //
OpenDirBtn.Location = new Point(895, 142); OpenDirBtn.Location = new Point(1066, 53);
OpenDirBtn.Margin = new Padding(4, 2, 4, 2); OpenDirBtn.Margin = new Padding(4, 2, 4, 2);
OpenDirBtn.Name = "OpenDirBtn"; OpenDirBtn.Name = "OpenDirBtn";
OpenDirBtn.Size = new Size(96, 34); OpenDirBtn.Size = new Size(96, 34);
@ -1700,7 +1691,7 @@
// //
// Cam2MatCbx // Cam2MatCbx
// //
Cam2MatCbx.Location = new Point(608, 190); Cam2MatCbx.Location = new Point(750, 111);
Cam2MatCbx.Margin = new Padding(4, 2, 4, 2); Cam2MatCbx.Margin = new Padding(4, 2, 4, 2);
Cam2MatCbx.Name = "Cam2MatCbx"; Cam2MatCbx.Name = "Cam2MatCbx";
Cam2MatCbx.Size = new Size(279, 31); Cam2MatCbx.Size = new Size(279, 31);
@ -1710,7 +1701,7 @@
// label22 // label22
// //
label22.AutoSize = true; label22.AutoSize = true;
label22.Location = new Point(471, 190); label22.Location = new Point(596, 105);
label22.Margin = new Padding(4, 0, 4, 0); label22.Margin = new Padding(4, 0, 4, 0);
label22.Name = "label22"; label22.Name = "label22";
label22.Size = new Size(138, 25); label22.Size = new Size(138, 25);
@ -1719,7 +1710,7 @@
// //
// Cam1MatCbx // Cam1MatCbx
// //
Cam1MatCbx.Location = new Point(608, 142); Cam1MatCbx.Location = new Point(750, 59);
Cam1MatCbx.Margin = new Padding(4, 2, 4, 2); Cam1MatCbx.Margin = new Padding(4, 2, 4, 2);
Cam1MatCbx.Name = "Cam1MatCbx"; Cam1MatCbx.Name = "Cam1MatCbx";
Cam1MatCbx.Size = new Size(279, 31); Cam1MatCbx.Size = new Size(279, 31);
@ -1729,7 +1720,7 @@
// label23 // label23
// //
label23.AutoSize = true; label23.AutoSize = true;
label23.Location = new Point(472, 147); label23.Location = new Point(597, 62);
label23.Margin = new Padding(4, 0, 4, 0); label23.Margin = new Padding(4, 0, 4, 0);
label23.Name = "label23"; label23.Name = "label23";
label23.Size = new Size(138, 25); label23.Size = new Size(138, 25);
@ -1738,7 +1729,7 @@
// //
// QueryoneBtn // QueryoneBtn
// //
QueryoneBtn.Location = new Point(1077, 209); QueryoneBtn.Location = new Point(978, 204);
QueryoneBtn.Margin = new Padding(4, 2, 4, 2); QueryoneBtn.Margin = new Padding(4, 2, 4, 2);
QueryoneBtn.Name = "QueryoneBtn"; QueryoneBtn.Name = "QueryoneBtn";
QueryoneBtn.Size = new Size(148, 50); QueryoneBtn.Size = new Size(148, 50);
@ -1747,96 +1738,20 @@
QueryoneBtn.UseVisualStyleBackColor = true; QueryoneBtn.UseVisualStyleBackColor = true;
QueryoneBtn.Click += QueryoneBtn_Click; QueryoneBtn.Click += QueryoneBtn_Click;
// //
// DetectBArMatbox
//
DetectBArMatbox.Location = new Point(607, 104);
DetectBArMatbox.Margin = new Padding(4, 2, 4, 2);
DetectBArMatbox.Name = "DetectBArMatbox";
DetectBArMatbox.Size = new Size(280, 31);
DetectBArMatbox.TabIndex = 24;
DetectBArMatbox.Text = "D:\\Hisence\\类型\\Lp202452414231.jpg";
//
// label24
//
label24.AutoSize = true;
label24.Location = new Point(471, 110);
label24.Margin = new Padding(4, 0, 4, 0);
label24.Name = "label24";
label24.Size = new Size(96, 25);
label24.TabIndex = 23;
label24.Text = "条码录入";
//
// InsertBtn // InsertBtn
// //
InsertBtn.Location = new Point(1077, 87); InsertBtn.Location = new Point(608, 204);
InsertBtn.Margin = new Padding(4, 2, 4, 2); InsertBtn.Margin = new Padding(4, 2, 4, 2);
InsertBtn.Name = "InsertBtn"; InsertBtn.Name = "InsertBtn";
InsertBtn.Size = new Size(148, 45); InsertBtn.Size = new Size(156, 56);
InsertBtn.TabIndex = 22; InsertBtn.TabIndex = 22;
InsertBtn.Text = "插入"; InsertBtn.Text = "插入";
InsertBtn.UseVisualStyleBackColor = true; InsertBtn.UseVisualStyleBackColor = true;
InsertBtn.Click += InsertBtn_Click; InsertBtn.Click += InsertBtn_Click;
// //
// moveTwoZbox
//
moveTwoZbox.Location = new Point(607, 56);
moveTwoZbox.Margin = new Padding(4, 2, 4, 2);
moveTwoZbox.Name = "moveTwoZbox";
moveTwoZbox.Size = new Size(280, 31);
moveTwoZbox.TabIndex = 21;
moveTwoZbox.Text = "0";
//
// label25
//
label25.AutoSize = true;
label25.Location = new Point(471, 62);
label25.Margin = new Padding(4, 0, 4, 0);
label25.Name = "label25";
label25.Size = new Size(151, 25);
label25.TabIndex = 20;
label25.Text = "第二次拍照Z轴";
//
// moveTwoYbox
//
moveTwoYbox.Location = new Point(607, 11);
moveTwoYbox.Margin = new Padding(4, 2, 4, 2);
moveTwoYbox.Name = "moveTwoYbox";
moveTwoYbox.Size = new Size(280, 31);
moveTwoYbox.TabIndex = 19;
moveTwoYbox.Text = "0";
//
// label26
//
label26.AutoSize = true;
label26.Location = new Point(471, 17);
label26.Margin = new Padding(4, 0, 4, 0);
label26.Name = "label26";
label26.Size = new Size(153, 25);
label26.TabIndex = 18;
label26.Text = "第二次拍照Y轴";
//
// moveTwoXbox
//
moveTwoXbox.Location = new Point(143, 229);
moveTwoXbox.Margin = new Padding(4, 2, 4, 2);
moveTwoXbox.Name = "moveTwoXbox";
moveTwoXbox.Size = new Size(287, 31);
moveTwoXbox.TabIndex = 17;
moveTwoXbox.Text = "54964";
//
// label27
//
label27.AutoSize = true;
label27.Location = new Point(21, 233);
label27.Margin = new Padding(4, 0, 4, 0);
label27.Name = "label27";
label27.Size = new Size(152, 25);
label27.TabIndex = 16;
label27.Text = "第二次拍照X轴";
//
// moveZbox // moveZbox
// //
moveZbox.Location = new Point(143, 182); moveZbox.Location = new Point(183, 184);
moveZbox.Margin = new Padding(4, 2, 4, 2); moveZbox.Margin = new Padding(4, 2, 4, 2);
moveZbox.Name = "moveZbox"; moveZbox.Name = "moveZbox";
moveZbox.Size = new Size(287, 31); moveZbox.Size = new Size(287, 31);
@ -1845,7 +1760,7 @@
// //
// moveYbox // moveYbox
// //
moveYbox.Location = new Point(143, 137); moveYbox.Location = new Point(183, 141);
moveYbox.Margin = new Padding(4, 2, 4, 2); moveYbox.Margin = new Padding(4, 2, 4, 2);
moveYbox.Name = "moveYbox"; moveYbox.Name = "moveYbox";
moveYbox.Size = new Size(287, 31); moveYbox.Size = new Size(287, 31);
@ -1864,7 +1779,7 @@
// //
// moveXbox // moveXbox
// //
moveXbox.Location = new Point(143, 98); moveXbox.Location = new Point(182, 101);
moveXbox.Margin = new Padding(4, 2, 4, 2); moveXbox.Margin = new Padding(4, 2, 4, 2);
moveXbox.Name = "moveXbox"; moveXbox.Name = "moveXbox";
moveXbox.Size = new Size(287, 31); moveXbox.Size = new Size(287, 31);
@ -1883,7 +1798,7 @@
// //
// OcrBarBox // OcrBarBox
// //
OcrBarBox.Location = new Point(143, 50); OcrBarBox.Location = new Point(183, 56);
OcrBarBox.Margin = new Padding(4, 2, 4, 2); OcrBarBox.Margin = new Padding(4, 2, 4, 2);
OcrBarBox.Name = "OcrBarBox"; OcrBarBox.Name = "OcrBarBox";
OcrBarBox.Size = new Size(287, 31); OcrBarBox.Size = new Size(287, 31);
@ -1893,16 +1808,16 @@
// label31 // label31
// //
label31.AutoSize = true; label31.AutoSize = true;
label31.Location = new Point(18, 56); label31.Location = new Point(23, 59);
label31.Margin = new Padding(4, 0, 4, 0); label31.Margin = new Padding(4, 0, 4, 0);
label31.Name = "label31"; label31.Name = "label31";
label31.Size = new Size(54, 25); label31.Size = new Size(41, 25);
label31.TabIndex = 4; label31.TabIndex = 4;
label31.Text = "条码"; label31.Text = "SN";
// //
// TypeBox // TypeBox
// //
TypeBox.Location = new Point(143, 11); TypeBox.Location = new Point(183, 14);
TypeBox.Margin = new Padding(4, 2, 4, 2); TypeBox.Margin = new Padding(4, 2, 4, 2);
TypeBox.Name = "TypeBox"; TypeBox.Name = "TypeBox";
TypeBox.Size = new Size(287, 31); TypeBox.Size = new Size(287, 31);
@ -1911,7 +1826,7 @@
// //
// queryALLBtn // queryALLBtn
// //
queryALLBtn.Location = new Point(1077, 147); queryALLBtn.Location = new Point(798, 204);
queryALLBtn.Margin = new Padding(4, 2, 4, 2); queryALLBtn.Margin = new Padding(4, 2, 4, 2);
queryALLBtn.Name = "queryALLBtn"; queryALLBtn.Name = "queryALLBtn";
queryALLBtn.Size = new Size(148, 56); queryALLBtn.Size = new Size(148, 56);
@ -1951,12 +1866,6 @@
richTextBox1.TabIndex = 1; richTextBox1.TabIndex = 1;
richTextBox1.Text = ""; richTextBox1.Text = "";
// //
// contextMenuStrip1
//
contextMenuStrip1.ImageScalingSize = new Size(24, 24);
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(61, 4);
//
// MainForm // MainForm
// //
AutoScaleDimensions = new SizeF(12F, 25F); AutoScaleDimensions = new SizeF(12F, 25F);
@ -2119,7 +2028,6 @@
private Label label21; private Label label21;
private TabPage tabPage3; private TabPage tabPage3;
private Panel panel2; private Panel panel2;
private Button button4;
private Button OpenTwoDirBtn; private Button OpenTwoDirBtn;
private Button OpenDirBtn; private Button OpenDirBtn;
private TextBox Cam2MatCbx; private TextBox Cam2MatCbx;
@ -2127,15 +2035,7 @@
private TextBox Cam1MatCbx; private TextBox Cam1MatCbx;
private Label label23; private Label label23;
private Button QueryoneBtn; private Button QueryoneBtn;
private TextBox DetectBArMatbox;
private Label label24;
private Button InsertBtn; private Button InsertBtn;
private TextBox moveTwoZbox;
private Label label25;
private TextBox moveTwoYbox;
private Label label26;
private TextBox moveTwoXbox;
private Label label27;
private TextBox moveZbox; private TextBox moveZbox;
private Label label28; private Label label28;
private TextBox moveYbox; private TextBox moveYbox;
@ -2180,5 +2080,6 @@
private XKRS.UI.Canvas canvas1; private XKRS.UI.Canvas canvas1;
private XKRS.UI.Canvas canvas6; private XKRS.UI.Canvas canvas6;
private XKRS.UI.Canvas canvas2; private XKRS.UI.Canvas canvas2;
private Button button1;
} }
} }

View File

@ -6,6 +6,7 @@ using OpenCvSharp;
using OpenCvSharp.Dnn; using OpenCvSharp.Dnn;
using OpenCvSharp.Extensions; using OpenCvSharp.Extensions;
using OpenCvSharp.XFeatures2D; using OpenCvSharp.XFeatures2D;
using STTech.CodePlus.Threading;
using Sunny.UI; using Sunny.UI;
using Sunny.UI.Win32; using Sunny.UI.Win32;
using System; using System;
@ -25,6 +26,7 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization;
using XKRS.Device.SimboVision.SimboHelper; using XKRS.Device.SimboVision.SimboHelper;
using XKRS.UI; using XKRS.UI;
using static HisenceYoloDetection.CheckDiffSciHelper; using static HisenceYoloDetection.CheckDiffSciHelper;
@ -69,6 +71,7 @@ namespace HisenceYoloDetection
AutoResetEvent _runHandleBefore = new AutoResetEvent(false); AutoResetEvent _runHandleBefore = new AutoResetEvent(false);
ManualResetEvent _runHandleAfter = new ManualResetEvent(false); ManualResetEvent _runHandleAfter = new ManualResetEvent(false);
AutoResetEvent _runThreadFormtype = new AutoResetEvent(false);
bool PLC545 = false; bool PLC545 = false;
bool PLC548 = false; bool PLC548 = false;
@ -289,94 +292,115 @@ namespace HisenceYoloDetection
/// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param> /// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
/// <param name="Accept">默认application/json</param> /// <param name="Accept">默认application/json</param>
/// <returns></returns> /// <returns></returns>
//public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json") public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
//{
// try
// {
// // 创建 Web 请求对象
// HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
// byte[] buf = Encoding.UTF8.GetBytes($"inputvalue={Uri.EscapeDataString(parameterData)}");
// myRequest.Method = "POST";
// myRequest.Accept = accept;
// myRequest.ContentType = contentType;
// myRequest.ContentLength = buf.Length;
// // 发送请求
// using (Stream stream = myRequest.GetRequestStream())
// {
// stream.Write(buf, 0, buf.Length);
// }
// // 获取响应内容
// using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
// using (StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8))
// {
// return reader.ReadToEnd();
// }
// }
// catch (WebException ex)
// {
// if (ex.Response != null)
// {
// using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
// {
// string errorResponse = reader.ReadToEnd();
// Console.WriteLine("WebException: " + errorResponse);
// return errorResponse;
// }
// }
// else
// {
// Console.WriteLine("WebException: " + ex.Message);
// return null;
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine("Exception: " + ex.Message);
// return null;
// }
//}
#endregion
/// <summary>
/// 主窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e)
{ {
//string path3 = "D:\\Hisence\\Test1\\3.jpg"; try
//Mat pathmat = Cv2.ImRead(path3); {
//string path2 = "D:\\Hisence\\Test1\\4-1.jpg"; // 创建 Web 请求对象
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
byte[] buf = Encoding.UTF8.GetBytes($"inputvalue={Uri.EscapeDataString(parameterData)}");
//Rect rect3 = new Rect(0, 0, 0, 0); myRequest.Method = "POST";
myRequest.Accept = accept;
myRequest.ContentType = contentType;
myRequest.ContentLength = buf.Length;
//CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect3, rect3, false, "D://Hisence//Test1"); // 发送请求
//string path22 = "D:\\Hisence\\Test2\\2.jpg"; using (Stream stream = myRequest.GetRequestStream())
//Mat pathmat2 = Cv2.ImRead(path22); {
//string path222 = "D:\\Hisence\\Test2\\3.jpg"; stream.Write(buf, 0, buf.Length);
//Rect rect = new Rect(0, 0, 0, 0); }
// 获取响应内容
using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
using (StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
catch (WebException ex)
{
if (ex.Response != null)
{
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
{
string errorResponse = reader.ReadToEnd();
Console.WriteLine("WebException: " + errorResponse);
return errorResponse;
}
}
else
{
Console.WriteLine("WebException: " + ex.Message);
return null;
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
return null;
}
}
#endregion
Dictionary<string, string> DayTypeDics = new Dictionary<string, string>();//存放当日的SN和型号值
public void GetTypeFromPost()
{
string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
DateTime dt = DateTime.Now;
string today = dt.ToString("yyyy-MM-dd");
string startTime = today;
string endTime = today;
string lineBody = "BZ-PC";
string materialDescript = "皂盒";
JObject patientInfo = new JObject
{
["StartTime"] = startTime,
["EndTime"] = endTime,
["LineBody"] = lineBody,
["MaterialDescripts"] = new JArray { materialDescript }
};
string sendData = patientInfo.ToString();
string resultData = Post(sendData, url, "application/x-www-form-urlencoded", "application/json");
if (resultData != null)
{
JObject responseJson = JObject.Parse(resultData);
bool success = responseJson["success"] != null && (bool)responseJson["success"];
if (success)
{
// string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// 目标 FinalDefID
JArray dataArray = responseJson["data"] as JArray;
if (dataArray != null)
{
foreach (JObject dataItem in dataArray)
{
string finalDefID = dataItem["FinalDefID"] != null ? dataItem["FinalDefID"].ToString() : "N/A";
string productType = dataItem["ProductType"] != null ? dataItem["ProductType"].ToString() : "N/A";
DayTypeDics.Add(finalDefID, productType);
//CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect, rect, true, "D://Hisence//Test2");
// 报警地址 }
//string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson"; }
}
else
{
string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
Console.WriteLine("请求失败:" + returnMsg);
}
}
else
{
Console.WriteLine("请求失败:未返回数据");
}
//DateTime dt = DateTime.Now; }
//string today = dt.ToString("yyyy-MM-dd");
//string startTime = today;
//string endTime = today;
//string lineBody = "BZ-PC";
//string materialDescript = "皂盒";
<<<<<<< HEAD
//JObject patientInfo = new JObject
=======
/// <summary> /// <summary>
/// 主窗口 /// 主窗口
/// </summary> /// </summary>
@ -384,65 +408,65 @@ namespace HisenceYoloDetection
/// <param name="e"></param> /// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
//报警地址 Stopwatch sw = new Stopwatch();
//string url = "https://inner-apisix.hisense.com/mes-plus/api/Fcc/GetWorkOrderBOMlnfo?user_key=k7gzo1fsfcami7n5hmpxtybyluf9xeue"; sw.Start();
////string url = "https://echo.hoppscotch.io";
//string PostUrl = url;
//DateTime dt= DateTime.Now;
//string starttime=string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017 string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
//string startTime = starttime; DateTime dt = DateTime.Now;
//string EndTime = starttime; string today = dt.ToString("yyyy-MM-dd");
//string lineBody = "BZ-PC";
//string MaterialDescripts = "制冷器";
//string MaterialDescripts2 = "工艺管";
//JObject patientinfo = new JObject();
//JArray ids = new JArray();
//ids.Add(MaterialDescripts);
//ids.Add(MaterialDescripts2);
//patientinfo["startTime"] = startTime;
//patientinfo["EndTime"] = EndTime;
//patientinfo["lineBody"] = lineBody;
//patientinfo["MaterialDescripts"] = ids;
//string sendData = JsonConvert.SerializeObject(patientinfo);
////eg: 发送Url需要的格式sendData={"ids":[123],"Name":小黑}
//string resultData = Post(sendData, PostUrl);
//resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}";
//JObject jo = (JObject)JsonConvert.DeserializeObject(resultData);
//string sucessIf = jo["success"].ToString();
//if(sucessIf.ToLower()=="true")
>>>>>>> 756d23229c59669d628dd94efb8876679bfe21f7
//{
// ["StartTime"] = startTime,
// ["EndTime"] = endTime,
// ["LineBody"] = lineBody,
// ["MaterialDescripts"] = new JArray { materialDescript }
//};
//string sendData = patientInfo.ToString(); string startTime = today;
//string resultData = Post(sendData, url, "application/x-www-form-urlencoded", "application/json"); string endTime = today;
string lineBody = "BZ-PC";
string materialDescript = "皂盒";
JObject patientInfo = new JObject
{
["StartTime"] = startTime,
["EndTime"] = endTime,
["LineBody"] = lineBody,
["MaterialDescripts"] = new JArray { materialDescript }
};
string sendData = patientInfo.ToString();
string resultData = Post(sendData, url, "application/x-www-form-urlencoded", "application/json");
if (resultData != null)
{
JObject responseJson = JObject.Parse(resultData);
bool success = responseJson["success"] != null && (bool)responseJson["success"];
if (success)
{
string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// 目标 FinalDefID
JArray dataArray = responseJson["data"] as JArray;
if (dataArray != null)
{
foreach (JObject dataItem in dataArray)
{
if (dataItem["FinalDefID"] != null && dataItem["FinalDefID"].ToString() == FinalDefIDToFind)
{
string productType = dataItem["ProductType"] != null ? dataItem["ProductType"].ToString() : "N/A";
Console.WriteLine($"FinalDefID: {FinalDefIDToFind}, ProductType: {productType}");
break;
}
}
}
}
else
{
string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
Console.WriteLine("请求失败:" + returnMsg);
}
}
else
{
Console.WriteLine("请求失败:未返回数据");
}
sw.Stop();
Console.WriteLine("时间请求i" + sw.ElapsedMilliseconds);
//if (resultData != null)
//{
// JObject responseJson = JObject.Parse(resultData);
// bool success = responseJson["success"] != null && (bool)responseJson["success"];
// if (success)
// {
// string productType = responseJson["ProductType"] != null ? responseJson["ProductType"].ToString() : "N/A";
// string finalDefIo = responseJson["FinalDefIo"] != null ? responseJson["FinalDefIo"].ToString() : "N/A";
// // 解析字段
// }
// else
// {
// string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
// Console.WriteLine("请求失败:" + returnMsg);
// }
//}
//else
//{
// Console.WriteLine("请求失败:未返回数据");
//}
if (_runHandleBefore == null) if (_runHandleBefore == null)
{ {
_runHandleBefore = new AutoResetEvent(false); _runHandleBefore = new AutoResetEvent(false);
@ -521,6 +545,11 @@ namespace HisenceYoloDetection
myLogDelegateUI = new MyLogDelegateUI(initAll3);//绑定委托 myLogDelegateUI = new MyLogDelegateUI(initAll3);//绑定委托
Scanner.Strart();
Scanner.OnClientDataReceived -= OnDataReceived;
Scanner.OnClientDataReceived += OnDataReceived;
Scanner.btnSendMsg("LON\r");//发送开启指令
myLog("发送恩士扫码枪开启指令", DateTime.Now);
//初始化PLC //初始化PLC
melsecPLCTCPDriver.Start(); melsecPLCTCPDriver.Start();
@ -836,7 +865,7 @@ namespace HisenceYoloDetection
try try
{ {
//初始化相机 //初始化相机
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet"); DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
//dataGridView1.DataSource = dataSet.Tables[0]; //dataGridView1.DataSource = dataSet.Tables[0];
@ -857,11 +886,7 @@ namespace HisenceYoloDetection
OKOrNGShow.Image = OKbitmap; OKOrNGShow.Image = OKbitmap;
//初始化扫码枪 //初始化扫码枪
Scanner.Strart();
Scanner.OnClientDataReceived -= OnDataReceived;
Scanner.OnClientDataReceived += OnDataReceived;
Scanner.btnSendMsg("LON\r");//发送开启指令
myLog("发送恩士扫码枪开启指令", DateTime.Now);
//PLC使能开启 //PLC使能开启
melsecPLCTCPDriver.WriteInt("581", 0);//定位松开 melsecPLCTCPDriver.WriteInt("581", 0);//定位松开
@ -1317,7 +1342,7 @@ namespace HisenceYoloDetection
{ {
// Old_xKNow = xKNow; // Old_xKNow = xKNow;
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now); myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
bBarTriger = true;
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴 //MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
} }
@ -1381,6 +1406,7 @@ namespace HisenceYoloDetection
{ {
int iNum1 = 0; int iNum1 = 0;
int iNum0 = 0; int iNum0 = 0;
int iNum3 = 0;
Thread.CurrentThread.Priority = ThreadPriority.Highest; Thread.CurrentThread.Priority = ThreadPriority.Highest;
while (true) while (true)
{ {
@ -1411,7 +1437,8 @@ namespace HisenceYoloDetection
else else
{ {
iNum1 = 0; iNum1 = 0;
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞 iNum3++;//获取光电没达到洗衣机上的次数
} }
if (iNum1 >= 2) if (iNum1 >= 2)
{ {
@ -1425,50 +1452,23 @@ namespace HisenceYoloDetection
{ {
_runHandleBefore.WaitOne(); _runHandleBefore.WaitOne();
//这里改成和海信的对接需求 //这里改成和海信的对接需求
string OcrBar = "";
string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// 目标 FinalDefID
#if false #if false
{ {
// Oldm_sKEYENCEBar= m_sKEYENCEBar; OcrBar=FormBarType(FinalDefIDToFind)
//获取请求
//报警地址
string url = "https://inner-apisix.hisense.com/mes-plus/api/Fcc/GetWorkOrderBOMlnfo?user_key=k7gzo1fsfcami7n5hmpxtybyluf9xeue";
// string url = "https://echo.hoppscotch.io";
string PostUrl = url;
DateTime dt = DateTime.Now;
string starttime = string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
string startTime = starttime;
string EndTime = starttime;
string lineBody = "ZZ-P";//线体
string MaterialDescripts = "制冷器";
string MaterialDescripts2 = "工艺管";
JObject patientinfo = new JObject();
JArray ids = new JArray();
ids.Add(MaterialDescripts);
ids.Add(MaterialDescripts2);
patientinfo["startTime"] = startTime;
patientinfo["EndTime"] = EndTime;
patientinfo["lineBody"] = lineBody;
patientinfo["MaterialDescripts"] = ids;
string sendData = JsonConvert.SerializeObject(patientinfo);
//eg: 发送Url需要的格式sendData={"ids":[123],"Name":小黑}
string resultData = Post(sendData, PostUrl);
resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}";
JObject jo = (JObject)JsonConvert.DeserializeObject(resultData);
string sucessIf = jo["success"].ToString();
if (sucessIf.ToLower() == "true")
{
string ProductType = jo["ProductType"].ToString();
string FinalDefIo = jo["FinalDefIo"].ToString();
//WEBAPI得到条码
xKNow = GetModeFromBar(ProductType);//从数据库中查询到这个条码的四轴的值
//解析字段
}
}
#endif #endif
// if(Oldm_sKEYENCEBar!= m_sKEYENCEBar) // if(Oldm_sKEYENCEBar!= m_sKEYENCEBar)
xKNow = GetModeFromBar("VWJ070541V0WW824F120223");//从数据库中查询到这个条码的四轴的值 if (DayTypeDics.ContainsKey(FinalDefIDToFind))//当日的post请求有此类SN 得到此类型号
{
OcrBar = DayTypeDics[FinalDefIDToFind];
}
if (OcrBar.IsNullOrEmpty())
{
break;
}
xKNow = GetModeFromBar(OcrBar);//从数据库中查询到这个条码的四轴的值
if (xKNow == null) if (xKNow == null)
@ -1476,25 +1476,21 @@ namespace HisenceYoloDetection
myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now); myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now);
// break; // break;
} }
//if(xKNow.OcrBar!= Old_xKNow.OcrBar)
//{
//}
if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$")) if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$"))
{ {
// Old_xKNow = xKNow;
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now); myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
} }
// break;
} }
// Thread.Sleep(2); // Thread.Sleep(2);
bBar = false; bBar = false;
#if true #if true
// if (bBarTriger)//证明读码器读到东西
{ {
@ -1551,7 +1547,7 @@ namespace HisenceYoloDetection
//模组复位 //模组复位
bTriger = true;//可以进行检测识别了 bTriger = true;//可以进行检测识别了
bBarTriger = false;//读码器可以不工作了
iNum0 = 0; iNum0 = 0;
iNum1 = 0; iNum1 = 0;
break; break;
@ -1618,6 +1614,10 @@ namespace HisenceYoloDetection
}
if(iNum3>=2)
{
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
} }
} }
@ -1680,6 +1680,7 @@ namespace HisenceYoloDetection
originMatShow.Image = cameraMat.ToBitmap(); originMatShow.Image = cameraMat.ToBitmap();
//pictureBox1.Image = cameraMat.ToBitmap(); //pictureBox1.Image = cameraMat.ToBitmap();
_runHandleAfter.Set(); _runHandleAfter.Set();
_runThreadFormtype.Set();
} }
//第二次拍照 //第二次拍照
@ -1731,6 +1732,7 @@ namespace HisenceYoloDetection
/// <summary> /// <summary>
/// 开始识别 /// 开始识别
/// </summary> /// </summary>
///
public void ReadyDetect() public void ReadyDetect()
{ {
_ = Task.Run((Action)(() => _ = Task.Run((Action)(() =>
@ -1742,10 +1744,11 @@ namespace HisenceYoloDetection
{ {
//信号量阻塞 使其不在总数增加和闪烁 //信号量阻塞 使其不在总数增加和闪烁
_runHandleAfter.WaitOne(); _runHandleAfter.WaitOne();
//相机2第一次拍照
//2第一次拍照
//if (IfCam2Triger) //if (IfCam2Triger)
{ {
IfCam2Triger = false; // IfCam2Triger = false;
//OCR识别 //OCR识别
//MLRequest req = new MLRequest(); //MLRequest req = new MLRequest();
//req.currentMat = Cam2ImgShowBar; //req.currentMat = Cam2ImgShowBar;
@ -1768,7 +1771,9 @@ namespace HisenceYoloDetection
string IOcrBAr = xKNow.OcrBar; string IOcrBAr = xKNow.OcrBar;
//xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值 //xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
//这里改成和海信的对接需求 //这里改成和海信的对接需求
IfCam1TwoTriger = false;
_runHandleAfter.Reset();
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr); List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
if (xkWordList.Count() == 1) if (xkWordList.Count() == 1)
{ {
@ -1817,9 +1822,7 @@ namespace HisenceYoloDetection
//相机1第二次拍照 //相机1第二次拍照
// if (IfCam1TwoTriger && bBarTriger) // if (IfCam1TwoTriger && bBarTriger)
{ {
IfCam1TwoTriger = false;
bBarTriger = false;//可能没什么用了
_runHandleAfter.Reset();
//初始化板 //初始化板
Defet_OnDetectionDone(whiteMat, 1); Defet_OnDetectionDone(whiteMat, 1);
Defet_OnDetectionDone(whiteMat, 2); Defet_OnDetectionDone(whiteMat, 2);
@ -1972,8 +1975,7 @@ namespace HisenceYoloDetection
melsecPLCTCPDriver.WriteInt("554", 0);//其他灯灭 melsecPLCTCPDriver.WriteInt("554", 0);//其他灯灭
melsecPLCTCPDriver.WriteInt("556", 0); melsecPLCTCPDriver.WriteInt("556", 0);
melsecPLCTCPDriver.WriteInt("558", 1);//报警 melsecPLCTCPDriver.WriteInt("558", 1);//报警
>>>>>>> 756d23229c59669d628dd94efb8876679bfe21f7
//加上人为判断是否是NG洗衣机 //加上人为判断是否是NG洗衣机
DialogResult dr = MessageBox.Show("是否误检?", "是否误检", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); DialogResult dr = MessageBox.Show("是否误检?", "是否误检", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK) if (dr == DialogResult.OK)
@ -2044,6 +2046,21 @@ namespace HisenceYoloDetection
} }
/// <summary> /// <summary>
/// 发请求获取当日生产的型号
/// </summary>
public void ThreadPost()
{
Task.Run(() => {
while (true)
{
_runThreadFormtype.WaitOne();
GetTypeFromPost();
}
});
}
/// <summary>
/// 根据条码从数据库中获取型号 /// 根据条码从数据库中获取型号
/// </summary> /// </summary>
/// <param name="SkBar"></param> /// <param name="SkBar"></param>
@ -2313,12 +2330,12 @@ namespace HisenceYoloDetection
======= =======
*/ */
// OnGetBar(); // OnGetBar();
melsecPLCTCPDriver.WriteInt("556", 1);//绿灯亮 melsecPLCTCPDriver.WriteInt("556", 1);//绿灯亮
melsecPLCTCPDriver.WriteInt("554", 0);//黄灯灭 melsecPLCTCPDriver.WriteInt("554", 0);//黄灯灭
>>>>>>> 756d23229c59669d628dd94efb8876679bfe21f7 TriggerCameral2();//光电触发拍照 根据SN获取型号 从数据库中得到块值
TriggerCameral2(); ReadyDetect();//相机拍照后检测线程
ReadyDetect(); ThreadPost();//相机拍照后获取当日的型号
myLog("开启流程成功", DateTime.Now); myLog("开启流程成功", DateTime.Now);
} }
@ -2574,7 +2591,7 @@ namespace HisenceYoloDetection
//isFileHaveName = true; //isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile(); //richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText(""); //richTextBox1.AppendText("");
DetectBArMatbox.Text = fName; //DetectBArMatbox.Text = fName;
BarPath = fName; BarPath = fName;
} }
} }
@ -2585,15 +2602,16 @@ namespace HisenceYoloDetection
try try
{ {
string SNText = OcrBarBox.Text;
string type = TypeBox.Text; string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text; string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text; string moveX = moveXbox.Text;
string moveY = moveYbox.Text; string moveY = moveYbox.Text;
string moveZ = moveZbox.Text; string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text; // string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text; // string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text; // string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text; // string movetwoZ = moveTwoZbox.Text;
bool whiteBan = true; bool whiteBan = true;
if (WhiteBanCbx.CheckState == CheckState.Checked)//选中 if (WhiteBanCbx.CheckState == CheckState.Checked)//选中
{ {
@ -2624,31 +2642,31 @@ namespace HisenceYoloDetection
MessageBox.Show("第一次拍照移动的Z只能是数字"); MessageBox.Show("第一次拍照移动的Z只能是数字");
return; return;
} }
if (!Regex.IsMatch(movetwoX, @"^[0-9]+$")) //if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
{ //{
MessageBox.Show("第二次拍照移动的X只能是数字"); // MessageBox.Show("第二次拍照移动的X只能是数字");
return; // return;
} //}
if (!Regex.IsMatch(movetwoY, @"^[0-9]+$")) //if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
{ //{
MessageBox.Show("第二次拍照移动的Y只能是数字"); // MessageBox.Show("第二次拍照移动的Y只能是数字");
return; // return;
} //}
if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$")) //if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
{ //{
MessageBox.Show("第二次拍照移动的Z只能是数字"); // MessageBox.Show("第二次拍照移动的Z只能是数字");
return; // return;
} //}
if (Detect != "" && BarPath != "" && Cam1OnePath != "" && Cam1TwoPath != "" && ModelChangePath != "") if (SNText != "" && BarPath != "" && Cam1OnePath != "" && Cam1TwoPath != "" && ModelChangePath != "")
{ {
int HmoveX = (int)Convert.ToInt64(moveX); int HmoveX = (int)Convert.ToInt64(moveX);
int HmoveY = (int)Convert.ToInt64(moveY); int HmoveY = (int)Convert.ToInt64(moveY);
int HmoveZ = (int)Convert.ToInt64(moveZ); int HmoveZ = (int)Convert.ToInt64(moveZ);
int HmovetwoX = (int)Convert.ToInt64(movetwoX); //int HmovetwoX = (int)Convert.ToInt64(movetwoX);
int HmovetwoY = (int)Convert.ToInt64(movetwoY); //int HmovetwoY = (int)Convert.ToInt64(movetwoY);
int HmovetwoZ = (int)Convert.ToInt64(movetwoZ); //int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
InsertXK_Hisence(whiteBan, HmoveX, HmoveY, HmoveZ, HmovetwoX, HmovetwoY, HmovetwoZ); InsertXK_Hisence(whiteBan, SNText, HmoveX, HmoveY, HmoveZ);
} }
@ -2663,15 +2681,73 @@ namespace HisenceYoloDetection
MessageBox.Show(es.Message); MessageBox.Show(es.Message);
} }
} }
public void InsertXK_Hisence(bool ifwhiteBan, int MoveX, int MoveY, int MoveZ, int MoveTwoX, int MoveTwoY, int MoveTwoZ) public string FormBarType(string SN)
{ {
PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel(); string productType = "N/A";
IpaddleOcrModel.Load(ModelChangePath, "CPU"); string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
//用中文文模型来识别条码 DateTime dt = DateTime.Now;
MLRequest OcrBari = new MLRequest(); string today = dt.ToString("yyyy-MM-dd");
OcrBari.currentMat = Cv2.ImRead(BarPath);
string IOcrBAr = DetMachineBar(ref OcrBari); string startTime = today;
string endTime = today;
string lineBody = "BZ-PC";
string materialDescript = "皂盒";
JObject patientInfo = new JObject
{
["StartTime"] = startTime,
["EndTime"] = endTime,
["LineBody"] = lineBody,
["MaterialDescripts"] = new JArray { materialDescript }
};
string sendData = patientInfo.ToString();
string resultData = Post(sendData, url, "application/x-www-form-urlencoded", "application/json");
if (resultData != null)
{
JObject responseJson = JObject.Parse(resultData);
bool success = responseJson["success"] != null && (bool)responseJson["success"];
if (success)
{
string FinalDefIDToFind = SN.Substring(1, 18);// 目标 FinalDefID
JArray dataArray = responseJson["data"] as JArray;
if (dataArray != null)
{
foreach (JObject dataItem in dataArray)
{
if (dataItem["FinalDefID"] != null && dataItem["FinalDefID"].ToString() == FinalDefIDToFind)
{
productType = dataItem["ProductType"] != null ? dataItem["ProductType"].ToString() : "N/A";
Console.WriteLine($"FinalDefID: {FinalDefIDToFind}, ProductType: {productType}");
break;
}
}
}
}
else
{
string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
Console.WriteLine("请求失败:" + returnMsg);
}
}
else
{
Console.WriteLine("请求失败:未返回数据");
}
return productType;
// sw.Stop();
// Console.WriteLine("时间请求i" + sw.ElapsedMilliseconds);
}
public void InsertXK_Hisence(bool ifwhiteBan, string SNtext, int MoveX, int MoveY, int MoveZ)
{
// PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
// IpaddleOcrModel.Load(ModelChangePath, "CPU");
string IOcrBAr = FormBarType(SNtext);
XK_HisenceWord xkWord = new XK_HisenceWord(); XK_HisenceWord xkWord = new XK_HisenceWord();
xkWord.OcrBar = IOcrBAr; xkWord.OcrBar = IOcrBAr;
xkWord.TwoIFWhile = ifwhiteBan; xkWord.TwoIFWhile = ifwhiteBan;
@ -2782,7 +2858,7 @@ namespace HisenceYoloDetection
} }
DateTime dt2 = DateTime.Now; DateTime dt2 = DateTime.Now;
XKHisence xK = new XKHisence("1", IOcrBAr, MoveX, MoveY, MoveZ, detstr, OcrTextone, MoveTwoX, MoveTwoY, MoveTwoZ, ModelChangePath, "", OcrTextTwo); XKHisence xK = new XKHisence("1", IOcrBAr, MoveX, MoveY, MoveZ, detstr, OcrTextone, MoveX, MoveY, MoveZ, ModelChangePath, "", OcrTextTwo);
//string log="D:\\Hisence\\detImages\\" + dt2.Year.ToString() + dt2.Month.ToString() + dt2.Day.ToString() + dt2.Hour.ToString() + dt2.Minute.ToString() + dt2.Millisecond.ToString() + "2result.log"; //string log="D:\\Hisence\\detImages\\" + dt2.Year.ToString() + dt2.Month.ToString() + dt2.Day.ToString() + dt2.Hour.ToString() + dt2.Minute.ToString() + dt2.Millisecond.ToString() + "2result.log";
// using (StreamWriter sw=new StreamWriter(log, true)) // using (StreamWriter sw=new StreamWriter(log, true))
// { // {
@ -3025,21 +3101,8 @@ namespace HisenceYoloDetection
{ {
try try
{ {
string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text;
string moveY = moveYbox.Text;
string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text;
string sql = "select * from XK_Hisence where type='" + type + "' or OcrBar='" + OcrBar + "'";
DataSet dataSet = SQLiteHelper.Query(sql);
InsertDataDgv.DataSource = dataSet.Tables[0];
} }
catch (Exception es) catch (Exception es)
{ {
@ -3708,7 +3771,11 @@ namespace HisenceYoloDetection
{ {
melsecPLCTCPDriver.WriteInt("550", 0); melsecPLCTCPDriver.WriteInt("550", 0);
} }
/// <summary>
/// 软件关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
melsecPLCTCPDriver.WriteInt("550", 0); melsecPLCTCPDriver.WriteInt("550", 0);
@ -3721,5 +3788,14 @@ namespace HisenceYoloDetection
{ {
} }
private void button1_Click_1(object sender, EventArgs e)
{
if (!m_sKEYENCEBar.IsNullOrEmpty())
{
OcrBarBox.Text = m_sKEYENCEBar;
}
}
} }
} }

View File

@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>569, 17</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
@ -135,9 +138,6 @@
<metadata name="timer6.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer6.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>477, 17</value> <value>477, 17</value>
</metadata> </metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>569, 17</value>
</metadata>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>733, 17</value> <value>733, 17</value>
</metadata> </metadata>