From 9a89e11ef933360bb55966069bee14913d17c7a9 Mon Sep 17 00:00:00 2001
From: 820689062 <820689062@qq.com>
Date: Sun, 14 Jul 2024 16:10:14 +0800
Subject: [PATCH] =?UTF-8?q?7/14=E5=8F=B7=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
HisenceYoloDetection/MainForm.Designer.cs | 187 ++-----
HisenceYoloDetection/MainForm.cs | 578 ++++++++++++++--------
HisenceYoloDetection/MainForm.resx | 6 +-
3 files changed, 410 insertions(+), 361 deletions(-)
diff --git a/HisenceYoloDetection/MainForm.Designer.cs b/HisenceYoloDetection/MainForm.Designer.cs
index 6fddfd2..90392f9 100644
--- a/HisenceYoloDetection/MainForm.Designer.cs
+++ b/HisenceYoloDetection/MainForm.Designer.cs
@@ -141,13 +141,14 @@
InitMachine = new Button();
tabPage3 = new TabPage();
panel2 = new Panel();
+ button1 = new Button();
+ contextMenuStrip1 = new ContextMenuStrip(components);
WhiteBanCbx = new CheckBox();
label33 = new Label();
label28 = new Label();
openModelBtn = new Button();
modelChangeCbx = new TextBox();
label34 = new Label();
- button4 = new Button();
OpenTwoDirBtn = new Button();
OpenDirBtn = new Button();
Cam2MatCbx = new TextBox();
@@ -155,15 +156,7 @@
Cam1MatCbx = new TextBox();
label23 = new Label();
QueryoneBtn = new Button();
- DetectBArMatbox = new TextBox();
- label24 = new Label();
InsertBtn = new Button();
- moveTwoZbox = new TextBox();
- label25 = new Label();
- moveTwoYbox = new TextBox();
- label26 = new Label();
- moveTwoXbox = new TextBox();
- label27 = new Label();
moveZbox = new TextBox();
moveYbox = new TextBox();
label29 = new Label();
@@ -182,7 +175,6 @@
timer5 = new System.Windows.Forms.Timer(components);
timer6 = new System.Windows.Forms.Timer(components);
richTextBox1 = new RichTextBox();
- contextMenuStrip1 = new ContextMenuStrip(components);
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
tabPage2.SuspendLayout();
panel1.SuspendLayout();
@@ -1419,13 +1411,13 @@
//
// panel2
//
+ panel2.Controls.Add(button1);
panel2.Controls.Add(WhiteBanCbx);
panel2.Controls.Add(label33);
panel2.Controls.Add(label28);
panel2.Controls.Add(openModelBtn);
panel2.Controls.Add(modelChangeCbx);
panel2.Controls.Add(label34);
- panel2.Controls.Add(button4);
panel2.Controls.Add(OpenTwoDirBtn);
panel2.Controls.Add(OpenDirBtn);
panel2.Controls.Add(Cam2MatCbx);
@@ -1433,15 +1425,7 @@
panel2.Controls.Add(Cam1MatCbx);
panel2.Controls.Add(label23);
panel2.Controls.Add(QueryoneBtn);
- panel2.Controls.Add(DetectBArMatbox);
- panel2.Controls.Add(label24);
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(moveYbox);
panel2.Controls.Add(label29);
@@ -1460,12 +1444,30 @@
panel2.TabIndex = 1;
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.AutoSize = true;
WhiteBanCbx.Checked = true;
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.Name = "WhiteBanCbx";
WhiteBanCbx.Size = new Size(59, 29);
@@ -1476,7 +1478,7 @@
// label33
//
label33.AutoSize = true;
- label33.Location = new Point(471, 232);
+ label33.Location = new Point(596, 147);
label33.Margin = new Padding(4, 0, 4, 0);
label33.Name = "label33";
label33.Size = new Size(243, 25);
@@ -1506,7 +1508,7 @@
//
// modelChangeCbx
//
- modelChangeCbx.Location = new Point(1059, 14);
+ modelChangeCbx.Location = new Point(750, 14);
modelChangeCbx.Margin = new Padding(4, 2, 4, 2);
modelChangeCbx.Name = "modelChangeCbx";
modelChangeCbx.Size = new Size(241, 31);
@@ -1516,27 +1518,16 @@
// label34
//
label34.AutoSize = true;
- label34.Location = new Point(923, 19);
+ label34.Location = new Point(597, 14);
label34.Margin = new Padding(4, 0, 4, 0);
label34.Name = "label34";
label34.Size = new Size(138, 25);
label34.TabIndex = 33;
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.Location = new Point(895, 184);
+ OpenTwoDirBtn.Location = new Point(1066, 105);
OpenTwoDirBtn.Margin = new Padding(4, 2, 4, 2);
OpenTwoDirBtn.Name = "OpenTwoDirBtn";
OpenTwoDirBtn.Size = new Size(96, 35);
@@ -1547,7 +1538,7 @@
//
// OpenDirBtn
//
- OpenDirBtn.Location = new Point(895, 142);
+ OpenDirBtn.Location = new Point(1066, 53);
OpenDirBtn.Margin = new Padding(4, 2, 4, 2);
OpenDirBtn.Name = "OpenDirBtn";
OpenDirBtn.Size = new Size(96, 34);
@@ -1558,7 +1549,7 @@
//
// Cam2MatCbx
//
- Cam2MatCbx.Location = new Point(608, 190);
+ Cam2MatCbx.Location = new Point(750, 111);
Cam2MatCbx.Margin = new Padding(4, 2, 4, 2);
Cam2MatCbx.Name = "Cam2MatCbx";
Cam2MatCbx.Size = new Size(279, 31);
@@ -1568,7 +1559,7 @@
// label22
//
label22.AutoSize = true;
- label22.Location = new Point(471, 190);
+ label22.Location = new Point(596, 105);
label22.Margin = new Padding(4, 0, 4, 0);
label22.Name = "label22";
label22.Size = new Size(138, 25);
@@ -1577,7 +1568,7 @@
//
// Cam1MatCbx
//
- Cam1MatCbx.Location = new Point(608, 142);
+ Cam1MatCbx.Location = new Point(750, 59);
Cam1MatCbx.Margin = new Padding(4, 2, 4, 2);
Cam1MatCbx.Name = "Cam1MatCbx";
Cam1MatCbx.Size = new Size(279, 31);
@@ -1587,7 +1578,7 @@
// label23
//
label23.AutoSize = true;
- label23.Location = new Point(472, 147);
+ label23.Location = new Point(597, 62);
label23.Margin = new Padding(4, 0, 4, 0);
label23.Name = "label23";
label23.Size = new Size(138, 25);
@@ -1596,7 +1587,7 @@
//
// QueryoneBtn
//
- QueryoneBtn.Location = new Point(1077, 209);
+ QueryoneBtn.Location = new Point(978, 204);
QueryoneBtn.Margin = new Padding(4, 2, 4, 2);
QueryoneBtn.Name = "QueryoneBtn";
QueryoneBtn.Size = new Size(148, 50);
@@ -1605,96 +1596,20 @@
QueryoneBtn.UseVisualStyleBackColor = true;
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.Location = new Point(1077, 87);
+ InsertBtn.Location = new Point(608, 204);
InsertBtn.Margin = new Padding(4, 2, 4, 2);
InsertBtn.Name = "InsertBtn";
- InsertBtn.Size = new Size(148, 45);
+ InsertBtn.Size = new Size(156, 56);
InsertBtn.TabIndex = 22;
InsertBtn.Text = "插入";
InsertBtn.UseVisualStyleBackColor = true;
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.Location = new Point(143, 182);
+ moveZbox.Location = new Point(183, 184);
moveZbox.Margin = new Padding(4, 2, 4, 2);
moveZbox.Name = "moveZbox";
moveZbox.Size = new Size(287, 31);
@@ -1703,7 +1618,7 @@
//
// moveYbox
//
- moveYbox.Location = new Point(143, 137);
+ moveYbox.Location = new Point(183, 141);
moveYbox.Margin = new Padding(4, 2, 4, 2);
moveYbox.Name = "moveYbox";
moveYbox.Size = new Size(287, 31);
@@ -1722,7 +1637,7 @@
//
// moveXbox
//
- moveXbox.Location = new Point(143, 98);
+ moveXbox.Location = new Point(182, 101);
moveXbox.Margin = new Padding(4, 2, 4, 2);
moveXbox.Name = "moveXbox";
moveXbox.Size = new Size(287, 31);
@@ -1741,7 +1656,7 @@
//
// OcrBarBox
//
- OcrBarBox.Location = new Point(143, 50);
+ OcrBarBox.Location = new Point(183, 56);
OcrBarBox.Margin = new Padding(4, 2, 4, 2);
OcrBarBox.Name = "OcrBarBox";
OcrBarBox.Size = new Size(287, 31);
@@ -1751,16 +1666,16 @@
// label31
//
label31.AutoSize = true;
- label31.Location = new Point(18, 56);
+ label31.Location = new Point(23, 59);
label31.Margin = new Padding(4, 0, 4, 0);
label31.Name = "label31";
- label31.Size = new Size(54, 25);
+ label31.Size = new Size(41, 25);
label31.TabIndex = 4;
- label31.Text = "条码";
+ label31.Text = "SN";
//
// TypeBox
//
- TypeBox.Location = new Point(143, 11);
+ TypeBox.Location = new Point(183, 14);
TypeBox.Margin = new Padding(4, 2, 4, 2);
TypeBox.Name = "TypeBox";
TypeBox.Size = new Size(287, 31);
@@ -1769,7 +1684,7 @@
//
// queryALLBtn
//
- queryALLBtn.Location = new Point(1077, 147);
+ queryALLBtn.Location = new Point(798, 204);
queryALLBtn.Margin = new Padding(4, 2, 4, 2);
queryALLBtn.Name = "queryALLBtn";
queryALLBtn.Size = new Size(148, 56);
@@ -1809,12 +1724,6 @@
richTextBox1.TabIndex = 1;
richTextBox1.Text = "";
//
- // contextMenuStrip1
- //
- contextMenuStrip1.ImageScalingSize = new Size(24, 24);
- contextMenuStrip1.Name = "contextMenuStrip1";
- contextMenuStrip1.Size = new Size(61, 4);
- //
// MainForm
//
AutoScaleDimensions = new SizeF(12F, 25F);
@@ -1977,7 +1886,6 @@
private Label label21;
private TabPage tabPage3;
private Panel panel2;
- private Button button4;
private Button OpenTwoDirBtn;
private Button OpenDirBtn;
private TextBox Cam2MatCbx;
@@ -1985,15 +1893,7 @@
private TextBox Cam1MatCbx;
private Label label23;
private Button QueryoneBtn;
- private TextBox DetectBArMatbox;
- private Label label24;
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 Label label28;
private TextBox moveYbox;
@@ -2038,5 +1938,6 @@
private XKRS.UI.Canvas canvas1;
private XKRS.UI.Canvas canvas6;
private XKRS.UI.Canvas canvas2;
+ private Button button1;
}
}
diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs
index 4b3c464..b174f67 100644
--- a/HisenceYoloDetection/MainForm.cs
+++ b/HisenceYoloDetection/MainForm.cs
@@ -6,6 +6,7 @@ using OpenCvSharp;
using OpenCvSharp.Dnn;
using OpenCvSharp.Extensions;
using OpenCvSharp.XFeatures2D;
+using STTech.CodePlus.Threading;
using Sunny.UI;
using Sunny.UI.Win32;
using System;
@@ -25,6 +26,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
+using System.Xml.Serialization;
using XKRS.Device.SimboVision.SimboHelper;
using XKRS.UI;
using static HisenceYoloDetection.CheckDiffSciHelper;
@@ -69,6 +71,7 @@ namespace HisenceYoloDetection
AutoResetEvent _runHandleBefore = new AutoResetEvent(false);
ManualResetEvent _runHandleAfter = new ManualResetEvent(false);
+ AutoResetEvent _runThreadFormtype = new AutoResetEvent(false);
bool PLC545 = false;
bool PLC548 = false;
@@ -289,50 +292,115 @@ namespace HisenceYoloDetection
/// Ĭ application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary
/// Ĭapplication/json
///
- public string Post(string parameterData, string serviceUrl, string ContentType = "application/json", string Accept = "application/json")
+ public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
{
- //ȸûuriַ
- //string serviceUrl = string.Format("{0}/{1}", this.BaseUri, uri);
+ try
+ {
+ // Web
+ HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
+ byte[] buf = Encoding.UTF8.GetBytes($"inputvalue={Uri.EscapeDataString(parameterData)}");
- //Webʶ
- HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
- //ûתɡUTF-8ֽ
- byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(parameterData);
+ myRequest.Method = "POST";
+ myRequest.Accept = accept;
+ myRequest.ContentType = contentType;
+ myRequest.ContentLength = buf.Length;
- myRequest.Method = "POST";
- //myRequest.Accept = "application/json";
- //myRequest.ContentType = "application/json"; // //Content-Type: application/x-www-form-urlencoded
- myRequest.AutomaticDecompression = DecompressionMethods.GZip;
- myRequest.Accept = Accept;
- //myRequest.ContentType = ContentType;
- myRequest.ContentType = "application/json; charset=UTF-8";
- myRequest.ContentLength = buf.Length;
- myRequest.MaximumAutomaticRedirections = 1;
- myRequest.AllowAutoRedirect = true;
+ //
+ using (Stream stream = myRequest.GetRequestStream())
+ {
+ stream.Write(buf, 0, buf.Length);
+ }
- //myRequest.Headers.Add("content-type", "application/json");
- //myRequest.Headers.Add("accept-encoding", "gzip");
- //myRequest.Headers.Add("accept-charset", "utf-8");
-
- //
- Stream stream = myRequest.GetRequestStream();
- stream.Write(buf, 0, buf.Length);
- stream.Close();
-
- //ͨWebʶȡӦ
- HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
- //ͨӦStreamReaderΪStreamReader
- StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
- //string returnXml = HttpUtility.UrlDecode(reader.ReadToEnd());//б
- string returnData = reader.ReadToEnd();//StreamReaderͿԴӦݴͷβ
-
- reader.Close();
- myResponse.Close();
-
- return returnData;
+ // ȡӦ
+ 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
+ #endregion
+ Dictionary DayTypeDics = new Dictionary();//ŵյ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);
+
+
+
+ }
+ }
+ }
+ else
+ {
+ string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
+ Console.WriteLine("ʧܣ" + returnMsg);
+ }
+ }
+ else
+ {
+ Console.WriteLine("ʧܣδ");
+ }
+
+ }
///
///
///
@@ -340,39 +408,65 @@ namespace HisenceYoloDetection
///
private void MainForm_Load(object sender, EventArgs e)
{
- //ַ
- //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;
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
- //string starttime=string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
+ 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)
+ {
+ 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);
- //string startTime = starttime;
- //string EndTime = starttime;
- //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")
- //{
- // string ProductType = jo["ProductType"].ToString();
- // string FinalDefIo = jo["FinalDefIo"].ToString();
- // //ֶ
- //}
if (_runHandleBefore == null)
{
_runHandleBefore = new AutoResetEvent(false);
@@ -451,6 +545,11 @@ namespace HisenceYoloDetection
myLogDelegateUI = new MyLogDelegateUI(initAll3);//ί
+ Scanner.Strart();
+ Scanner.OnClientDataReceived -= OnDataReceived;
+ Scanner.OnClientDataReceived += OnDataReceived;
+ Scanner.btnSendMsg("LON\r");//Ϳָ
+ myLog("Ͷʿɨǹָ", DateTime.Now);
//ʼPLC
melsecPLCTCPDriver.Start();
@@ -761,7 +860,7 @@ namespace HisenceYoloDetection
try
{
//ʼ
-
+
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
//dataGridView1.DataSource = dataSet.Tables[0];
@@ -778,15 +877,11 @@ namespace HisenceYoloDetection
Cam1.OnHImageOutput -= OnCameraMatOutPut;
Cam1.OnHImageOutput += OnCameraMatOutPut;
//Cam2.OnHImageOutput -= OnCameraMatOutPut2;
- // Cam2.OnHImageOutput += OnCameraMatOutPut2;
+ // Cam2.OnHImageOutput += OnCameraMatOutPut2;
OKOrNGShow.Image = OKbitmap;
//ʼɨǹ
- Scanner.Strart();
- Scanner.OnClientDataReceived -= OnDataReceived;
- Scanner.OnClientDataReceived += OnDataReceived;
- Scanner.btnSendMsg("LON\r");//Ϳָ
- myLog("Ͷʿɨǹָ", DateTime.Now);
+
//PLCʹܿ
melsecPLCTCPDriver.WriteInt("581", 0);//λɿ
@@ -1229,20 +1324,20 @@ namespace HisenceYoloDetection
xKNow = GetModeFromBar("VWJ070541V0WW824F120223");//ݿвѯֵ
- if (xKNow==null)
+ if (xKNow == null)
{
myLog("ݿûƥ" + m_sKEYENCEBar, DateTime.Now);
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]+$"))
{
- // Old_xKNow = xKNow;
+ // Old_xKNow = xKNow;
myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now);
- bBarTriger = true;
+
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLCƵƶ
}
@@ -1306,6 +1401,7 @@ namespace HisenceYoloDetection
{
int iNum1 = 0;
int iNum0 = 0;
+ int iNum3 = 0;
Thread.CurrentThread.Priority = ThreadPriority.Highest;
while (true)
{
@@ -1336,7 +1432,8 @@ namespace HisenceYoloDetection
else
{
iNum1 = 0;
- melsecPLCTCPDriver.WriteInt("550", 1);//
+ iNum3++;//ȡûﵽϴ»ϵĴ
+
}
if (iNum1 >= 2)
{
@@ -1350,50 +1447,23 @@ namespace HisenceYoloDetection
{
_runHandleBefore.WaitOne();
//ijɺͺŵĶԽ
+ string OcrBar = "";
+ string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// Ŀ FinalDefID
#if false
{
- // Oldm_sKEYENCEBar= m_sKEYENCEBar;
- //ȡ
- //ַ
- 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);//ݿвѯֵ
- //ֶ
- }
- }
+ OcrBar=FormBarType(FinalDefIDToFind)
#endif
// 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)
@@ -1401,29 +1471,25 @@ namespace HisenceYoloDetection
myLog("ݿûƥ" + m_sKEYENCEBar, DateTime.Now);
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]+$"))
{
- // Old_xKNow = xKNow;
- myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now);
- //MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLCƵƶ
+ myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now);
+
+
}
- // break;
}
Thread.Sleep(2);
bBar = false;
#if true
- // if (bBarTriger)//֤
+
{
-
+
myLog("һβɼͼ", DateTime.Now);
//ƶģ βĵַ Ƿǰƶ
@@ -1449,7 +1515,7 @@ namespace HisenceYoloDetection
{
MoveToP(5815, YPos, ZPos + (int)(dismove));
}
-
+
Cam1.SnapshotCount = 0;
Cam1.Snapshot();
@@ -1461,8 +1527,8 @@ namespace HisenceYoloDetection
//{
// MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ);
//}
-
- // MoveToP(51043, YPos, ZPos + (int)(dismove));
+
+ // MoveToP(51043, YPos, ZPos + (int)(dismove));
//Cam1.Snapshot();
MoveToP(5815, YPos, ZPos);
melsecPLCTCPDriver.WriteInt("550", 0);//
@@ -1476,7 +1542,7 @@ namespace HisenceYoloDetection
//ģ鸴λ
bTriger = true;//Խмʶ
- bBarTriger = false;//Բ
+
iNum0 = 0;
iNum1 = 0;
break;
@@ -1543,6 +1609,10 @@ namespace HisenceYoloDetection
+ }
+ if(iNum3>=2)
+ {
+ melsecPLCTCPDriver.WriteInt("550", 1);//
}
}
@@ -1605,18 +1675,19 @@ namespace HisenceYoloDetection
originMatShow.Image = cameraMat.ToBitmap();
//pictureBox1.Image = cameraMat.ToBitmap();
_runHandleAfter.Set();
+ _runThreadFormtype.Set();
}
//ڶ
if (SnapshotCount == 2)
{
-
- Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\\\1\\002.jpg");
+
+ Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\\\1\\002.jpg");
//Cam1ImgTwo = cameraMat;
IfCam1TwoTriger = true;
//originMatShow2.Image = cameraMat.ToBitmap();
-
+
}
@@ -1656,6 +1727,7 @@ namespace HisenceYoloDetection
///
/// ʼʶ
///
+ ///
public void ReadyDetect()
{
_ = Task.Run((Action)(() =>
@@ -1667,10 +1739,11 @@ namespace HisenceYoloDetection
{
//ź ʹ䲻Ӻ˸
_runHandleAfter.WaitOne();
- //2һ
+
+ //2һ
//if (IfCam2Triger)
{
- IfCam2Triger = false;
+ // IfCam2Triger = false;
//OCRʶ
//MLRequest req = new MLRequest();
//req.currentMat = Cam2ImgShowBar;
@@ -1693,13 +1766,15 @@ namespace HisenceYoloDetection
string IOcrBAr = xKNow.OcrBar;
//xKNow = GetModeFromBar(IOcrBAr);//ݿвѯֵ
//ijɺͺŵĶԽ
+ IfCam1TwoTriger = false;
+ _runHandleAfter.Reset();
List xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
if (xkWordList.Count() == 1)
{
xK_HisenceSQLWord = xkWordList[0];
}
- if(xKNow==null)
+ if (xKNow == null)
{
myLog("δƥ" + IOcrBAr, DateTime.Now);
break;
@@ -1729,7 +1804,7 @@ namespace HisenceYoloDetection
//}
myLog("ͺƥɹ" + IOcrBAr, DateTime.Now);
-
+
}
@@ -1740,11 +1815,9 @@ namespace HisenceYoloDetection
}
//1ڶ
- // if (IfCam1TwoTriger && bBarTriger)
+ // if (IfCam1TwoTriger && bBarTriger)
{
- IfCam1TwoTriger = false;
- bBarTriger = false;//ûʲô
- _runHandleAfter.Reset();
+
//ʼ
Defet_OnDetectionDone(whiteMat, 1);
Defet_OnDetectionDone(whiteMat, 2);
@@ -1753,7 +1826,7 @@ namespace HisenceYoloDetection
Defet_OnDetectionDone(whiteMat, 5);
Defet_OnDetectionDone(whiteMat, 6);
Defet_OnDetectionDone(whiteMat, 7);
-
+
XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
AllDsums++;
@@ -1775,14 +1848,14 @@ namespace HisenceYoloDetection
List strMatListOne = new List();
List strMatFuzzyListOne = new List();
Mat mResultCut = req.currentMat.Clone();
-
+
if (mL.ResultMap != null)
{
mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
ResultMatShow.Image = mL.ResultMap;
}
-
+
////
//MLRequest req2 = new MLRequest();
//req2.currentMat = Cam1ImgTwo;
@@ -1802,7 +1875,7 @@ namespace HisenceYoloDetection
List strMatListTwo = new List();
List strMatFuzzyListTwo = new List();
- // Mat mResultCut2 = req2.currentMat.Clone();
+ // Mat mResultCut2 = req2.currentMat.Clone();
Dictionary keyValueResult = new Dictionary();
Dictionary keyValueResult2 = new Dictionary();
#region ִжλȶ
@@ -1840,18 +1913,18 @@ namespace HisenceYoloDetection
//Mat mCut = new Mat();
Stopwatch sw = new Stopwatch();
sw.Start();
-
- InsertSqlRunDataButton(ref keyValueResult, false, ref mResultCut, mL, mLButton, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
-
- // InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
+ InsertSqlRunDataButton(ref keyValueResult, false, ref mResultCut, mL, mLButton, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
+
+
+ // InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
sw.Stop();
myLog("ʱ" + sw.ElapsedMilliseconds, DateTime.Now);
}
-
-
+
+
if (MatchStr)
{
@@ -1868,7 +1941,7 @@ namespace HisenceYoloDetection
// int sqlblocksum=
-
+
melsecPLCTCPDriver.WriteInt("550", 0);//
if (MatchStr)
@@ -1890,7 +1963,7 @@ namespace HisenceYoloDetection
melsecPLCTCPDriver.WriteInt("554", 0);//
melsecPLCTCPDriver.WriteInt("556", 0);
melsecPLCTCPDriver.WriteInt("558", 1);//
-
+
//ΪжǷNGϴ»
DialogResult dr = MessageBox.Show("Ƿ죿", "Ƿ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
@@ -1902,7 +1975,7 @@ namespace HisenceYoloDetection
WUsums++;
this.Invoke(new Action(() =>
{
- double percent = (double)WUsums/ AllDsums;
+ double percent = (double)WUsums / AllDsums;
string percentText = percent.ToString("0.0%");//percentTextֵΪ10.0%
textBox1.Text = percentText;
OKOrNGShow.Image = OKbitmap;
@@ -1910,7 +1983,7 @@ namespace HisenceYoloDetection
myLog("ƥʧ", DateTime.Now);
}
else
- {
+ {
NGDsums++;
melsecPLCTCPDriver.WriteInt("558", 0);//
melsecPLCTCPDriver.WriteInt("552", 0);//
@@ -1923,7 +1996,7 @@ namespace HisenceYoloDetection
myLog("ƥɹ", DateTime.Now);
}
-
+
}
@@ -1949,6 +2022,21 @@ namespace HisenceYoloDetection
}
///
+ /// ȡͺ
+ ///
+ public void ThreadPost()
+ {
+ Task.Run(() => {
+ while (true)
+ {
+
+ _runThreadFormtype.WaitOne();
+ GetTypeFromPost();
+
+ }
+ });
+ }
+ ///
/// ݿлȡͺ
///
///
@@ -2010,7 +2098,7 @@ namespace HisenceYoloDetection
//
if (data.Length > 10)
{
- m_sKEYENCEBar=string.Empty;
+ m_sKEYENCEBar = string.Empty;
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
// myLog("ͺOcr" + m_sKEYENCEBar, DateTime.Now);
_runHandleBefore.Set();
@@ -2211,11 +2299,12 @@ namespace HisenceYoloDetection
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
*/
- // OnGetBar();
+ // OnGetBar();
melsecPLCTCPDriver.WriteInt("556", 1);//̵
melsecPLCTCPDriver.WriteInt("554", 0);//Ƶ
- TriggerCameral2();
- ReadyDetect();
+ TriggerCameral2();//紥 SNȡͺ ݿеõֵ
+ ReadyDetect();//պ߳
+ ThreadPost();//պȡյͺ
myLog("̳ɹ", DateTime.Now);
}
@@ -2471,7 +2560,7 @@ namespace HisenceYoloDetection
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
- DetectBArMatbox.Text = fName;
+ //DetectBArMatbox.Text = fName;
BarPath = fName;
}
}
@@ -2482,15 +2571,16 @@ namespace HisenceYoloDetection
try
{
+ string SNText = OcrBarBox.Text;
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 Detect = DetectBArMatbox.Text;
+ // string movetwoX = moveTwoXbox.Text;
+ // string movetwoY = moveTwoYbox.Text;
+ // string movetwoZ = moveTwoZbox.Text;
bool whiteBan = true;
if (WhiteBanCbx.CheckState == CheckState.Checked)//ѡ
{
@@ -2521,31 +2611,31 @@ namespace HisenceYoloDetection
MessageBox.Show("һƶZֻ");
return;
}
- if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
- {
- MessageBox.Show("ڶƶXֻ");
- return;
- }
- if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
- {
- MessageBox.Show("ڶƶYֻ");
- return;
- }
- if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
- {
- MessageBox.Show("ڶƶZֻ");
- return;
- }
+ //if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
+ //{
+ // MessageBox.Show("ڶƶXֻ");
+ // return;
+ //}
+ //if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
+ //{
+ // MessageBox.Show("ڶƶYֻ");
+ // return;
+ //}
+ //if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
+ //{
+ // MessageBox.Show("ڶƶZֻ");
+ // return;
+ //}
- if (Detect != "" && BarPath != "" && Cam1OnePath != "" && Cam1TwoPath != "" && ModelChangePath != "")
+ if (SNText != "" && BarPath != "" && Cam1OnePath != "" && Cam1TwoPath != "" && ModelChangePath != "")
{
int HmoveX = (int)Convert.ToInt64(moveX);
int HmoveY = (int)Convert.ToInt64(moveY);
int HmoveZ = (int)Convert.ToInt64(moveZ);
- int HmovetwoX = (int)Convert.ToInt64(movetwoX);
- int HmovetwoY = (int)Convert.ToInt64(movetwoY);
- int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
- InsertXK_Hisence(whiteBan, HmoveX, HmoveY, HmoveZ, HmovetwoX, HmovetwoY, HmovetwoZ);
+ //int HmovetwoX = (int)Convert.ToInt64(movetwoX);
+ //int HmovetwoY = (int)Convert.ToInt64(movetwoY);
+ //int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
+ InsertXK_Hisence(whiteBan, SNText, HmoveX, HmoveY, HmoveZ);
}
@@ -2560,15 +2650,73 @@ namespace HisenceYoloDetection
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();
- IpaddleOcrModel.Load(ModelChangePath, "CPU");
+ string productType = "N/A";
+ string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
- //ģʶ
- MLRequest OcrBari = new MLRequest();
- OcrBari.currentMat = Cv2.ImRead(BarPath);
- string IOcrBAr = DetMachineBar(ref OcrBari);
+ 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 = 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();
xkWord.OcrBar = IOcrBAr;
xkWord.TwoIFWhile = ifwhiteBan;
@@ -2613,7 +2761,7 @@ namespace HisenceYoloDetection
Mat mResultCut = CamOneI.currentMat.Clone();
//Mat mCut = new Mat();
Dictionary keyValueResult = new Dictionary();
- InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
+ InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
@@ -2679,7 +2827,7 @@ namespace HisenceYoloDetection
}
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";
// using (StreamWriter sw=new StreamWriter(log, true))
// {
@@ -2922,21 +3070,8 @@ namespace HisenceYoloDetection
{
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)
{
@@ -3047,7 +3182,7 @@ namespace HisenceYoloDetection
break;
case 7:
{
- // canvas7.ImaMAt = detectionImage;
+ // canvas7.ImaMAt = detectionImage;
}
break;
case 8:
@@ -3077,7 +3212,7 @@ namespace HisenceYoloDetection
/// صĶλĽ
///
///
- public void InsertSqlRunDataButton(ref Dictionary keyValueResult, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List strMatList, ref List strMatRefList, ref PaddleOcrModel IOcrModel)
+ public void InsertSqlRunDataButton(ref Dictionary keyValueResult, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List strMatList, ref List strMatRefList, ref PaddleOcrModel IOcrModel)
{
#if true
//try
@@ -3486,7 +3621,7 @@ namespace HisenceYoloDetection
{
SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
-
+
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.SevenblockPath;
@@ -3605,10 +3740,23 @@ namespace HisenceYoloDetection
{
melsecPLCTCPDriver.WriteInt("550", 0);
}
-
+ ///
+ /// ر
+ ///
+ ///
+ ///
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
melsecPLCTCPDriver.WriteInt("550", 0);
}
+
+ private void button1_Click_1(object sender, EventArgs e)
+ {
+ if (!m_sKEYENCEBar.IsNullOrEmpty())
+ {
+ OcrBarBox.Text = m_sKEYENCEBar;
+ }
+
+ }
}
}
diff --git a/HisenceYoloDetection/MainForm.resx b/HisenceYoloDetection/MainForm.resx
index cbb8e7a..790fda2 100644
--- a/HisenceYoloDetection/MainForm.resx
+++ b/HisenceYoloDetection/MainForm.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 569, 17
+
17, 17
@@ -135,9 +138,6 @@
477, 17
-
- 569, 17
-
733, 17