修改读码器和MES系统对接
This commit is contained in:
parent
eb55c5b784
commit
15df28b3b4
@ -17,8 +17,8 @@ Global
|
|||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.ActiveCfg = Debug|X64
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.ActiveCfg = Debug|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.Build.0 = Debug|X64
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.Build.0 = Debug|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.ActiveCfg = Release|X64
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.ActiveCfg = Release|X64
|
||||||
|
@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Platforms>AnyCPU;X64</Platforms>
|
<Platforms>AnyCPU;X64</Platforms>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<ApplicationIcon>bin\X64\Debug\net7.0-windows\Logo.ico</ApplicationIcon>
|
<ApplicationIcon>bin\X64\Debug\net7.0-windows\Logo.ico</ApplicationIcon>
|
||||||
|
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
124
HisenceYoloDetection/MainForm.Designer.cs
generated
124
HisenceYoloDetection/MainForm.Designer.cs
generated
@ -136,12 +136,12 @@
|
|||||||
originMatShow = new PictureBox();
|
originMatShow = new PictureBox();
|
||||||
ResultMatShow = new PictureBox();
|
ResultMatShow = new PictureBox();
|
||||||
panel8 = new Panel();
|
panel8 = new Panel();
|
||||||
|
canvas6 = new XKRS.UI.Canvas();
|
||||||
|
canvas2 = new XKRS.UI.Canvas();
|
||||||
textBox2 = new TextBox();
|
textBox2 = new TextBox();
|
||||||
label36 = new Label();
|
label36 = new Label();
|
||||||
textBox1 = new TextBox();
|
textBox1 = new TextBox();
|
||||||
label35 = new Label();
|
label35 = new Label();
|
||||||
canvas6 = new XKRS.UI.Canvas();
|
|
||||||
canvas2 = new XKRS.UI.Canvas();
|
|
||||||
实时显示 = new Label();
|
实时显示 = new Label();
|
||||||
OKOrNGShow = new PictureBox();
|
OKOrNGShow = new PictureBox();
|
||||||
OKDNum = new TextBox();
|
OKDNum = new TextBox();
|
||||||
@ -1226,7 +1226,7 @@
|
|||||||
groupBox2.Margin = new Padding(4, 2, 4, 2);
|
groupBox2.Margin = new Padding(4, 2, 4, 2);
|
||||||
groupBox2.Name = "groupBox2";
|
groupBox2.Name = "groupBox2";
|
||||||
groupBox2.Padding = new Padding(4, 2, 4, 2);
|
groupBox2.Padding = new Padding(4, 2, 4, 2);
|
||||||
groupBox2.Size = new Size(1102, 718);
|
groupBox2.Size = new Size(1083, 718);
|
||||||
groupBox2.TabIndex = 0;
|
groupBox2.TabIndex = 0;
|
||||||
groupBox2.TabStop = false;
|
groupBox2.TabStop = false;
|
||||||
groupBox2.Text = "图片";
|
groupBox2.Text = "图片";
|
||||||
@ -1240,7 +1240,7 @@
|
|||||||
mat1.IsEnabledDispose = true;
|
mat1.IsEnabledDispose = true;
|
||||||
canvas5.ImaMAt = mat1;
|
canvas5.ImaMAt = mat1;
|
||||||
canvas5.ImgData = null;
|
canvas5.ImgData = null;
|
||||||
canvas5.Location = new Point(758, 464);
|
canvas5.Location = new Point(693, 440);
|
||||||
canvas5.MoveStep = 5F;
|
canvas5.MoveStep = 5F;
|
||||||
canvas5.Name = "canvas5";
|
canvas5.Name = "canvas5";
|
||||||
canvas5.Route = 0D;
|
canvas5.Route = 0D;
|
||||||
@ -1261,7 +1261,7 @@
|
|||||||
mat2.IsEnabledDispose = true;
|
mat2.IsEnabledDispose = true;
|
||||||
canvas4.ImaMAt = mat2;
|
canvas4.ImaMAt = mat2;
|
||||||
canvas4.ImgData = null;
|
canvas4.ImgData = null;
|
||||||
canvas4.Location = new Point(382, 464);
|
canvas4.Location = new Point(350, 440);
|
||||||
canvas4.MoveStep = 5F;
|
canvas4.MoveStep = 5F;
|
||||||
canvas4.Name = "canvas4";
|
canvas4.Name = "canvas4";
|
||||||
canvas4.Route = 0D;
|
canvas4.Route = 0D;
|
||||||
@ -1282,7 +1282,7 @@
|
|||||||
mat3.IsEnabledDispose = true;
|
mat3.IsEnabledDispose = true;
|
||||||
canvas3.ImaMAt = mat3;
|
canvas3.ImaMAt = mat3;
|
||||||
canvas3.ImgData = null;
|
canvas3.ImgData = null;
|
||||||
canvas3.Location = new Point(8, 464);
|
canvas3.Location = new Point(7, 440);
|
||||||
canvas3.MoveStep = 5F;
|
canvas3.MoveStep = 5F;
|
||||||
canvas3.Name = "canvas3";
|
canvas3.Name = "canvas3";
|
||||||
canvas3.Route = 0D;
|
canvas3.Route = 0D;
|
||||||
@ -1368,12 +1368,12 @@
|
|||||||
//
|
//
|
||||||
// panel8
|
// panel8
|
||||||
//
|
//
|
||||||
|
panel8.Controls.Add(canvas6);
|
||||||
|
panel8.Controls.Add(canvas2);
|
||||||
panel8.Controls.Add(textBox2);
|
panel8.Controls.Add(textBox2);
|
||||||
panel8.Controls.Add(label36);
|
panel8.Controls.Add(label36);
|
||||||
panel8.Controls.Add(textBox1);
|
panel8.Controls.Add(textBox1);
|
||||||
panel8.Controls.Add(label35);
|
panel8.Controls.Add(label35);
|
||||||
panel8.Controls.Add(canvas6);
|
|
||||||
panel8.Controls.Add(canvas2);
|
|
||||||
panel8.Controls.Add(实时显示);
|
panel8.Controls.Add(实时显示);
|
||||||
panel8.Controls.Add(OKOrNGShow);
|
panel8.Controls.Add(OKOrNGShow);
|
||||||
panel8.Controls.Add(OKDNum);
|
panel8.Controls.Add(OKDNum);
|
||||||
@ -1393,6 +1393,49 @@
|
|||||||
panel8.TabIndex = 2;
|
panel8.TabIndex = 2;
|
||||||
panel8.Paint += panel8_Paint;
|
panel8.Paint += panel8_Paint;
|
||||||
//
|
//
|
||||||
|
// canvas6
|
||||||
|
//
|
||||||
|
canvas6.AllowSelectDefect = true;
|
||||||
|
canvas6.BrushColor = null;
|
||||||
|
canvas6.ImagePath = "";
|
||||||
|
mat5.IsEnabledDispose = true;
|
||||||
|
canvas6.ImaMAt = mat5;
|
||||||
|
canvas6.ImgData = null;
|
||||||
|
canvas6.Location = new Point(10, 440);
|
||||||
|
canvas6.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
canvas6.MoveStep = 5F;
|
||||||
|
canvas6.Name = "canvas6";
|
||||||
|
canvas6.Route = 0D;
|
||||||
|
canvas6.Scale = 1D;
|
||||||
|
canvas6.Size = new Size(433, 188);
|
||||||
|
canvas6.TabIndex = 13;
|
||||||
|
canvas6.WholeScale = 0F;
|
||||||
|
canvas6.XMove = 0F;
|
||||||
|
canvas6.XScale = 0F;
|
||||||
|
canvas6.YMove = 0F;
|
||||||
|
canvas6.YScale = 0F;
|
||||||
|
//
|
||||||
|
// canvas2
|
||||||
|
//
|
||||||
|
canvas2.AllowSelectDefect = true;
|
||||||
|
canvas2.BrushColor = null;
|
||||||
|
canvas2.ImagePath = "";
|
||||||
|
mat6.IsEnabledDispose = true;
|
||||||
|
canvas2.ImaMAt = mat6;
|
||||||
|
canvas2.ImgData = null;
|
||||||
|
canvas2.Location = new Point(10, 226);
|
||||||
|
canvas2.MoveStep = 5F;
|
||||||
|
canvas2.Name = "canvas2";
|
||||||
|
canvas2.Route = 0D;
|
||||||
|
canvas2.Scale = 1D;
|
||||||
|
canvas2.Size = new Size(337, 200);
|
||||||
|
canvas2.TabIndex = 18;
|
||||||
|
canvas2.WholeScale = 0F;
|
||||||
|
canvas2.XMove = 0F;
|
||||||
|
canvas2.XScale = 0F;
|
||||||
|
canvas2.YMove = 0F;
|
||||||
|
canvas2.YScale = 0F;
|
||||||
|
//
|
||||||
// textBox2
|
// textBox2
|
||||||
//
|
//
|
||||||
textBox2.Location = new Point(437, 287);
|
textBox2.Location = new Point(437, 287);
|
||||||
@ -1429,49 +1472,6 @@
|
|||||||
label35.TabIndex = 14;
|
label35.TabIndex = 14;
|
||||||
label35.Text = "误检率";
|
label35.Text = "误检率";
|
||||||
//
|
//
|
||||||
// canvas6
|
|
||||||
//
|
|
||||||
canvas6.AllowSelectDefect = true;
|
|
||||||
canvas6.BrushColor = null;
|
|
||||||
canvas6.ImagePath = "";
|
|
||||||
mat5.IsEnabledDispose = true;
|
|
||||||
canvas6.ImaMAt = mat5;
|
|
||||||
canvas6.ImgData = null;
|
|
||||||
canvas6.Location = new Point(19, 454);
|
|
||||||
canvas6.MoveStep = 5F;
|
|
||||||
canvas6.Name = "canvas6";
|
|
||||||
canvas6.Route = 0D;
|
|
||||||
canvas6.Scale = 1D;
|
|
||||||
canvas6.Size = new Size(318, 200);
|
|
||||||
canvas6.TabIndex = 13;
|
|
||||||
canvas6.WholeScale = 0F;
|
|
||||||
canvas6.XMove = 0F;
|
|
||||||
canvas6.XScale = 0F;
|
|
||||||
canvas6.YMove = 0F;
|
|
||||||
canvas6.YScale = 0F;
|
|
||||||
//
|
|
||||||
// canvas2
|
|
||||||
//
|
|
||||||
canvas2.AllowSelectDefect = true;
|
|
||||||
canvas2.BrushColor = null;
|
|
||||||
canvas2.ImagePath = "";
|
|
||||||
mat6.IsEnabledDispose = true;
|
|
||||||
canvas2.ImaMAt = mat6;
|
|
||||||
canvas2.ImgData = null;
|
|
||||||
canvas2.Location = new Point(19, 238);
|
|
||||||
canvas2.Margin = new Padding(4, 3, 4, 3);
|
|
||||||
canvas2.MoveStep = 5F;
|
|
||||||
canvas2.Name = "canvas2";
|
|
||||||
canvas2.Route = 0D;
|
|
||||||
canvas2.Scale = 1D;
|
|
||||||
canvas2.Size = new Size(318, 188);
|
|
||||||
canvas2.TabIndex = 10;
|
|
||||||
canvas2.WholeScale = 0F;
|
|
||||||
canvas2.XMove = 0F;
|
|
||||||
canvas2.XScale = 0F;
|
|
||||||
canvas2.YMove = 0F;
|
|
||||||
canvas2.YScale = 0F;
|
|
||||||
//
|
|
||||||
// 实时显示
|
// 实时显示
|
||||||
//
|
//
|
||||||
实时显示.AutoSize = true;
|
实时显示.AutoSize = true;
|
||||||
@ -1562,10 +1562,10 @@
|
|||||||
//
|
//
|
||||||
// ScanDevList
|
// ScanDevList
|
||||||
//
|
//
|
||||||
ScanDevList.Location = new Point(297, 22);
|
ScanDevList.Location = new Point(296, 18);
|
||||||
ScanDevList.Margin = new Padding(4, 2, 4, 2);
|
ScanDevList.Margin = new Padding(4, 2, 4, 2);
|
||||||
ScanDevList.Name = "ScanDevList";
|
ScanDevList.Name = "ScanDevList";
|
||||||
ScanDevList.Size = new Size(96, 22);
|
ScanDevList.Size = new Size(96, 30);
|
||||||
ScanDevList.TabIndex = 2;
|
ScanDevList.TabIndex = 2;
|
||||||
ScanDevList.Text = "Scan";
|
ScanDevList.Text = "Scan";
|
||||||
ScanDevList.UseVisualStyleBackColor = true;
|
ScanDevList.UseVisualStyleBackColor = true;
|
||||||
@ -2211,15 +2211,21 @@
|
|||||||
private XKRS.UI.Canvas DefetShow7;
|
private XKRS.UI.Canvas DefetShow7;
|
||||||
private XKRS.UI.Canvas DefetShow6;
|
private XKRS.UI.Canvas DefetShow6;
|
||||||
private Button handStopBtn;
|
private Button handStopBtn;
|
||||||
private XKRS.UI.Canvas canvas1;
|
//private XKRS.UI.Canvas canvas1;
|
||||||
private XKRS.UI.Canvas canvas5;
|
//private XKRS.UI.Canvas canvas5;
|
||||||
private XKRS.UI.Canvas canvas4;
|
//private XKRS.UI.Canvas canvas4;
|
||||||
private XKRS.UI.Canvas canvas3;
|
//private XKRS.UI.Canvas canvas3;
|
||||||
private XKRS.UI.Canvas canvas6;
|
//private XKRS.UI.Canvas canvas6;
|
||||||
private XKRS.UI.Canvas canvas2;
|
//private XKRS.UI.Canvas canvas2;
|
||||||
private TextBox textBox1;
|
private TextBox textBox1;
|
||||||
private Label label35;
|
private Label label35;
|
||||||
private TextBox textBox2;
|
private TextBox textBox2;
|
||||||
private Label label36;
|
private Label label36;
|
||||||
|
private XKRS.UI.Canvas canvas5;
|
||||||
|
private XKRS.UI.Canvas canvas4;
|
||||||
|
private XKRS.UI.Canvas canvas3;
|
||||||
|
private XKRS.UI.Canvas canvas1;
|
||||||
|
private XKRS.UI.Canvas canvas6;
|
||||||
|
private XKRS.UI.Canvas canvas2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DVPCameraType;
|
using DVPCameraType;
|
||||||
using Microsoft.VisualBasic.Logging;
|
using Microsoft.VisualBasic.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using OpenCvSharp.Dnn;
|
using OpenCvSharp.Dnn;
|
||||||
@ -191,6 +192,143 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// GET方式发送得结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">请求的url</param>
|
||||||
|
/// <returns>服务器响应的数据</returns>
|
||||||
|
public static string getHttpRequest(string url)
|
||||||
|
{
|
||||||
|
//预备请求的资源
|
||||||
|
HttpWebRequest request = null;
|
||||||
|
HttpWebResponse response = null;
|
||||||
|
StreamReader reader = null;
|
||||||
|
|
||||||
|
string content = string.Empty;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
request.Method = "GET";
|
||||||
|
|
||||||
|
response = (HttpWebResponse)request.GetResponse();
|
||||||
|
using (reader = new StreamReader(response.GetResponseStream()))
|
||||||
|
{
|
||||||
|
content = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception err)
|
||||||
|
{
|
||||||
|
MessageBox.Show("1.GET出现了错误!\n错误来源:" + err.Source + "\n错误信息:" + err.Message + "\n" + err);
|
||||||
|
Console.WriteLine("1.GET出现了错误!\n错误来源:" + err.Source + "错误信息:" + err.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
//用完销毁
|
||||||
|
response.Dispose();
|
||||||
|
reader.Dispose();
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发起一个http请求,方式为POST
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">发送请求的目标url</param>
|
||||||
|
/// <param name="reMsg">要发送的消息</param>
|
||||||
|
/// <returns>服务器响应的数据</returns>
|
||||||
|
public string postHttpRequest(string uri, string msg)
|
||||||
|
{
|
||||||
|
//预备请求的资源
|
||||||
|
HttpWebRequest request = null;
|
||||||
|
HttpWebResponse response = null;
|
||||||
|
Stream requestStream = null;
|
||||||
|
StreamReader reader = null;
|
||||||
|
|
||||||
|
var data = Encoding.UTF8.GetBytes(string.Format("a={0}&b={1}", "message", msg));
|
||||||
|
string content = "";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request = (HttpWebRequest)WebRequest.Create(uri);
|
||||||
|
request.Method = "POST";
|
||||||
|
requestStream = request.GetRequestStream();
|
||||||
|
|
||||||
|
request.ContentType = "application/text";
|
||||||
|
|
||||||
|
requestStream.Write(data, 0, data.Length);
|
||||||
|
response = (HttpWebResponse)request.GetResponse();
|
||||||
|
|
||||||
|
using (reader = new StreamReader(response.GetResponseStream()))
|
||||||
|
{
|
||||||
|
content = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
MessageBox.Show("1.POST出现了错误!\n错误来源:" + err.Source + "\n错误信息:" + err.Message + "\n" + err);
|
||||||
|
Console.WriteLine("1.POST出现了错误!\n错误来源:" + err.Source + "错误信息:" + err.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
//资源用完回收
|
||||||
|
requestStream.Dispose();
|
||||||
|
response.Dispose();
|
||||||
|
reader.Dispose();
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Post请求
|
||||||
|
/// <summary>
|
||||||
|
/// http Post请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parameterData">参数</param>
|
||||||
|
/// <param name="serviceUrl">访问地址</param>
|
||||||
|
/// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
|
||||||
|
/// <param name="Accept">默认application/json</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Post(string parameterData, string serviceUrl, string ContentType = "application/json", string Accept = "application/json")
|
||||||
|
{
|
||||||
|
//先根据用户请求的uri构造请求地址
|
||||||
|
//string serviceUrl = string.Format("{0}/{1}", this.BaseUri, uri);
|
||||||
|
|
||||||
|
//创建Web访问对象
|
||||||
|
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
||||||
|
//把用户传过来的数据转成“UTF-8”的字节流
|
||||||
|
byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(parameterData);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主窗口
|
/// 主窗口
|
||||||
@ -200,9 +338,38 @@ namespace HisenceYoloDetection
|
|||||||
private void MainForm_Load(object sender, EventArgs e)
|
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;
|
||||||
|
|
||||||
|
string starttime=string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
|
||||||
|
|
||||||
|
string startTime = starttime;
|
||||||
|
string EndTime = starttime;
|
||||||
|
string lineBody = "ZZ-P5";
|
||||||
|
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)
|
if (_runHandleBefore == null)
|
||||||
{
|
{
|
||||||
_runHandleBefore = new AutoResetEvent(false);
|
_runHandleBefore = new AutoResetEvent(false);
|
||||||
@ -413,6 +580,7 @@ namespace HisenceYoloDetection
|
|||||||
AllDSum.Text = AllDsums.ToString();
|
AllDSum.Text = AllDsums.ToString();
|
||||||
OKDNum.Text = OKDsums.ToString();
|
OKDNum.Text = OKDsums.ToString();
|
||||||
NGDNum.Text = NGDsums.ToString();
|
NGDNum.Text = NGDsums.ToString();
|
||||||
|
textBox1.Text = WUsums.ToString();
|
||||||
using (StreamWriter stream = new StreamWriter("D://information.log", true))
|
using (StreamWriter stream = new StreamWriter("D://information.log", true))
|
||||||
{
|
{
|
||||||
stream.WriteLine(Logtxt);
|
stream.WriteLine(Logtxt);
|
||||||
@ -610,11 +778,11 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
OKOrNGShow.Image = OKbitmap;
|
OKOrNGShow.Image = OKbitmap;
|
||||||
//初始化扫码枪
|
//初始化扫码枪
|
||||||
//Scanner.Strart();
|
Scanner.Strart();
|
||||||
//Scanner.OnClientDataReceived -= OnDataReceived;
|
Scanner.OnClientDataReceived -= OnDataReceived;
|
||||||
//Scanner.OnClientDataReceived += OnDataReceived;
|
Scanner.OnClientDataReceived += OnDataReceived;
|
||||||
//Scanner.btnSendMsg("LON\r");//发送开启指令
|
Scanner.btnSendMsg("LON\r");//发送开启指令
|
||||||
//myLog("发送恩士扫码枪开启指令", DateTime.Now);
|
myLog("发送恩士扫码枪开启指令", DateTime.Now);
|
||||||
|
|
||||||
//PLC使能开启
|
//PLC使能开启
|
||||||
melsecPLCTCPDriver.WriteInt("581", 0);//定位松开
|
melsecPLCTCPDriver.WriteInt("581", 0);//定位松开
|
||||||
@ -1010,14 +1178,18 @@ namespace HisenceYoloDetection
|
|||||||
if (bBar)
|
if (bBar)
|
||||||
{
|
{
|
||||||
_runHandleBefore.WaitOne();
|
_runHandleBefore.WaitOne();
|
||||||
bBarTriger = true;//修改成相机拍照获取型号
|
//这里改成和海信的对接需求
|
||||||
|
|
||||||
|
//xKNow = GetModeFromBar("VWJ070633V0WW80F0120356");//从数据库中查询到这个条码的四轴的值
|
||||||
xKNow = GetModeFromBar("VWJ070633V0WW80F0120356");//从数据库中查询到这个条码的四轴的值
|
xKNow = GetModeFromBar(m_sKEYENCEBar);//从数据库中查询到这个条码的四轴的值
|
||||||
//xKNow = GetModeFromBar(m_sKEYENCEBar);//从数据库中查询到这个条码的四轴的值
|
if(xKNow==null)
|
||||||
|
{
|
||||||
|
myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now);
|
||||||
|
break;
|
||||||
|
}
|
||||||
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]+$"))
|
||||||
{
|
{
|
||||||
myLog("型号匹配成功" + m_sKEYENCEBar, DateTime.Now);
|
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
|
||||||
bBarTriger = true;
|
bBarTriger = true;
|
||||||
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
|
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
|
||||||
}
|
}
|
||||||
@ -1116,10 +1288,12 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
if (iNum1 >= 2)
|
if (iNum1 >= 2)
|
||||||
{
|
{
|
||||||
//if (bBarTriger)
|
#if false
|
||||||
|
|
||||||
|
if (bBarTriger)//证明读码器读到东西
|
||||||
{
|
{
|
||||||
|
|
||||||
#if false
|
|
||||||
if (!StopM)
|
if (!StopM)
|
||||||
{
|
{
|
||||||
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
|
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
|
||||||
@ -1183,6 +1357,7 @@ namespace HisenceYoloDetection
|
|||||||
iNum0 = 0;
|
iNum0 = 0;
|
||||||
iNum1 = 0;
|
iNum1 = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
myLog("第一次采集图像", DateTime.Now);
|
myLog("第一次采集图像", DateTime.Now);
|
||||||
//移动模组 读三次测距的地址 看是否往前移动
|
//移动模组 读三次测距的地址 看是否往前移动
|
||||||
@ -1242,7 +1417,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1370,34 +1545,42 @@ 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;
|
||||||
//req.currentMat = Cv2.ImRead("D:\\Hisence\\类型\\1\\bar.jpg");
|
////req.currentMat = Cv2.ImRead("D:\\Hisence\\类型\\1\\bar.jpg");
|
||||||
|
|
||||||
//相机识别的字符串
|
////相机识别的字符串
|
||||||
string IOcrBAr = DetMachineBar(ref req);
|
//string IOcrBAr = DetMachineBar(ref req);
|
||||||
DateTime dt = DateTime.Now;
|
//DateTime dt = DateTime.Now;
|
||||||
using (StreamWriter sw = new StreamWriter("D://Hisence//logsBar.log", true))
|
//using (StreamWriter sw = new StreamWriter("D://Hisence//logsBar.log", true))
|
||||||
{
|
//{
|
||||||
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
// string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
||||||
sw.WriteLine(filename + "\n");
|
// sw.WriteLine(filename + "\n");
|
||||||
sw.WriteLine(IOcrBAr + "\n");
|
// sw.WriteLine(IOcrBAr + "\n");
|
||||||
sw.Flush();
|
// sw.Flush();
|
||||||
}
|
//}
|
||||||
// IOcrBAr = "BatchW9659ModelWNHPI74SCPSDE";
|
// IOcrBAr = "BatchW9659ModelWNHPI74SCPSDE";
|
||||||
IOcrBAr = "W821PWMS27106WD2";
|
// IOcrBAr = "W821PWMS27106WD2";
|
||||||
|
// IOcrBAr=
|
||||||
//根据条码数据库比对
|
//根据条码数据库比对
|
||||||
xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
string IOcrBAr = xKNow.OcrBar;
|
||||||
|
//xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
||||||
|
//这里改成和海信的对接需求
|
||||||
|
|
||||||
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
||||||
if (xkWordList.Count() == 1)
|
if (xkWordList.Count() == 1)
|
||||||
{
|
{
|
||||||
xK_HisenceSQLWord = xkWordList[0];
|
xK_HisenceSQLWord = xkWordList[0];
|
||||||
}
|
}
|
||||||
|
if(xKNow==null)
|
||||||
|
{
|
||||||
|
myLog("未匹配条码" + IOcrBAr, DateTime.Now);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (xKNow.OcrBar == null)
|
if (xKNow.OcrBar == null)
|
||||||
{
|
{
|
||||||
@ -1423,7 +1606,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
//}
|
//}
|
||||||
myLog("型号匹配成功" + IOcrBAr, DateTime.Now);
|
myLog("型号匹配成功" + IOcrBAr, DateTime.Now);
|
||||||
bBarTriger = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1437,7 +1620,7 @@ namespace HisenceYoloDetection
|
|||||||
// if (IfCam1TwoTriger && bBarTriger)
|
// if (IfCam1TwoTriger && bBarTriger)
|
||||||
{
|
{
|
||||||
IfCam1TwoTriger = false;
|
IfCam1TwoTriger = false;
|
||||||
bBarTriger = false;
|
bBarTriger = false;//可能没什么用了
|
||||||
_runHandleAfter.Reset();
|
_runHandleAfter.Reset();
|
||||||
//初始化板
|
//初始化板
|
||||||
Defet_OnDetectionDone(whiteMat, 1);
|
Defet_OnDetectionDone(whiteMat, 1);
|
||||||
@ -1582,7 +1765,7 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//红灯
|
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//红灯
|
||||||
melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//报警
|
melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//报警
|
||||||
myLog("匹配失败", DateTime.Now);
|
|
||||||
//加上人为判断是否是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)
|
||||||
@ -1598,7 +1781,7 @@ namespace HisenceYoloDetection
|
|||||||
textBox1.Text = percentText;
|
textBox1.Text = percentText;
|
||||||
OKOrNGShow.Image = OKbitmap;
|
OKOrNGShow.Image = OKbitmap;
|
||||||
}));
|
}));
|
||||||
|
myLog("匹配失败", DateTime.Now);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1610,6 +1793,7 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
OKOrNGShow.Image = NGbitmap;
|
OKOrNGShow.Image = NGbitmap;
|
||||||
}));
|
}));
|
||||||
|
myLog("匹配成功", DateTime.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1699,6 +1883,7 @@ namespace HisenceYoloDetection
|
|||||||
//
|
//
|
||||||
if (data.Length > 10)
|
if (data.Length > 10)
|
||||||
{
|
{
|
||||||
|
m_sKEYENCEBar=string.Empty;
|
||||||
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
|
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
|
||||||
// myLog("型号Ocr" + m_sKEYENCEBar, DateTime.Now);
|
// myLog("型号Ocr" + m_sKEYENCEBar, DateTime.Now);
|
||||||
_runHandleBefore.Set();
|
_runHandleBefore.Set();
|
||||||
@ -1899,7 +2084,7 @@ namespace HisenceYoloDetection
|
|||||||
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
|
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
|
||||||
|
|
||||||
*/
|
*/
|
||||||
//OnGetBar();
|
OnGetBar();
|
||||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//黄灯
|
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//黄灯
|
||||||
TriggerCameral2();
|
TriggerCameral2();
|
||||||
ReadyDetect();
|
ReadyDetect();
|
||||||
@ -3141,7 +3326,7 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
SQLStr = SQlxK_HisenceWord.SixblockMainWord;
|
SQLStr = SQlxK_HisenceWord.SixblockMainWord;
|
||||||
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
|
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
|
||||||
|
OneIF1 = false;//测试
|
||||||
Rect rect = new Rect(0, 0, 0, 0);
|
Rect rect = new Rect(0, 0, 0, 0);
|
||||||
string PathSql = SQlxK_HisenceWord.SixblockPath;
|
string PathSql = SQlxK_HisenceWord.SixblockPath;
|
||||||
//第六块卷积设置一直为true
|
//第六块卷积设置一直为true
|
||||||
@ -3173,6 +3358,7 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
|
SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
|
||||||
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
|
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
|
||||||
|
|
||||||
Rect rect = new Rect(0, 0, 0, 0);
|
Rect rect = new Rect(0, 0, 0, 0);
|
||||||
string PathSql = SQlxK_HisenceWord.SevenblockPath;
|
string PathSql = SQlxK_HisenceWord.SevenblockPath;
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ namespace HisenceYoloDetection
|
|||||||
public void Strart()
|
public void Strart()
|
||||||
{
|
{
|
||||||
client = new TcpClient();
|
client = new TcpClient();
|
||||||
client.Host = "192.168.3.100";
|
// client.Host = "192.168.3.100";
|
||||||
client.Port= 9004;
|
// client.Port= 9004;
|
||||||
//client.Host = "127.0.0.1";
|
client.Host = "127.0.0.1";
|
||||||
//client.Port = 9000;
|
client.Port = 9000;
|
||||||
client.Connect();
|
client.Connect();
|
||||||
|
|
||||||
client.OnDataReceived += Client_OnDataReceived;
|
client.OnDataReceived += Client_OnDataReceived;
|
||||||
|
@ -5,8 +5,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<BaseOutputPath>.\bin\X64\Debug</BaseOutputPath>
|
<!--<BaseOutputPath>.\bin\X64\Debug</BaseOutputPath>-->
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
|
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<Optimize>False</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user