diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/1f77c647-ee08-4001-9a36-e7c45492a0af.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/1f77c647-ee08-4001-9a36-e7c45492a0af.vsidx
deleted file mode 100644
index e265543..0000000
Binary files a/LeatherProject/.vs/LeatherApp/FileContentIndex/1f77c647-ee08-4001-9a36-e7c45492a0af.vsidx and /dev/null differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/2865db31-fea4-4e65-8e2e-c78b5d7e8f8f.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/2865db31-fea4-4e65-8e2e-c78b5d7e8f8f.vsidx
new file mode 100644
index 0000000..d4c0e5b
Binary files /dev/null and b/LeatherProject/.vs/LeatherApp/FileContentIndex/2865db31-fea4-4e65-8e2e-c78b5d7e8f8f.vsidx differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/2eaf4d9d-4bd8-4252-b924-61dcb944494c.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/2eaf4d9d-4bd8-4252-b924-61dcb944494c.vsidx
deleted file mode 100644
index 2974237..0000000
Binary files a/LeatherProject/.vs/LeatherApp/FileContentIndex/2eaf4d9d-4bd8-4252-b924-61dcb944494c.vsidx and /dev/null differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/334983ad-2e9a-45e3-8e27-e10cb1641111.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/334983ad-2e9a-45e3-8e27-e10cb1641111.vsidx
deleted file mode 100644
index cf2deb1..0000000
Binary files a/LeatherProject/.vs/LeatherApp/FileContentIndex/334983ad-2e9a-45e3-8e27-e10cb1641111.vsidx and /dev/null differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/51b1d98f-624a-4632-86a3-0e1aed712bd5.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/51b1d98f-624a-4632-86a3-0e1aed712bd5.vsidx
new file mode 100644
index 0000000..062673f
Binary files /dev/null and b/LeatherProject/.vs/LeatherApp/FileContentIndex/51b1d98f-624a-4632-86a3-0e1aed712bd5.vsidx differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/5cfb1fc0-c3ef-401d-a9b2-0bba4af3b6a3.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/5cfb1fc0-c3ef-401d-a9b2-0bba4af3b6a3.vsidx
new file mode 100644
index 0000000..c2f20bb
Binary files /dev/null and b/LeatherProject/.vs/LeatherApp/FileContentIndex/5cfb1fc0-c3ef-401d-a9b2-0bba4af3b6a3.vsidx differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/6b0d4daa-4cdd-497d-b720-53918bd7c3b6.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/6b0d4daa-4cdd-497d-b720-53918bd7c3b6.vsidx
new file mode 100644
index 0000000..ad9c12f
Binary files /dev/null and b/LeatherProject/.vs/LeatherApp/FileContentIndex/6b0d4daa-4cdd-497d-b720-53918bd7c3b6.vsidx differ
diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/fd572fcf-5d30-4ba2-8bb8-7b47269abcc3.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/fd572fcf-5d30-4ba2-8bb8-7b47269abcc3.vsidx
deleted file mode 100644
index e60a8a4..0000000
Binary files a/LeatherProject/.vs/LeatherApp/FileContentIndex/fd572fcf-5d30-4ba2-8bb8-7b47269abcc3.vsidx and /dev/null differ
diff --git a/LeatherProject/GeBoShi/GeBoShi.csproj b/LeatherProject/GeBoShi/GeBoShi.csproj
index 864a51f..60762d0 100644
--- a/LeatherProject/GeBoShi/GeBoShi.csproj
+++ b/LeatherProject/GeBoShi/GeBoShi.csproj
@@ -22,6 +22,7 @@
DEBUG;TRACE
prompt
4
+ true
AnyCPU
@@ -33,8 +34,7 @@
4
-
-
+ Ge.ico
@@ -43,6 +43,7 @@
..\..\..\..\..\..\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\CSkin.dll
+
..\..\..\..\..\版博士\源码\V2.0\halftoneproject-master\BanBoShi\Dlls\HZH_Controls.dll
@@ -53,12 +54,14 @@
False
..\Models\bin\Debug\Models.dll
+
..\packages\OpenCvSharp4.4.8.0.20230708\lib\net48\OpenCvSharp.dll
..\packages\OpenCvSharp4.Extensions.4.7.0.20230115\lib\net48\OpenCvSharp.Extensions.dll
+
..\Service\bin\Debug\Service.dll
@@ -112,8 +115,10 @@
+
+
Form
@@ -181,5 +186,8 @@
+
+
+
\ No newline at end of file
diff --git a/LeatherProject/GeBoShi/ImageDefect/DefectLib.cs b/LeatherProject/GeBoShi/ImageDefect/DefectLib.cs
index b587514..bf235db 100644
--- a/LeatherProject/GeBoShi/ImageDefect/DefectLib.cs
+++ b/LeatherProject/GeBoShi/ImageDefect/DefectLib.cs
@@ -1,7 +1,10 @@
-using HZH_Controls.Controls;
+using CCWin.Win32.Const;
+using GeBoShi.SysCtrl;
+using HZH_Controls.Controls;
using MaiMuControl.Device;
using Models;
using OpenCvSharp;
+using S7.Net.Types;
using System;
using System.Collections.Generic;
using System.Data;
@@ -180,6 +183,22 @@ namespace GeBoShi.ImageDefect
return array;
}
+ public static string ToGB2312(int codepage, string str)
+ {
+ try
+ {
+ Encoding cp850 = Encoding.GetEncoding(codepage);
+ Encoding gb2312 = Encoding.GetEncoding("gb2312");//Encoding.Default ,936
+ byte[] temp = cp850.GetBytes(str);
+ return Encoding.GetEncoding("gb2312").GetString(temp, 0, temp.Length);
+ }
+ catch (Exception ex)//(UnsupportedEncodingException ex)
+ {
+ Console.Write(ex.Message);
+ return null;
+ }
+ }
+
private void runStep()
{
int step = 0;
@@ -211,9 +230,11 @@ namespace GeBoShi.ImageDefect
detector = IntPtr.Zero;
}
step = 5;
- detector = CreateDetector($"./models/{task.modelName}");
+ string modelPath = $"{ConfMgr.Instance.SysConfigParams.AIModelPath}\\{task.modelName}";
+
+ detector = CreateDetector(modelPath);
if (detector == IntPtr.Zero)
- throw new Exception($"模型({task.modelName})初始化失败!");
+ throw new Exception($"模型({modelPath})初始化失败!");
step = 6;
preModelName = task.modelName;
}
@@ -379,8 +400,8 @@ namespace GeBoShi.ImageDefect
//y = image_hight-y-h;//转到右下角为原点
count++;
- var cmW = Math.Round(w * task.widthRatio / task.cm2px_x, 2);
- var cmH = Math.Round(h * task.widthRatio / task.cm2px_y, 2);
+ //var cmW = Math.Round(w * task.widthRatio / task.cm2px_x, 2);
+ //var cmH = Math.Round(h * task.widthRatio / task.cm2px_y, 2);
// 打印输出信息
task.resultInfo += $"----{i}----col:{i % colNum}/{colNum} row:{i / colNum}/{colNum}-----------\n目标:{j + 1} 类别ID:{classId} 置信度:{confidence} 对比度:{contrast} 坐标:({x},{y})-({x + w},{y + h}) 宽高:w={w},h={h}; \n";
@@ -403,6 +424,12 @@ namespace GeBoShi.ImageDefect
#endregion
}
+ #region 合并接头横档
+ if(DefectLabelInfoList.Count >0)
+ DefectLabelInfoList = HeBingDefect(task.bmp.Width, "jietou", DefectLabelInfoList);
+ if (DefectLabelInfoList.Count > 0)
+ DefectLabelInfoList = HeBingDefect(task.bmp.Width, "hengdang", DefectLabelInfoList);
+ #endregion
//结果过滤
#region 结果过滤
//降序排序,先得到是否有接头检出
@@ -465,12 +492,14 @@ namespace GeBoShi.ImageDefect
liStep++;//2
task.resultInfo += $" 转换到大图坐标(px):p1={point1.X},{point1.Y}; p2={point2.X},{point2.Y}\n";
Cv2.Rectangle(task.bmpTag, point1, point2, new Scalar(0.0, 0.0, 255.0), 1);//画打标点
- //WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"保存第 {count} 行缺陷信息;");
- var cmX = Math.Round(point1.X * task.widthRatio / task.cm2px_x, 2);
+
+ //WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"保存第 {count} 行缺陷信息;");
+ int px = (point1.X - task.xw) > 0 ? (point1.X - task.xw) : 0;
+ var cmX = Math.Round(px * task.widthRatio / task.cm2px_x, 2);
var cmY = Math.Round((task.bmp.Height - point1.Y - DefectLabelInfoList[q].h) * task.widthRatio / task.cm2px_y, 2);//外面计Y从右下角为原点
liStep++;//3
task.resultInfo += $" 转换到大图坐标(cm)[widthRatio={task.widthRatio}]:x={cmX},y={cmY}; w={DefectLabelInfoList[q].cmW},h={DefectLabelInfoList[q].cmH}\n";
- task.excelTable.Rows.Add($"{task.photoIndex}", cmX, cmY, DefectLabelInfoList[q].cmW, DefectLabelInfoList[q].cmH, DefectLabelInfoList[q].j + 1, DefectLabelInfoList[q].classId, DefectLabelInfoList[q].confidence, DefectLabelInfoList[q].contrast);
+ task.excelTable.Rows.Add($"{task.photoIndex}", cmX, cmY, DefectLabelInfoList[q].cmW, DefectLabelInfoList[q].cmH, DefectLabelInfoList[q].j + 1, DefectLabelInfoList[q].classId, DefectLabelInfoList[q].confidence, Utils.ContrastToPercent(DefectLabelInfoList[q].contrast));
liStep++;//4
//切缺陷小图
@@ -522,6 +551,73 @@ namespace GeBoShi.ImageDefect
}
}
+ #region 词条合并
+ private List HeBingDefect(int Width, string label, List DefectLabelInfoList)
+ {
+ int fw = 500;
+ List outList = new List();
+
+ List HeBingList = new List();
+ List XcHeBingList = new List();
+ List xPos = new List();
+ List xZXD = new List();
+
+ DefectLabelInfo stpoint = DefectLabelInfoList[0];
+
+ int colNum = Width / image_width;
+ //寻找在一条线上
+ for (int q = 0; q < DefectLabelInfoList.Count; q++)
+ {
+ if (SysMgr.Instance.GetDefectCode()[DefectLabelInfoList[q].classId] == label)
+ {
+ int max = stpoint.y + fw;
+ int min = stpoint.y - fw > 0 ? stpoint.y - fw : 0;
+ if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max)
+ {
+ HeBingList.Add(DefectLabelInfoList[q]);
+ xPos.Add(DefectLabelInfoList[q].x);
+ xZXD.Add(DefectLabelInfoList[q].confidence);
+ }
+ else
+ XcHeBingList.Add(DefectLabelInfoList[q]);
+ }
+ else
+ outList.Add(DefectLabelInfoList[q]);
+ }
+ //递归下次合并数据
+ List dg1 = new List();
+ if (XcHeBingList.Count > 0)
+ dg1 = HeBingDefect(Width, label, XcHeBingList);
+
+
+ //多个jietou合并
+ if (HeBingList.Count > 0)
+ {
+ var stIt = HeBingList.Find(x => x.x == xPos.Min());
+ var edIt = HeBingList.Find(x => x.x == xPos.Max());
+ var eZXD = HeBingList.Find(x => x.confidence == xZXD.Max());
+ int newW = Math.Abs((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x) + edIt.w;
+ outList.Add(new DefectLabelInfo()
+ {
+ x = stIt.x,
+ y = edIt.y,
+ w = newW, //多图叠加
+ h = edIt.h,
+ classId = eZXD.classId,
+ confidence = eZXD.confidence,
+ contrast = eZXD.contrast,
+ cmH = Math.Round(edIt.h * 1.0 / ConfMgr.Instance.SysConfigParams.Cm2px_y, 2),
+ cmW = Math.Round(newW * 1.0 / ConfMgr.Instance.SysConfigParams.Cm2px_x, 2),
+ i = stIt.i,
+ j = stIt.j,
+ });
+ }
+
+ outList = outList.Concat(dg1).ToList();//保留重复项
+ return outList;
+ }
+ #endregion
+
#region 结果回调
private void callback(DefectTask task)
{
@@ -693,5 +789,10 @@ namespace GeBoShi.ImageDefect
///
public DataTable excelTable = new DataTable();
public long[] stopwatch = new long[4];
+
+ ///
+ /// 等比例填充的宽度
+ ///
+ public int xw;
}
}
diff --git a/LeatherProject/GeBoShi/Main.Designer.cs b/LeatherProject/GeBoShi/Main.Designer.cs
index 3c3ab2f..298860f 100644
--- a/LeatherProject/GeBoShi/Main.Designer.cs
+++ b/LeatherProject/GeBoShi/Main.Designer.cs
@@ -30,17 +30,17 @@
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
- System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.tsbtnImpStop = new System.Windows.Forms.ToolStripButton();
@@ -120,15 +120,27 @@
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel4 = new System.Windows.Forms.Panel();
this.skinDataGridView1 = new CCWin.SkinControl.SkinDataGridView();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tsAxisState = new System.Windows.Forms.ToolStripStatusLabel();
this.tsslLoginTime = new System.Windows.Forms.ToolStripStatusLabel();
this.tsslLoginInfo = new System.Windows.Forms.ToolStripStatusLabel();
this.tslabelTime = new System.Windows.Forms.ToolStripStatusLabel();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
+ this.colUid = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colIndex = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colDefectName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colX = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colY = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colW = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colH = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colArea = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colZXD = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.colTarget = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.uiTitel1 = new MaiMuControl.UIKits.MaiMuMenu.UITitel();
+ this.lblDefectSpeed = new System.Windows.Forms.Label();
+ this.lblDefectLen = new System.Windows.Forms.Label();
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -214,6 +226,7 @@
this.tsbtnImpStop.Size = new System.Drawing.Size(60, 53);
this.tsbtnImpStop.Text = "结束验布";
this.tsbtnImpStop.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbtnImpStop.Click += new System.EventHandler(this.tsbtnImpStop_Click);
//
// tsbtnStart
//
@@ -225,6 +238,7 @@
this.tsbtnStart.Size = new System.Drawing.Size(60, 53);
this.tsbtnStart.Text = "开始验布";
this.tsbtnStart.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbtnStart.Click += new System.EventHandler(this.tsbtnStart_Click);
//
// tsbtnStop
//
@@ -236,6 +250,7 @@
this.tsbtnStop.Size = new System.Drawing.Size(52, 53);
this.tsbtnStop.Text = " 暂停 ";
this.tsbtnStop.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbtnStop.Click += new System.EventHandler(this.tsbtnStop_Click);
//
// toolStripSeparator2
//
@@ -252,6 +267,7 @@
this.tsbtnWarning.Size = new System.Drawing.Size(60, 53);
this.tsbtnWarning.Text = "解除报警";
this.tsbtnWarning.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbtnWarning.Click += new System.EventHandler(this.tsbtnWarning_Click);
//
// toolStripSeparator3
//
@@ -268,6 +284,8 @@
this.tsbtnReset.Size = new System.Drawing.Size(52, 53);
this.tsbtnReset.Text = " 复位 ";
this.tsbtnReset.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbtnReset.Visible = false;
+ this.tsbtnReset.Click += new System.EventHandler(this.tsbtnReset_Click);
//
// tsbGoHome
//
@@ -279,6 +297,7 @@
this.tsbGoHome.Size = new System.Drawing.Size(60, 53);
this.tsbGoHome.Text = "硬件重启";
this.tsbGoHome.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
+ this.tsbGoHome.Click += new System.EventHandler(this.tsbGoHome_Click);
//
// menuStrip1
//
@@ -314,20 +333,20 @@
this.tsmPdtMgr.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tsmPdtMgr.Image = ((System.Drawing.Image)(resources.GetObject("tsmPdtMgr.Image")));
this.tsmPdtMgr.Name = "tsmPdtMgr";
- this.tsmPdtMgr.Size = new System.Drawing.Size(124, 22);
+ this.tsmPdtMgr.Size = new System.Drawing.Size(180, 22);
this.tsmPdtMgr.Text = "检测管理";
this.tsmPdtMgr.Click += new System.EventHandler(this.tsmPdtMgr_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(121, 6);
+ this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("退出ToolStripMenuItem.Image")));
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
- this.退出ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
+ this.退出ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.退出ToolStripMenuItem.Text = "退出";
this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
//
@@ -393,21 +412,22 @@
//
this.tsmSysSet.Image = ((System.Drawing.Image)(resources.GetObject("tsmSysSet.Image")));
this.tsmSysSet.Name = "tsmSysSet";
- this.tsmSysSet.Size = new System.Drawing.Size(124, 22);
+ this.tsmSysSet.Size = new System.Drawing.Size(180, 22);
this.tsmSysSet.Text = "系统设置";
this.tsmSysSet.Click += new System.EventHandler(this.tsmSysSet_Click);
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
- this.toolStripSeparator5.Size = new System.Drawing.Size(121, 6);
+ this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
//
// tsmDebug
//
this.tsmDebug.Image = ((System.Drawing.Image)(resources.GetObject("tsmDebug.Image")));
this.tsmDebug.Name = "tsmDebug";
- this.tsmDebug.Size = new System.Drawing.Size(124, 22);
+ this.tsmDebug.Size = new System.Drawing.Size(180, 22);
this.tsmDebug.Text = "调试";
+ this.tsmDebug.Click += new System.EventHandler(this.tsmDebug_Click);
//
// tsmHelp
//
@@ -428,32 +448,32 @@
//
this.tsmReadLog.Image = ((System.Drawing.Image)(resources.GetObject("tsmReadLog.Image")));
this.tsmReadLog.Name = "tsmReadLog";
- this.tsmReadLog.Size = new System.Drawing.Size(148, 22);
+ this.tsmReadLog.Size = new System.Drawing.Size(180, 22);
this.tsmReadLog.Text = "日志查询";
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
- this.toolStripSeparator6.Size = new System.Drawing.Size(145, 6);
+ this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
//
// tsmHelpInfo
//
this.tsmHelpInfo.Image = ((System.Drawing.Image)(resources.GetObject("tsmHelpInfo.Image")));
this.tsmHelpInfo.Name = "tsmHelpInfo";
- this.tsmHelpInfo.Size = new System.Drawing.Size(148, 22);
+ this.tsmHelpInfo.Size = new System.Drawing.Size(180, 22);
this.tsmHelpInfo.Text = "帮助";
//
// tsmInfoUS
//
this.tsmInfoUS.Image = ((System.Drawing.Image)(resources.GetObject("tsmInfoUS.Image")));
this.tsmInfoUS.Name = "tsmInfoUS";
- this.tsmInfoUS.Size = new System.Drawing.Size(148, 22);
+ this.tsmInfoUS.Size = new System.Drawing.Size(180, 22);
this.tsmInfoUS.Text = "关于";
//
// tsmSoftFile
//
this.tsmSoftFile.Name = "tsmSoftFile";
- this.tsmSoftFile.Size = new System.Drawing.Size(148, 22);
+ this.tsmSoftFile.Size = new System.Drawing.Size(180, 22);
this.tsmSoftFile.Text = "软件使用说明";
//
// splitContainer1
@@ -485,9 +505,9 @@
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
- this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 244F));
- this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 120F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 251F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 144F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(381, 496);
this.tableLayoutPanel1.TabIndex = 0;
//
@@ -502,7 +522,7 @@
this.gpbProductInfo.Margin = new System.Windows.Forms.Padding(2);
this.gpbProductInfo.Name = "gpbProductInfo";
this.gpbProductInfo.Padding = new System.Windows.Forms.Padding(2);
- this.gpbProductInfo.Size = new System.Drawing.Size(377, 240);
+ this.gpbProductInfo.Size = new System.Drawing.Size(377, 247);
this.gpbProductInfo.TabIndex = 4;
this.gpbProductInfo.TabStop = false;
this.gpbProductInfo.Text = "产品信息";
@@ -526,7 +546,7 @@
this.panel1.Location = new System.Drawing.Point(2, 16);
this.panel1.Margin = new System.Windows.Forms.Padding(2);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(373, 222);
+ this.panel1.Size = new System.Drawing.Size(373, 229);
this.panel1.TabIndex = 0;
//
// cbDefectCode
@@ -703,9 +723,9 @@
//
this.panel2.Controls.Add(this.groupBox2);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel2.Location = new System.Drawing.Point(3, 247);
+ this.panel2.Location = new System.Drawing.Point(3, 254);
this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(375, 100);
+ this.panel2.Size = new System.Drawing.Size(375, 95);
this.panel2.TabIndex = 5;
//
// groupBox2
@@ -721,7 +741,7 @@
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox2.Size = new System.Drawing.Size(375, 100);
+ this.groupBox2.Size = new System.Drawing.Size(375, 95);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "检测控制";
@@ -730,7 +750,7 @@
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label7.Location = new System.Drawing.Point(37, 65);
+ this.label7.Location = new System.Drawing.Point(39, 59);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(93, 20);
this.label7.TabIndex = 8;
@@ -753,9 +773,9 @@
this.ucSwitch1.FalseColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189)))));
this.ucSwitch1.FalseTextColr = System.Drawing.Color.Black;
this.ucSwitch1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.ucSwitch1.Location = new System.Drawing.Point(187, 59);
+ this.ucSwitch1.Location = new System.Drawing.Point(177, 53);
this.ucSwitch1.Name = "ucSwitch1";
- this.ucSwitch1.Size = new System.Drawing.Size(83, 31);
+ this.ucSwitch1.Size = new System.Drawing.Size(80, 28);
this.ucSwitch1.SwitchType = HZH_Controls.Controls.SwitchType.Ellipse;
this.ucSwitch1.TabIndex = 0;
this.ucSwitch1.Texts = new string[] {
@@ -786,9 +806,9 @@
//
this.panel3.Controls.Add(this.gpbLog);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel3.Location = new System.Drawing.Point(3, 353);
+ this.panel3.Location = new System.Drawing.Point(3, 355);
this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(375, 140);
+ this.panel3.Size = new System.Drawing.Size(375, 138);
this.panel3.TabIndex = 6;
//
// gpbLog
@@ -803,7 +823,7 @@
this.gpbLog.Margin = new System.Windows.Forms.Padding(2);
this.gpbLog.Name = "gpbLog";
this.gpbLog.Padding = new System.Windows.Forms.Padding(2);
- this.gpbLog.Size = new System.Drawing.Size(375, 119);
+ this.gpbLog.Size = new System.Drawing.Size(375, 117);
this.gpbLog.TabIndex = 7;
this.gpbLog.TabStop = false;
this.gpbLog.Text = "日志信息";
@@ -817,8 +837,9 @@
this.lstLog.ItemHeight = 16;
this.lstLog.Location = new System.Drawing.Point(2, 16);
this.lstLog.Name = "lstLog";
- this.lstLog.Size = new System.Drawing.Size(371, 101);
+ this.lstLog.Size = new System.Drawing.Size(371, 99);
this.lstLog.TabIndex = 27;
+ this.lstLog.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstLog_DrawItem);
//
// splitContainer2
//
@@ -834,7 +855,7 @@
//
this.splitContainer2.Panel2.Controls.Add(this.tableLayoutPanel3);
this.splitContainer2.Size = new System.Drawing.Size(760, 496);
- this.splitContainer2.SplitterDistance = 483;
+ this.splitContainer2.SplitterDistance = 482;
this.splitContainer2.TabIndex = 0;
//
// splitContainer3
@@ -851,7 +872,7 @@
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.skinTabImage);
- this.splitContainer3.Size = new System.Drawing.Size(483, 496);
+ this.splitContainer3.Size = new System.Drawing.Size(482, 496);
this.splitContainer3.SplitterDistance = 245;
this.splitContainer3.TabIndex = 0;
//
@@ -866,7 +887,7 @@
this.groupBox3.Margin = new System.Windows.Forms.Padding(2);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox3.Size = new System.Drawing.Size(483, 245);
+ this.groupBox3.Size = new System.Drawing.Size(482, 245);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "瑕疵分布";
@@ -879,23 +900,38 @@
this.panel5.Location = new System.Drawing.Point(2, 16);
this.panel5.Margin = new System.Windows.Forms.Padding(2);
this.panel5.Name = "panel5";
- this.panel5.Size = new System.Drawing.Size(479, 227);
+ this.panel5.Size = new System.Drawing.Size(478, 227);
this.panel5.TabIndex = 0;
//
// chart1
//
- chartArea5.Name = "ChartArea1";
- this.chart1.ChartAreas.Add(chartArea5);
+ chartArea1.AxisX.LabelStyle.Format = "N0";
+ chartArea1.AxisX.Maximum = 160D;
+ chartArea1.AxisX.Minimum = 0D;
+ chartArea1.AxisY.Interval = 5D;
+ chartArea1.AxisY.LabelStyle.Format = "N0";
+ chartArea1.AxisY.MaximumAutoSize = 90F;
+ chartArea1.AxisY.Minimum = 0D;
+ chartArea1.AxisY.ScaleView.MinSize = 1D;
+ chartArea1.AxisY.ScaleView.Size = 20D;
+ chartArea1.AxisY.ScaleView.Zoomable = false;
+ chartArea1.AxisY.ScrollBar.BackColor = System.Drawing.Color.WhiteSmoke;
+ chartArea1.AxisY.ScrollBar.ButtonColor = System.Drawing.Color.LightGray;
+ chartArea1.AxisY.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll;
+ chartArea1.AxisY.ScrollBar.IsPositionedInside = false;
+ chartArea1.AxisY.ScrollBar.LineColor = System.Drawing.Color.Gray;
+ chartArea1.Name = "ChartArea1";
+ this.chart1.ChartAreas.Add(chartArea1);
this.chart1.Dock = System.Windows.Forms.DockStyle.Fill;
- legend5.Name = "Legend1";
- this.chart1.Legends.Add(legend5);
+ legend1.Name = "Legend1";
+ this.chart1.Legends.Add(legend1);
this.chart1.Location = new System.Drawing.Point(0, 0);
this.chart1.Name = "chart1";
- series5.ChartArea = "ChartArea1";
- series5.Legend = "Legend1";
- series5.Name = "Series1";
- this.chart1.Series.Add(series5);
- this.chart1.Size = new System.Drawing.Size(479, 227);
+ series1.ChartArea = "ChartArea1";
+ series1.Legend = "Legend1";
+ series1.Name = "Series1";
+ this.chart1.Series.Add(series1);
+ this.chart1.Size = new System.Drawing.Size(478, 227);
this.chart1.TabIndex = 0;
this.chart1.Text = "chart1";
//
@@ -910,7 +946,7 @@
this.skinTabImage.Controls.Add(this.skinTabPage2);
this.skinTabImage.HeadBack = null;
this.skinTabImage.ImgTxtOffset = new System.Drawing.Point(0, 0);
- this.skinTabImage.ItemSize = new System.Drawing.Size(240, 36);
+ this.skinTabImage.ItemSize = new System.Drawing.Size(239, 36);
this.skinTabImage.ItemStretch = true;
this.skinTabImage.Location = new System.Drawing.Point(0, 0);
this.skinTabImage.Name = "skinTabImage";
@@ -925,8 +961,8 @@
this.skinTabImage.PageImagePosition = CCWin.SkinControl.SkinTabControl.ePageImagePosition.Left;
this.skinTabImage.PageNorml = null;
this.skinTabImage.PageNormlTxtColor = System.Drawing.Color.White;
- this.skinTabImage.SelectedIndex = 0;
- this.skinTabImage.Size = new System.Drawing.Size(483, 222);
+ this.skinTabImage.SelectedIndex = 1;
+ this.skinTabImage.Size = new System.Drawing.Size(482, 222);
this.skinTabImage.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.skinTabImage.TabIndex = 0;
//
@@ -938,7 +974,7 @@
this.skinTabPage1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.skinTabPage1.Location = new System.Drawing.Point(0, 36);
this.skinTabPage1.Name = "skinTabPage1";
- this.skinTabPage1.Size = new System.Drawing.Size(483, 186);
+ this.skinTabPage1.Size = new System.Drawing.Size(482, 186);
this.skinTabPage1.TabIndex = 0;
this.skinTabPage1.TabItemImage = null;
this.skinTabPage1.Text = "实时采集图像";
@@ -955,7 +991,7 @@
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
- this.tableLayoutPanel2.Size = new System.Drawing.Size(483, 186);
+ this.tableLayoutPanel2.Size = new System.Drawing.Size(482, 186);
this.tableLayoutPanel2.TabIndex = 0;
//
// pictureBox3
@@ -966,7 +1002,7 @@
this.pictureBox3.Location = new System.Drawing.Point(243, 2);
this.pictureBox3.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox3.Name = "pictureBox3";
- this.pictureBox3.Size = new System.Drawing.Size(238, 182);
+ this.pictureBox3.Size = new System.Drawing.Size(237, 182);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox3.TabIndex = 12;
this.pictureBox3.TabStop = false;
@@ -992,7 +1028,7 @@
this.skinTabPage2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.skinTabPage2.Location = new System.Drawing.Point(0, 36);
this.skinTabPage2.Name = "skinTabPage2";
- this.skinTabPage2.Size = new System.Drawing.Size(483, 186);
+ this.skinTabPage2.Size = new System.Drawing.Size(482, 186);
this.skinTabPage2.TabIndex = 1;
this.skinTabPage2.TabItemImage = null;
this.skinTabPage2.Text = "处理合并图像";
@@ -1005,7 +1041,7 @@
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(483, 186);
+ this.pictureBox1.Size = new System.Drawing.Size(482, 186);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 10;
this.pictureBox1.TabStop = false;
@@ -1024,7 +1060,7 @@
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
- this.tableLayoutPanel3.Size = new System.Drawing.Size(273, 496);
+ this.tableLayoutPanel3.Size = new System.Drawing.Size(274, 496);
this.tableLayoutPanel3.TabIndex = 0;
//
// panel8
@@ -1033,7 +1069,7 @@
this.panel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel8.Location = new System.Drawing.Point(3, 349);
this.panel8.Name = "panel8";
- this.panel8.Size = new System.Drawing.Size(267, 144);
+ this.panel8.Size = new System.Drawing.Size(443, 144);
this.panel8.TabIndex = 8;
//
// groupBox5
@@ -1049,7 +1085,7 @@
this.groupBox5.Margin = new System.Windows.Forms.Padding(2);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox5.Size = new System.Drawing.Size(267, 122);
+ this.groupBox5.Size = new System.Drawing.Size(443, 122);
this.groupBox5.TabIndex = 7;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "幅宽";
@@ -1062,23 +1098,30 @@
this.panel9.Location = new System.Drawing.Point(2, 16);
this.panel9.Margin = new System.Windows.Forms.Padding(2);
this.panel9.Name = "panel9";
- this.panel9.Size = new System.Drawing.Size(263, 104);
+ this.panel9.Size = new System.Drawing.Size(439, 104);
this.panel9.TabIndex = 0;
//
// chart3
//
- chartArea6.Name = "ChartArea1";
- this.chart3.ChartAreas.Add(chartArea6);
+ chartArea2.AxisX.LabelStyle.Format = "N0";
+ chartArea2.AxisX.MaximumAutoSize = 100F;
+ chartArea2.AxisX.Minimum = 0D;
+ chartArea2.AxisX.ScaleView.Size = 10D;
+ chartArea2.AxisX.ScaleView.Zoomable = false;
+ chartArea2.AxisX.ScrollBar.ButtonStyle = System.Windows.Forms.DataVisualization.Charting.ScrollBarButtonStyles.SmallScroll;
+ chartArea2.AxisY.LabelStyle.Format = "N0";
+ chartArea2.Name = "ChartArea1";
+ this.chart3.ChartAreas.Add(chartArea2);
this.chart3.Dock = System.Windows.Forms.DockStyle.Fill;
- legend6.Name = "Legend1";
- this.chart3.Legends.Add(legend6);
+ legend2.Name = "Legend1";
+ this.chart3.Legends.Add(legend2);
this.chart3.Location = new System.Drawing.Point(0, 0);
this.chart3.Name = "chart3";
- series6.ChartArea = "ChartArea1";
- series6.Legend = "Legend1";
- series6.Name = "Series1";
- this.chart3.Series.Add(series6);
- this.chart3.Size = new System.Drawing.Size(263, 104);
+ series2.ChartArea = "ChartArea1";
+ series2.Legend = "Legend1";
+ series2.Name = "Series1";
+ this.chart3.Series.Add(series2);
+ this.chart3.Size = new System.Drawing.Size(439, 104);
this.chart3.TabIndex = 0;
this.chart3.Text = "chart3";
//
@@ -1088,7 +1131,7 @@
this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel6.Location = new System.Drawing.Point(3, 201);
this.panel6.Name = "panel6";
- this.panel6.Size = new System.Drawing.Size(267, 142);
+ this.panel6.Size = new System.Drawing.Size(443, 142);
this.panel6.TabIndex = 7;
//
// groupBox4
@@ -1102,7 +1145,7 @@
this.groupBox4.Margin = new System.Windows.Forms.Padding(2);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox4.Size = new System.Drawing.Size(267, 142);
+ this.groupBox4.Size = new System.Drawing.Size(443, 142);
this.groupBox4.TabIndex = 6;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "瑕疵信息";
@@ -1115,7 +1158,7 @@
this.panel7.Location = new System.Drawing.Point(2, 16);
this.panel7.Margin = new System.Windows.Forms.Padding(2);
this.panel7.Name = "panel7";
- this.panel7.Size = new System.Drawing.Size(263, 124);
+ this.panel7.Size = new System.Drawing.Size(439, 124);
this.panel7.TabIndex = 0;
//
// pictureBox4
@@ -1126,7 +1169,7 @@
this.pictureBox4.Location = new System.Drawing.Point(0, 0);
this.pictureBox4.Margin = new System.Windows.Forms.Padding(2);
this.pictureBox4.Name = "pictureBox4";
- this.pictureBox4.Size = new System.Drawing.Size(263, 124);
+ this.pictureBox4.Size = new System.Drawing.Size(439, 124);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox4.TabIndex = 13;
this.pictureBox4.TabStop = false;
@@ -1142,7 +1185,7 @@
this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox1.Size = new System.Drawing.Size(269, 194);
+ this.groupBox1.Size = new System.Drawing.Size(445, 194);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "瑕疵列表";
@@ -1155,38 +1198,47 @@
this.panel4.Location = new System.Drawing.Point(2, 16);
this.panel4.Margin = new System.Windows.Forms.Padding(2);
this.panel4.Name = "panel4";
- this.panel4.Size = new System.Drawing.Size(265, 176);
+ this.panel4.Size = new System.Drawing.Size(441, 176);
this.panel4.TabIndex = 0;
//
// skinDataGridView1
//
- dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(231)))), ((int)(((byte)(246)))), ((int)(((byte)(253)))));
- this.skinDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle11;
+ dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(231)))), ((int)(((byte)(246)))), ((int)(((byte)(253)))));
+ this.skinDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.skinDataGridView1.BackgroundColor = System.Drawing.SystemColors.Window;
this.skinDataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.skinDataGridView1.ColumnFont = null;
this.skinDataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
- dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle12.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(246)))), ((int)(((byte)(239)))));
- dataGridViewCellStyle12.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.Window;
- dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.skinDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12;
+ dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(246)))), ((int)(((byte)(239)))));
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.Window;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.skinDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.skinDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.skinDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2});
+ this.colUid,
+ this.colCode,
+ this.colIndex,
+ this.colDefectName,
+ this.colX,
+ this.colY,
+ this.colW,
+ this.colH,
+ this.colArea,
+ this.colZXD,
+ this.colTarget});
this.skinDataGridView1.ColumnSelectForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- dataGridViewCellStyle13.BackColor = System.Drawing.Color.White;
- dataGridViewCellStyle13.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(188)))), ((int)(((byte)(240)))));
- dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.White;
- dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
- this.skinDataGridView1.DefaultCellStyle = dataGridViewCellStyle13;
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.Color.White;
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(188)))), ((int)(((byte)(240)))));
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+ this.skinDataGridView1.DefaultCellStyle = dataGridViewCellStyle3;
this.skinDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.skinDataGridView1.EnableHeadersVisualStyles = false;
this.skinDataGridView1.GridColor = System.Drawing.SystemColors.GradientActiveCaption;
@@ -1196,39 +1248,27 @@
this.skinDataGridView1.Location = new System.Drawing.Point(0, 0);
this.skinDataGridView1.Name = "skinDataGridView1";
this.skinDataGridView1.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
- dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.ButtonHighlight;
- dataGridViewCellStyle14.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.MenuText;
- dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.skinDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle14;
+ dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
+ dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.MenuText;
+ dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.skinDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.skinDataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
- dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- this.skinDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle15;
+ dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ this.skinDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle5;
this.skinDataGridView1.RowTemplate.Height = 23;
- this.skinDataGridView1.Size = new System.Drawing.Size(265, 176);
+ this.skinDataGridView1.Size = new System.Drawing.Size(441, 176);
this.skinDataGridView1.TabIndex = 0;
this.skinDataGridView1.TitleBack = null;
this.skinDataGridView1.TitleBackColorBegin = System.Drawing.SystemColors.HotTrack;
this.skinDataGridView1.TitleBackColorEnd = System.Drawing.SystemColors.HotTrack;
//
- // Column1
- //
- this.Column1.HeaderText = "图号";
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- this.Column2.HeaderText = "名称";
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
// statusStrip1
//
this.statusStrip1.BackColor = System.Drawing.SystemColors.HotTrack;
@@ -1276,6 +1316,84 @@
this.tslabelTime.Size = new System.Drawing.Size(103, 17);
this.tslabelTime.Text = "实时测试:360.00s";
//
+ // colUid
+ //
+ this.colUid.HeaderText = "Uid";
+ this.colUid.Name = "colUid";
+ this.colUid.ReadOnly = true;
+ this.colUid.Visible = false;
+ //
+ // colCode
+ //
+ this.colCode.HeaderText = "Code";
+ this.colCode.Name = "colCode";
+ this.colCode.ReadOnly = true;
+ this.colCode.Visible = false;
+ //
+ // colIndex
+ //
+ this.colIndex.DataPropertyName = "Index";
+ this.colIndex.HeaderText = "图号";
+ this.colIndex.Name = "colIndex";
+ this.colIndex.ReadOnly = true;
+ //
+ // colDefectName
+ //
+ this.colDefectName.DataPropertyName = "Name";
+ this.colDefectName.HeaderText = "名称";
+ this.colDefectName.Name = "colDefectName";
+ this.colDefectName.ReadOnly = true;
+ //
+ // colX
+ //
+ this.colX.DataPropertyName = "X";
+ this.colX.HeaderText = "X(cm)";
+ this.colX.Name = "colX";
+ this.colX.ReadOnly = true;
+ //
+ // colY
+ //
+ this.colY.DataPropertyName = "Y";
+ this.colY.HeaderText = "Y(m)";
+ this.colY.Name = "colY";
+ this.colY.ReadOnly = true;
+ //
+ // colW
+ //
+ this.colW.HeaderText = "宽(cm)";
+ this.colW.Name = "colW";
+ this.colW.ReadOnly = true;
+ //
+ // colH
+ //
+ this.colH.HeaderText = "高(cm)";
+ this.colH.Name = "colH";
+ this.colH.ReadOnly = true;
+ //
+ // colArea
+ //
+ this.colArea.HeaderText = "面积(cm)";
+ this.colArea.Name = "colArea";
+ this.colArea.ReadOnly = true;
+ //
+ // colZXD
+ //
+ this.colZXD.DataPropertyName = "ZXD";
+ this.colZXD.HeaderText = "置信度";
+ this.colZXD.Name = "colZXD";
+ this.colZXD.ReadOnly = true;
+ //
+ // colTarget
+ //
+ this.colTarget.DataPropertyName = "Contrast";
+ this.colTarget.HeaderText = "对比度";
+ this.colTarget.Name = "colTarget";
+ this.colTarget.ReadOnly = true;
+ //
+ // backgroundWorker1
+ //
+ this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
+ //
// uiTitel1
//
this.uiTitel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(8)))), ((int)(((byte)(31)))), ((int)(((byte)(120)))));
@@ -1286,11 +1404,41 @@
this.uiTitel1.Size = new System.Drawing.Size(1145, 46);
this.uiTitel1.TabIndex = 21;
//
+ // lblDefectSpeed
+ //
+ this.lblDefectSpeed.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.lblDefectSpeed.AutoSize = true;
+ this.lblDefectSpeed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(51)))), ((int)(((byte)(122)))));
+ this.lblDefectSpeed.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.lblDefectSpeed.ForeColor = System.Drawing.Color.LimeGreen;
+ this.lblDefectSpeed.Location = new System.Drawing.Point(939, 118);
+ this.lblDefectSpeed.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lblDefectSpeed.Name = "lblDefectSpeed";
+ this.lblDefectSpeed.Size = new System.Drawing.Size(171, 16);
+ this.lblDefectSpeed.TabIndex = 30;
+ this.lblDefectSpeed.Text = "检测速度: 0 米/分钟";
+ //
+ // lblDefectLen
+ //
+ this.lblDefectLen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.lblDefectLen.AutoSize = true;
+ this.lblDefectLen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(51)))), ((int)(((byte)(122)))));
+ this.lblDefectLen.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.lblDefectLen.ForeColor = System.Drawing.Color.LimeGreen;
+ this.lblDefectLen.Location = new System.Drawing.Point(939, 98);
+ this.lblDefectLen.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lblDefectLen.Name = "lblDefectLen";
+ this.lblDefectLen.Size = new System.Drawing.Size(128, 16);
+ this.lblDefectLen.TabIndex = 29;
+ this.lblDefectLen.Text = "检测长度: 0 米";
+ //
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1145, 641);
+ this.Controls.Add(this.lblDefectSpeed);
+ this.Controls.Add(this.lblDefectLen);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.toolStrip1);
@@ -1435,8 +1583,6 @@
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Panel panel4;
private CCWin.SkinControl.SkinDataGridView skinDataGridView1;
- private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
- private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Panel panel9;
@@ -1447,6 +1593,20 @@
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.ComboBox cbDefectCode;
private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colUid;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colCode;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colIndex;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colDefectName;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colX;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colY;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colW;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colH;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colArea;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colZXD;
+ private System.Windows.Forms.DataGridViewTextBoxColumn colTarget;
+ private System.ComponentModel.BackgroundWorker backgroundWorker1;
+ private System.Windows.Forms.Label lblDefectSpeed;
+ private System.Windows.Forms.Label lblDefectLen;
}
}
diff --git a/LeatherProject/GeBoShi/Main.cs b/LeatherProject/GeBoShi/Main.cs
index 0f68154..e50458f 100644
--- a/LeatherProject/GeBoShi/Main.cs
+++ b/LeatherProject/GeBoShi/Main.cs
@@ -3,22 +3,42 @@ using GeBoShi.UI;
using GeBoShi.UI.Load;
using GeBoShi.UI.Product;
using GeBoShi.UI.SysSet;
+using HZH_Controls;
+using HZH_Controls.Controls;
using HZH_Controls.Forms;
+using MaiMuControl.Device;
+using MaiMuControl.Device.CamDev;
+using Models;
+using OpenCvSharp.Extensions;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Web.UI.WebControls.WebParts;
using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
namespace GeBoShi
{
public partial class Main : Form
{
+ object AddTextLock = new object();
+ bool backgroundWorkerDo;
+ ///
+ /// 显示颜色现在对应30色,确保label在30个以内
+ ///
+ Color[] ChartColor = new Color[30] { Color.Red, Color.Blue, Color.Green, Color.YellowGreen, Color.Orange,
+ Color.Peru, Color.DarkRed,Color.AliceBlue, Color.Pink , Color.Brown,
+ Color.CadetBlue, Color.OrangeRed, Color.Cyan, Color.Lime, Color.Magenta, Color.Tan, Color.Sienna,
+ Color.AliceBlue, Color.SaddleBrown, Color.DarkBlue, Color.Firebrick,Color.Gainsboro,Color.Honeydew,Color.Khaki,Color.Lavender,
+ Color.LightGoldenrodYellow,Color.Navy, Color.Khaki, Color.IndianRed,Color.Lavender};
public Main()
{
InitializeComponent();
@@ -33,6 +53,32 @@ namespace GeBoShi
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
+
+ SysMgr.Instance.MainRuning += main_running;
+ SysMgr.Instance.AutoRuning += auto_runing;
+
+ #region dataGridView设置
+ skinDataGridView1.AllowUserToAddRows = skinDataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
+ skinDataGridView1.AllowUserToResizeRows = false;//用户调整行大小 //显示行号与列宽度自动调整
+ skinDataGridView1.RowHeadersVisible = true;
+ skinDataGridView1.RowHeadersWidth = 50;
+ //dataGridView1.ColumnHeadersHeightSizeMode = dataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+ skinDataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
+ skinDataGridView1.RowTemplate.Height = 30;
+
+ //skinDataGridView1.RowPostPaint += (sender, e) =>//序号列头
+ //{
+ // showRowNum_onDataGrid_RowPostPaint(this.skinDataGridView1, sender, e);
+ //};
+ for (int i = 0; i < skinDataGridView1.Columns.Count; i++)//禁止点击列头排序
+ skinDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
+ this.skinDataGridView1.CellClick += skinDataGridView1_CellClick; ;
+ #endregion
+
+ this.lblDefectLen.Top = toolStrip1.Top + 10;
+ this.lblDefectLen.Left = toolStrip1.Width - 300;
+ this.lblDefectSpeed.Top = toolStrip1.Top + 10 + lblDefectLen.Height + 5;
+ this.lblDefectSpeed.Left = toolStrip1.Width - 300;
}
#region 初始化
@@ -60,6 +106,11 @@ namespace GeBoShi
#endregion
#region 界面刷新
+ private void showRowNum_onDataGrid_RowPostPaint(DataGridView dgv, object sender, DataGridViewRowPostPaintEventArgs e)
+ {
+ Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height);
+ TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rectangle, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
+ }
private void ResetUI(bool clearSN)
{
@@ -80,8 +131,40 @@ namespace GeBoShi
this.cbProductReelNum.Enabled = true;
this.cbProductNum.Enabled = true;
- tslabelTime.Text = "实时测试:0.00s";
+ this.pictureBox1.Image = null;
+ pictureBox1.Refresh();
+ this.pictureBox2.Image = null;
+ pictureBox2.Refresh();
+ this.pictureBox3.Image = null;
+ pictureBox3.Refresh();
+ this.pictureBox4.Image = null;
+ pictureBox4.Refresh();
+ //tslabelTime.Text = "实时测试:0.00s";
+ skinDataGridView1.DataSource = null;
+
+ this.skinDataGridView1.Rows.Clear();
+ chart1.Series.Clear();
+ chart1.Series.Add("SELECT");
+ chart1.Series["SELECT"].ChartType = SeriesChartType.Point;
+ chart1.Series["SELECT"].MarkerSize = 25;
+ chart1.Series["SELECT"].MarkerColor = Color.Black;
+ chart1.Series["SELECT"].MarkerStyle = MarkerStyle.Star6;
+ //chart1.Series["SELECT"].Enabled = false;
+ chart1.ChartAreas[0].AxisX.Title = "宽度(cm)";
+ chart1.ChartAreas[0].AxisY.Title = "长度(m)";
+
+ chart3.Series.Clear();
+ chart3.Series.Add("面宽");
+ chart3.ChartAreas[0].AxisX.Title = "长度(m)";
+ chart3.ChartAreas[0].AxisY.Title = "宽度(cm)";
+ chart3.Series["面宽"].ChartType = SeriesChartType.Line;
+ chart3.Series["面宽"].MarkerSize = 5;
+ chart3.Series["面宽"].MarkerColor = Color.Blue;
+ chart3.Series["面宽"].MarkerStyle = MarkerStyle.Circle;
+
+ lblDefectLen.Text = $"检测长度: 0 米";
+ lblDefectSpeed.Text = $"检测速度: 0 米/分钟";
this.Refresh();
}
#endregion
@@ -165,18 +248,17 @@ namespace GeBoShi
//backgroundWorker1.RunWorkerAsync();
//s_BackWorker = true;
//backgroundWorker.RunWorkerAsync();
-
+
//开启云端连接
//SysMgr.Instance.InitCloudConnect();
//开启产品服务
//SysMgr.Instance.InitPdtService();
//开启处理事件反馈
- //SysMgr.Instance.InitDefectEvent();
+ SysMgr.Instance.InitDefectEvent();
//加载产品料号
- //SysMgr.Instance.LoadProductCodeList();
+ SysMgr.Instance.LoadProductCodeList();
//加载产品选择
- //LoadPdtList(SysMgr.Instance.ProductCodeList);
- //LoadSNList(SysMgr.Instance.ProductSNList);
+ LoadPdtList(SysMgr.Instance.ProductCodeList);
this.Cursor = Cursors.Default;
//运行前检测磁盘空间
@@ -275,6 +357,10 @@ namespace GeBoShi
}
}
+ private void tsmDebug_Click(object sender, EventArgs e)
+ {
+
+ }
#endregion
#endregion
@@ -285,7 +371,24 @@ namespace GeBoShi
private void LoadPdtList(List list)
{
this.cbDefectCode.Items.Clear();
+ while (true)
+ {
+ bool bk = true;
+ for (int i = 0; i < list.Count; i++)
+ {
+ if (list[i] == null || string.IsNullOrEmpty(list[i]))
+ {
+ list.Remove(list[i]);
+ bk = false;
+ }
+ }
+ if (bk)
+ {
+ break;
+ }
+ }
this.pdtlistData = list.ToArray();
+
cbDefectCode.Items.AddRange(pdtlistData);//比使用DataSource速度要快一些
cbDefectCode.TextUpdate += cobList_TextUpdate;//重新绑定事件
cbDefectCode.KeyDown += CobList_KeyDown;
@@ -344,5 +447,514 @@ namespace GeBoShi
}
}
#endregion
+
+ #region 按钮
+
+ private void tsbtnStart_Click(object sender, EventArgs e)
+ {
+ if (!SysMgr.Instance.IsRuning)
+ {
+ //低报警自动复位
+ if (SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
+ {
+ if (SysMgr.Instance.StatusMgr.Warning == WarningEnum.Low)
+ {
+ SysMgr.Instance.StatusMgr.ClearWarning();
+ SysMgr.Instance.StatusMgr.GotoNormalStandby();
+ }
+ }
+ //提示正在报警中
+ if (SysMgr.Instance.StatusMgr.Status == SystemStsEnum.Warning)
+ {
+ FrmDialog.ShowDialog(this, "系统报警中!无法启动运行!", "警告", false);
+ return;
+ }
+ this.Cursor = Cursors.WaitCursor;
+ System.Windows.Forms.Application.DoEvents();
+ if (SysMgr.Instance.StatusMgr.Status != SystemStsEnum.Pause)
+ {
+ ResetUI(false);
+ AddTextEvent("运行", $"启动自动检测流程");
+ this.lstLog.Refresh();
+ string name = this.cbProductCode.Text;
+ string batch = this.cbProductBatch.Text;
+ string reel = this.cbProductReelNum.Text;
+ string len = this.cbProductNum.Text;
+ string defname = this.cbDefectCode.Text;
+ if (SysMgr.Instance.StartRun(this, this.cbPdtSN.Text, ref defname, ref name, ref batch, ref reel, ref len))
+ {
+ this.tsbtnImpStop.Enabled = true;
+ this.tsbtnStop.Enabled = true;
+ this.tsbtnStart.Enabled = false;
+ //锁定信息
+ this.cbPdtSN.Enabled = false;
+ this.cbProductCode.Enabled = false;
+ this.cbProductBatch.Enabled = false;
+ this.cbProductReelNum.Enabled = false;
+ this.cbProductNum.Enabled = false;
+ this.cbDefectCode.Enabled = false;
+ //记录开始运行时间
+ //RunStartTime.Restart();
+
+ //重新显示
+ this.cbProductCode.Text = name;
+ this.cbProductBatch.Text = batch;
+ this.cbProductReelNum.Text = reel;
+ this.cbProductNum.Text = len;
+ this.cbDefectCode.Text = defname;
+
+
+ }
+ }
+ else //暂停状态开始
+ {
+ if (SysMgr.Instance.ReStartRun())
+ {
+ this.tsbtnStop.Enabled = true;
+ this.tsbtnStart.Enabled = false;
+ }
+ }
+ this.Cursor = Cursors.Default;
+ }
+ }
+
+ private void tsbtnReset_Click(object sender, EventArgs e)
+ {
+
+ }
+ private void tsbtnStop_Click(object sender, EventArgs e)
+ {
+ AddTextEvent("暂停", "手动暂停");
+ this.tsbtnStart.Enabled = true;
+ SysMgr.Instance.StatusMgr.GotoPause();
+ SysMgr.Instance.SendStatus();
+ SysMgr.Instance.LedPause();
+ }
+
+ private void tsbtnWarning_Click(object sender, EventArgs e)
+ {
+ if (SysMgr.Instance.StatusMgr.Warning != WarningEnum.Normal)
+ {
+ AddTextEvent("清除", "手动清除报警");
+ SysMgr.Instance.StatusMgr.ClearWarning();
+ SysMgr.Instance.LedReady();
+ if (SysMgr.Instance.IsAuto)
+ SysMgr.Instance.StatusMgr.GotoPause();
+ else
+ SysMgr.Instance.StatusMgr.GotoNormalStandby();
+ SysMgr.Instance.SendStatus();
+ }
+ }
+ ///
+ /// 结束验布
+ ///
+ ///
+ ///
+ private void tsbtnImpStop_Click(object sender, EventArgs e)
+ {
+ AddTextEvent("结束验布", "手动结束验布");
+ SysMgr.Instance.DefectEnd(this);
+ }
+
+ int cnnnt = 10;
+ private void tsbGoHome_Click(object sender, EventArgs e)
+ {
+#if false
+ //测试散点
+ chart1.Series.Clear();
+ chart1.ChartAreas[0].AxisX.Title = "宽度(cm)";
+ chart1.ChartAreas[0].AxisY.Title = "长度(m)";
+
+ chart1.Series.Add("皱印");
+ chart1.Series["皱印"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ chart1.Series["皱印"].MarkerSize = 10;
+ chart1.Series["皱印"].MarkerColor = Color.Red;
+ chart1.Series["皱印"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
+ for (int i = 0; i < cnnnt; i++)
+ this.chart1.Series["皱印"].Points.AddXY(i%5,i);
+
+ chart1.Series.Add("划伤");
+ chart1.Series["划伤"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ chart1.Series["划伤"].MarkerSize = 10;
+ chart1.Series["划伤"].MarkerColor = Color.Blue;
+ chart1.Series["划伤"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
+ for (int i = 0; i < cnnnt; i++)
+ this.chart1.Series["划伤"].Points.AddXY(i % 5 + 0.5, i + 0.3);
+
+ chart1.ChartAreas[0].AxisY.Maximum = ((int)(this.chart1.Series["划伤"].Points.FindMaxByValue().YValues.Max() /10) + 1) * 10 + 5;
+ chart1.ChartAreas[0].AxisY.ScaleView.Scroll(System.Windows.Forms.DataVisualization.Charting.ScrollType.Last);
+ cnnnt +=20;
+
+ MemoryStream ms = new MemoryStream();
+ chart1.SaveImage(ms, ChartImageFormat.Bmp);
+ Bitmap bmp = new Bitmap(ms);
+ bmp.Save("111.jpg");
+ ms.Close();
+#endif
+ //测试散点
+ chart3.Series.Clear();
+ chart3.ChartAreas[0].AxisX.Title = "长度(m)";
+ chart3.ChartAreas[0].AxisY.Title = "宽度(cm)";
+
+ chart3.Series.Add("面宽");
+
+ string tt = "面宽";
+ if (chart3.Series.FindByName(tt) == null)
+ chart3.Series.Add("面宽");
+ else
+ {
+ chart3.Series["面宽"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ chart3.Series["面宽"].MarkerSize = 5;
+ chart3.Series["面宽"].MarkerColor = Color.Blue;
+ chart3.Series["面宽"].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
+
+ Random rm = new Random();
+ for (int i = 0; i < cnnnt; i++)
+ this.chart3.Series["面宽"].Points.AddXY(i, rm.Next(140, 160));
+ cnnnt += 20;
+ }
+ //chart3.Series[0].f
+ chart3.ChartAreas["ChartArea1"].AxisX.ScaleView.Scroll(ScrollType.Last);
+ }
+#endregion
+
+ #region 显示图像和消息
+ private void lstLog_DrawItem(object sender, DrawItemEventArgs e)
+ {
+ e.DrawBackground();
+ if (e.Index < 0) return;
+
+ try
+ {
+ string str = lstLog.Items[e.Index].ToString();
+ e.Graphics.DrawString(str.Substring(1), e.Font,
+ new SolidBrush(str[0] == 'R' ? Color.Red : (str[0] == 'Y' ? Color.Orange : Color.Black)),
+ e.Bounds);
+ }
+ catch (Exception ex)
+ {
+ e.Graphics.DrawString(ex.Message, e.Font,
+ new SolidBrush(Color.Red),
+ e.Bounds);
+ }
+ }
+
+ ///
+ /// 异步输出日志
+ ///
+ /// 模板标识
+ /// 内容
+ ///
+ private void AddTextEvent(string tag, string msg, WarningEnum level = WarningEnum.Normal)
+ {
+ lock (AddTextLock)
+ {
+ if (tag != null && tag != "")
+ tag = $" - [{tag}]";
+
+ var now = DateTime.Now;
+ msg = now.ToString("HH:mm:ss fff") + tag + " - " + msg;
+
+ msg = (level == WarningEnum.Normal ? "B" : level == WarningEnum.Low ? "Y" : "R") + msg;
+
+ if (this.lstLog.Items.Count > 1000)
+ this.lstLog.Items.Clear();
+ lstLog.Items.Insert(0, msg);
+
+ }
+ }
+
+ private void main_running(object sender, MainEventArgs e)
+ {
+ ShowMessage(e);
+ }
+ private delegate void ShowMessageDelegate(MainEventArgs e);
+ private void ShowMessage(MainEventArgs e)
+ {
+ if (InvokeRequired)
+ {
+ ShowMessageDelegate smd = new ShowMessageDelegate(ShowMessage);
+ this.BeginInvoke(smd, e);
+ }
+ else
+ {
+ AddTextEvent(e.Tag, e.Message, e.Warning);
+ }
+ }
+
+ ///
+ /// 自动运行流程显示
+ ///
+ ///
+ ///
+ private void auto_runing(object sender, RunEventArgs e)
+ {
+ ShowUIEvent(e);
+ }
+
+ private delegate void ShowUIEventDelegate(RunEventArgs e);
+ Bitmap bmp0;
+ Bitmap bmp1;
+ Bitmap bmp2;
+ private void ShowUIEvent(RunEventArgs e)
+ {
+ if (InvokeRequired)
+ {
+ ShowUIEventDelegate smd = new ShowUIEventDelegate(ShowUIEvent);
+ this.BeginInvoke(smd, e);
+ }
+ else
+ {
+ try
+ {
+ if (e.Cmd == 6) //显示主图
+ {
+ if (e.PicIndex == 1)
+ {
+ bmp1 = (Bitmap)CamDev.HImageToBitmap(e.Pic).Clone();
+ this.pictureBox2.Image = bmp1;
+ this.pictureBox2.Refresh();
+ }
+ else if (e.PicIndex == 2)
+ {
+ bmp2 = (Bitmap)CamDev.HImageToBitmap(e.Pic).Clone();
+ this.pictureBox3.Image = bmp2;
+ this.pictureBox3.Refresh();
+ }
+ else if(e.PicIndex == 0)
+ {
+ bmp0 = (Bitmap)CamDev.HImageToBitmap(e.Pic).Clone();
+ this.pictureBox1.Image = bmp0;
+ this.pictureBox1.Refresh();
+ }
+ }
+ else if (e.Cmd == 10) //测试结束
+ {
+ this.tsbtnStart.Enabled = true;
+ this.tsbtnStop.Enabled = false;
+ this.tsbtnImpStop.Enabled = false;
+
+ this.cbPdtSN.Enabled = true;
+ this.cbProductCode.Enabled = true;
+ this.cbProductBatch.Enabled = true;
+ this.cbProductReelNum.Enabled = true;
+ this.cbProductNum.Enabled = true;
+ this.cbDefectCode.Enabled = true;
+ }
+ else if (e.Cmd == 11) //显示缺陷列表
+ {
+ foreach (var rowItem in e.DataRowlist)
+ {
+ this.skinDataGridView1.Rows.Insert(0, rowItem);
+ if (chart1.Series.FindByName((string)rowItem[3]) == null)//rowItem[3] 为name
+ {
+ chart1.Series.Add((string)rowItem[3]);
+ var obj = SysMgr.Instance.GetDefectLabel((string)rowItem[3]);
+ int labelIndex = obj.Value("id");
+ chart1.Series[(string)rowItem[3]].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ chart1.Series[(string)rowItem[3]].MarkerSize = 5;
+ chart1.Series[(string)rowItem[3]].MarkerColor = ChartColor[labelIndex];
+ chart1.Series[(string)rowItem[3]].MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
+ }
+ chart1.Series[(string)rowItem[3]].Points.AddXY(rowItem[4], rowItem[5]);
+ }
+ //chart1.ChartAreas[0].AxisY.Maximum = ((int)(this.chart1.Series["划伤"].Points.FindMaxByValue().YValues.Max() / 10) + 1) * 10 + 5;
+ chart1.ChartAreas[0].AxisY.ScaleView.Scroll(System.Windows.Forms.DataVisualization.Charting.ScrollType.Last);
+ }
+ else if(e.Cmd == 12) //显示处理图
+ {
+ bmp0 = (Bitmap)e.Defectimg.Clone();
+ this.pictureBox1.Image = bmp0;
+ this.pictureBox1.Refresh();
+ }
+ else if (e.Cmd == 13) //显示门幅
+ {
+ //this.BeginInvoke(new System.Action(() =>
+ //{
+ List ydata = new List();
+ foreach (var Item in e.Points)
+ {
+ ydata.Add(Item[1]);
+ float x = Item[0] / 100; //cm -> m
+ this.chart3.Series["面宽"].Points.AddXY((float)Math.Round(x, 2), (float)Math.Round(Item[1], 2));
+ }
+ chart3.ChartAreas[0].AxisY.Maximum = Math.Round(ydata.Max() + 10, 0);
+ chart3.ChartAreas[0].AxisY.Minimum = Math.Round(ydata.Max() - 10, 0);
+ chart3.ChartAreas["ChartArea1"].AxisX.ScaleView.Scroll(ScrollType.Last);
+ //}));
+ }
+ else if (e.Cmd == 14) //显示速度
+ {
+ //this.BeginInvoke(new System.Action(() =>
+ //{
+ lblDefectLen.Text = $"检测长度: {e.Len} 米";
+ lblDefectSpeed.Text = $"检测速度: {e.Speed} 米/分钟";
+ //}));
+ }
+ else if (e.Cmd == 15) //显示处理图 new
+ {
+ bmp0 = (Bitmap)e.DefectMat.ToBitmap();
+ this.pictureBox1.Image = bmp0;
+ this.pictureBox1.Refresh();
+ }
+ Application.DoEvents();
+ }
+ catch { }
+ }
+ }
+ #endregion
+
+ #region 后台
+ GetPN pn = new GetPN();
+ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
+ {
+ while (backgroundWorkerDo)
+ {
+ try
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.tsslLoginTime.Text = $" 当前时间:{DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss")}";
+ }));
+ //检测按钮和实时状态
+ if (SysMgr.Instance.IsInit)
+ {
+ bool sts = SysMgr.Instance.WarningShowLed(false);
+ if (sts)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.tsbtnStart.Enabled = true;
+ this.tsbtnStop.Enabled = false;
+ }));
+ }
+ int stsno = 0;
+ stsno = SysMgr.Instance.ButtonIOTrg(false);
+ if (stsno == 1)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ tsbtnStart_Click(null, null);
+ }));
+ }
+ else if (stsno == 2)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.tsbtnStart.Enabled = true;
+ }));
+ SysMgr.Instance.LedPause();
+ }
+ else if (stsno == 3)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ tsbtnReset_Click(null, null);
+ }));
+
+ }
+ }
+ //if (pn.P(SysMgr.Instance.IsRuning))
+ //{
+ // //继续计时
+ // RunStartTime.Start();
+ //}
+ //if (pn.N(SysMgr.Instance.IsRuning))
+ //{
+ // //停止计时
+ // RunStartTime.Stop();
+ //}
+ //if (SysMgr.Instance.IsRuning)
+ //{
+ // //实时显示
+ // RunStartTime.Stop();
+ // this.Invoke(new MethodInvoker(() =>
+ // {
+ // tslabelTime.Text = "实时测试:" + ((double)RunStartTime.ElapsedMilliseconds / 1000.0).ToString("0.000") + "s";
+ // //this.Refresh();
+ // }));
+ // RunStartTime.Start();
+ //}
+ Thread.Sleep(100);
+ Application.DoEvents();
+ }
+ catch { }
+ }
+ }
+ ///
+ /// 信号上升沿下降沿捕获
+ ///
+ class GetPN
+ {
+ bool _P = false;
+ bool _N = false;
+ ///
+ /// 判断上升沿
+ ///
+ ///
+ ///
+ public bool P(bool Value)
+ {
+ if (Value && !_P)
+ {
+ _P = true;
+ return true;
+ }
+
+ if (!Value)
+ _P = false;
+
+ return false;
+ }
+ ///
+ /// 判断下降沿
+ ///
+ ///
+ ///
+ public bool N(bool Value)
+ {
+ if (!Value && _N)
+ {
+ _N = false;
+ return true;
+ }
+
+ if (Value)
+ _N = true;
+ return false;
+ }
+ }
+
+
+
+
+ #endregion
+
+ #region 表格点击
+ private void skinDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
+ {
+ if (e.RowIndex < 0)
+ return;
+ var defectInfo = SysMgr.Instance.GetDefectInfo((long)this.skinDataGridView1.CurrentRow.Cells["colUid"].Value);
+ if (defectInfo == null)
+ {
+ DialogResult dr = DialogResult.Cancel;
+ dr = FrmDialog.ShowDialog(this, "此记录已不存在!", "警告", true);
+ return;
+ }
+ this.pictureBox4.Image = (defectInfo.image);
+
+ //选中
+ this.Invoke(new System.Action(() =>
+ {
+ if (chart1.Series != null && chart1.Series.FindByName("SELECT") != null)
+ {
+ chart1.Series["SELECT"].Points.Clear();
+ chart1.Series["SELECT"].Points.AddXY(defectInfo.CentreX, defectInfo.CentreY / 100);
+ chart1.Refresh();
+ }
+ }));
+ }
+ #endregion
}
}
diff --git a/LeatherProject/GeBoShi/Main.resx b/LeatherProject/GeBoShi/Main.resx
index d084cc5..b6f73f1 100644
--- a/LeatherProject/GeBoShi/Main.resx
+++ b/LeatherProject/GeBoShi/Main.resx
@@ -431,10 +431,37 @@
b1AAAAAASUVORK5CYII=
-
+
True
-
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
True
@@ -443,4 +470,7 @@
597, 17
+
+ 743, 17
+
\ No newline at end of file
diff --git a/LeatherProject/GeBoShi/SysCtrl/ConfMgr.cs b/LeatherProject/GeBoShi/SysCtrl/ConfMgr.cs
index 921a990..6f02ccc 100644
--- a/LeatherProject/GeBoShi/SysCtrl/ConfMgr.cs
+++ b/LeatherProject/GeBoShi/SysCtrl/ConfMgr.cs
@@ -1,7 +1,10 @@
using MaiMuControl.SysStatusMgr.UserMgr;
+using Newtonsoft.Json.Linq;
+using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Data;
using System.IO;
using System.Linq;
using System.Text;
@@ -47,8 +50,6 @@ namespace GeBoShi.SysCtrl
private readonly string _rootPath;
private readonly string _configFile;
private readonly string _projectDir;
- private readonly string _pointsPath;
- private readonly string _markPicPath;
#endregion
private ConfMgr()
@@ -57,8 +58,6 @@ namespace GeBoShi.SysCtrl
_configFile = Path.Combine(_rootPath, "SysParamsConfig.ini");
_devConfigPath = Path.Combine(_rootPath, "DevParamsConfig.ini");
_projectDir = Path.Combine(_rootPath, "Project");
- _pointsPath = Path.Combine(_rootPath, "PointsConfig.ini");
- _markPicPath = Path.Combine(_rootPath, "MarkPic");
_specificationPath = Path.Combine(_rootPath, "革博士软件操作说明.docx");
DBConStr = "server = localhost; Database = LeatherDB; Uid = root; Pwd = " + ConteolUserDB.GetSqlDBCode() + "; AllowLoadLocalInfile = true;";
@@ -83,43 +82,20 @@ namespace GeBoShi.SysCtrl
//public string ProjectDir { get { return _projectDir; } }
public string ProjectDir { get { return SysConfigParams.ProductPath; } }
- public string MarkPicPath { get { return _markPicPath; } }
-
+ ///
+ /// 配置文件根路径
+ ///
+ public string ConfigDir { get { return _rootPath; } }
///
/// 说明书路径
///
public string SpecificationPath { get { return _specificationPath; } }
private string _specificationPath;
- ///
- /// 上料位X1
- ///
- public double LoadPoint_X1 { get; set; }
- ///
- /// 上料位X2
- ///
- public double LoadPoint_X2 { get; set; }
- ///
- /// 上料位Y
- ///
- public double LoadPoint_Y { get; set; }
- ///
- /// 上料位Z
- ///
- public double LoadPoint_Z { get; set; }
-
- ///
- /// 测厚气缸到位等待时间
- ///
- public int HeightDoWait { get; set; }
- ///
- /// 加紧气缸到位等待时间
- ///
- public int ProductDoWait { get; set; }
#endregion
#region 公开文件操作
-
+
#region 系统配置参数
///
/// 写入ini
@@ -162,6 +138,16 @@ namespace GeBoShi.SysCtrl
iniHelper.WriteString("Dev", "IODevName", SysParams.IODevName);
iniHelper.WriteString("Dev", "IOCfgPath", SysParams.IOCfgPath);
+ iniHelper.WriteString("Dev", "PLC_IP", SysParams.PLC_IP);
+ iniHelper.WriteInteger("Dev", "PLC_Rack", SysParams.PLC_Rack);
+ iniHelper.WriteInteger("Dev", "PLC_Solt", SysParams.PLC_Solt);
+ iniHelper.WriteString("Dev", "CamPath_1", SysParams.CamPath_1);
+ iniHelper.WriteInteger("Dev", "CamDev_1", SysParams.CamDev_1);
+ iniHelper.WriteInteger("Dev", "CamIndex_1", SysParams.CamIndex_1);
+ iniHelper.WriteString("Dev", "CamPath_2", SysParams.CamPath_2);
+ iniHelper.WriteInteger("Dev", "CamDev_2", SysParams.CamDev_2);
+ iniHelper.WriteInteger("Dev", "CamIndex_2", SysParams.CamIndex_2);
+
iniHelper.WriteString("Sys", "AIModelPath", SysParams.AIModelPath);
iniHelper.WriteString("Sys", "ProductPath", SysParams.ProductPath);
@@ -188,6 +174,24 @@ namespace GeBoShi.SysCtrl
iniHelper.WriteBool("ExcelPrint", "EnableExcelPrint", SysParams.EnableExcelPrint);
iniHelper.WriteString("ExcelPrint", "ExcelPrinterName", SysParams.ExcelPrinterName);
+ iniHelper.WriteString("ERP", "ErpDBConStr", SysParams.ErpDBConStr);
+ iniHelper.WriteString("ERP", "ErpSql", SysParams.ErpSql);
+
+ iniHelper.WriteString("Customer", "CustomerName", SysParams.CustomerName);
+
+ iniHelper.WriteBool("FLIP", "Cam1_flipX", SysParams.Cam1_flipX);
+ iniHelper.WriteBool("FLIP", "Cam1_flipY", SysParams.Cam1_flipY);
+ iniHelper.WriteBool("FLIP", "Cam2_flipX", SysParams.Cam2_flipX);
+ iniHelper.WriteBool("FLIP", "Cam2_flipY", SysParams.Cam2_flipY);
+
+ iniHelper.WriteInteger("CMPX", "Cm2px_x", SysParams.Cm2px_x);
+ iniHelper.WriteInteger("CMPX", "Cm2px_y", SysParams.Cm2px_y);
+ iniHelper.WriteInteger("CMPX", "MidCoin", SysParams.MidCoin);
+ iniHelper.WriteInteger("CMPX", "HolePx", SysParams.HolePx);
+ iniHelper.WriteInteger("CMPX", "LCrop", SysParams.LCrop);
+ iniHelper.WriteInteger("CMPX", "RCrop", SysParams.RCrop);
+ iniHelper.WriteInteger("CMPX", "Expand_pixel", SysParams.Expand_pixel);
+
SysConfigParams = SysParams;
}
///
@@ -208,6 +212,63 @@ namespace GeBoShi.SysCtrl
//iniHelper.ReadBool("SaveAllImg", "SaveAllImg", out bValue);
//sysParams.SaveAllImg = bValue;
+ iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue);
+ sysParams.OpenBuzzer = bValue;
+ iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue);
+ sysParams.OpenDoor = bValue;
+ iniHelper.ReadBool("SysFunction", "OpenIO", out bValue);
+ sysParams.OpenIO = bValue;
+ iniHelper.ReadBool("SysFunction", "OpenPLC", out bValue);
+ sysParams.OpenPLC = bValue;
+
+ iniHelper.ReadString("Dev", "LightCom", out sValue);
+ sysParams.LightCom = sValue.Replace("\0", "");
+ iniHelper.ReadInteger("Dev", "LightComBaud", out iValue);
+ sysParams.LightComBaud = iValue;
+ iniHelper.ReadString("Dev", "IODevName", out sValue);
+ sysParams.IODevName = sValue.Replace("\0", "");
+ iniHelper.ReadString("Dev", "IOCfgPath", out sValue);
+ sysParams.IOCfgPath = sValue.Replace("\0", "");
+ iniHelper.ReadString("Dev", "PLC_IP", out sValue);
+ sysParams.PLC_IP = sValue.Replace("\0", "");
+ iniHelper.ReadInteger("Dev", "PLC_Rack", out iValue);
+ sysParams.PLC_Rack = iValue;
+ iniHelper.ReadInteger("Dev", "PLC_Solt", out iValue);
+ sysParams.PLC_Solt = iValue;
+ iniHelper.ReadString("Dev", "CamPath_1", out sValue);
+ sysParams.CamPath_1 = sValue.Replace("\0", "");
+ iniHelper.ReadInteger("Dev", "CamDev_1", out iValue);
+ sysParams.CamDev_1 = iValue;
+ iniHelper.ReadInteger("Dev", "CamIndex_1", out iValue);
+ sysParams.CamIndex_1 = iValue;
+ iniHelper.ReadString("Dev", "CamPath_2", out sValue);
+ sysParams.CamPath_2 = sValue.Replace("\0", "");
+ iniHelper.ReadInteger("Dev", "CamDev_2", out iValue);
+ sysParams.CamDev_2 = iValue;
+ iniHelper.ReadInteger("Dev", "CamIndex_2", out iValue);
+ sysParams.CamIndex_2 = iValue;
+
+ iniHelper.ReadBool("CloudAndMES", "OpenCloud", out bValue);
+ sysParams.OpenCloud = bValue;
+ iniHelper.ReadString("CloudAndMES", "CloudThisName", out sValue);
+ sysParams.CloudThisName = sValue.Replace("\0", string.Empty);
+ iniHelper.ReadString("CloudAndMES", "CloudServerIP", out sValue);
+ sysParams.CloudServerIP = sValue;
+ iniHelper.ReadInteger("CloudAndMES", "CloudServerPort", out iValue);
+ sysParams.CloudServerPort = iValue;
+ iniHelper.ReadString("CloudAndMES", "CloudUser", out sValue);
+ sysParams.CloudUser = sValue;
+ iniHelper.ReadString("CloudAndMES", "CloudPassword", out sValue);
+ sysParams.CloudPassword = sValue;
+ iniHelper.ReadBool("CloudAndMES", "OpenPdtServer", out bValue);
+ sysParams.OpenPdtServer = bValue;
+ iniHelper.ReadString("CloudAndMES", "PdtServerIP", out sValue);
+ sysParams.PdtServerIP = sValue;
+ iniHelper.ReadInteger("CloudAndMES", "PdtServerPort", out iValue);
+ sysParams.PdtServerPort = iValue;
+ iniHelper.ReadBool("CloudAndMES", "IsPdtServer", out bValue);
+ sysParams.IsPdtServer = bValue;
+
iniHelper.ReadString("DefectSrcImag", "SavePath", out sValue);
sysParams.DefectSrcImag.SavePath = sValue.Replace("\0", "");
iniHelper.ReadBool("DefectSrcImag", "AutoSave", out bValue);
@@ -233,7 +294,13 @@ namespace GeBoShi.SysCtrl
iniHelper.ReadBool("DefectSplicImag", "AutoDelete", out bValue);
sysParams.DefectSplicImag.AutoDelete = bValue;
iniHelper.ReadDouble("DefectSplicImag", "AutoDeleteDays", out dValue);
- sysParams.DefectSplicImag.AutoDeleteDays = dValue;
+ sysParams.DefectSplicImag.AutoDeleteDays = dValue;
+
+
+ iniHelper.ReadString("Sys", "AIModelPath", out sValue);
+ sysParams.AIModelPath = sValue.Replace("\0", "");
+ iniHelper.ReadString("Sys", "ProductPath", out sValue);
+ sysParams.ProductPath = sValue.Replace("\0", "");
iniHelper.ReadString("Log", "SavePath", out sValue);
sysParams.LogPath = sValue.Replace("\0", "");
@@ -242,31 +309,6 @@ namespace GeBoShi.SysCtrl
iniHelper.ReadDouble("Log", "AutoDeleteDays", out dValue);
sysParams.AutoDeleteLogData = dValue;
- iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue);
- sysParams.OpenBuzzer = bValue;
- iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue);
- sysParams.OpenDoor = bValue;
- iniHelper.ReadBool("SysFunction", "OpenIO", out bValue);
- sysParams.OpenIO = bValue;
- iniHelper.ReadBool("SysFunction", "OpenPLC", out bValue);
- sysParams.OpenPLC = bValue;
-
- iniHelper.ReadString("Dev", "LightCom", out sValue);
- sysParams.LightCom = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Dev", "LightComBaud", out iValue);
- sysParams.LightComBaud = iValue;
-
- iniHelper.ReadString("Dev", "IODevName", out sValue);
- sysParams.IODevName = sValue.Replace("\0", "");
- iniHelper.ReadString("Dev", "IOCfgPath", out sValue);
- sysParams.IOCfgPath = sValue.Replace("\0", "");
-
- iniHelper.ReadString("Sys", "AIModelPath", out sValue);
- sysParams.AIModelPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "ProductPath", out sValue);
- sysParams.ProductPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "HttpServerIP", out sValue);
-
iniHelper.ReadBool("ShowMainWin", "ShowResetBtn", out bValue);
sysParams.ShowResetBtn = bValue;
iniHelper.ReadBool("ShowMainWin", "ShowBuzz", out bValue);
@@ -274,27 +316,30 @@ namespace GeBoShi.SysCtrl
iniHelper.ReadBool("ShowMainWin", "ShowDoorAlm", out bValue);
sysParams.ShowDoorAlm = bValue;
- iniHelper.ReadBool("CloudAndMES", "OpenCloud", out bValue);
- sysParams.OpenCloud = bValue;
- iniHelper.ReadString("CloudAndMES", "CloudThisName", out sValue);
- sysParams.CloudThisName = sValue.Replace("\0", string.Empty);
- iniHelper.ReadString("CloudAndMES", "CloudServerIP", out sValue);
- sysParams.CloudServerIP = sValue;
- iniHelper.ReadInteger("CloudAndMES", "CloudServerPort", out iValue);
- sysParams.CloudServerPort = iValue;
- iniHelper.ReadString("CloudAndMES", "CloudUser", out sValue);
- sysParams.CloudUser = sValue;
- iniHelper.ReadString("CloudAndMES", "CloudPassword", out sValue);
- sysParams.CloudPassword = sValue;
+ iniHelper.ReadBool("FLIP", "Cam1_flipX", out bValue);
+ sysParams.Cam1_flipX = bValue;
+ iniHelper.ReadBool("FLIP", "Cam1_flipY", out bValue);
+ sysParams.Cam1_flipY = bValue;
+ iniHelper.ReadBool("FLIP", "Cam2_flipX", out bValue);
+ sysParams.Cam2_flipX = bValue;
+ iniHelper.ReadBool("FLIP", "Cam2_flipY", out bValue);
+ sysParams.Cam2_flipY = bValue;
+
+ iniHelper.ReadInteger("CMPX", "Cm2px_x", out iValue);
+ sysParams.Cm2px_x = iValue;
+ iniHelper.ReadInteger("CMPX", "Cm2px_y", out iValue);
+ sysParams.Cm2px_y = iValue;
+ iniHelper.ReadInteger("CMPX", "MidCoin", out iValue);
+ sysParams.MidCoin = iValue;
+ iniHelper.ReadInteger("CMPX", "HolePx", out iValue);
+ sysParams.HolePx = iValue;
+ iniHelper.ReadInteger("CMPX", "LCrop", out iValue);
+ sysParams.LCrop = iValue;
+ iniHelper.ReadInteger("CMPX", "RCrop", out iValue);
+ sysParams.RCrop = iValue;
+ iniHelper.ReadInteger("CMPX", "Expand_pixel", out iValue);
+ sysParams.Expand_pixel = iValue;
- iniHelper.ReadBool("CloudAndMES", "OpenPdtServer", out bValue);
- sysParams.OpenPdtServer = bValue;
- iniHelper.ReadString("CloudAndMES", "PdtServerIP", out sValue);
- sysParams.PdtServerIP = sValue;
- iniHelper.ReadInteger("CloudAndMES", "PdtServerPort", out iValue);
- sysParams.PdtServerPort = iValue;
- iniHelper.ReadBool("CloudAndMES", "IsPdtServer", out bValue);
- sysParams.IsPdtServer = bValue;
iniHelper.ReadBool("LabelPrint", "EnableLabelPrint", out bValue);
sysParams.EnableLabelPrint = bValue;
@@ -304,7 +349,20 @@ namespace GeBoShi.SysCtrl
iniHelper.ReadBool("ExcelPrint", "EnableExcelPrint", out bValue);
sysParams.EnableExcelPrint = bValue;
iniHelper.ReadString("ExcelPrint", "ExcelPrinterName", out sValue);
- sysParams.ExcelPrinterName = sValue;
+ sysParams.ExcelPrinterName = sValue;
+
+ iniHelper.ReadString("ERP", "ErpDBConStr", out sValue);
+ sysParams.ErpDBConStr = sValue;
+ iniHelper.ReadString("ERP", "ErpSql", out sValue);
+ sysParams.ErpSql = sValue;
+
+ iniHelper.ReadString("Customer", "CustomerName", out sValue);
+ sysParams.CustomerName = sValue;
+
+ iniHelper.ReadString("Material", "SuedeList", out sValue);
+ if (!string.IsNullOrWhiteSpace(sValue))
+ sysParams.SuedeList = sValue.Split(new char[] { ',', ';' });
+
SysConfigParams = sysParams;
return sysParams;
@@ -532,6 +590,49 @@ namespace GeBoShi.SysCtrl
}
#endregion
+ #region ERP数据库
+ private SqlSugarClient db;
+
+ public SqlSugarClient getErpDBCon(SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer)
+ {
+ if (string.IsNullOrEmpty(SysConfigParams.ErpDBConStr))
+ return null;
+ if (db != null) return db;
+
+ db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = SysConfigParams.ErpDBConStr,
+ DbType = dbType,
+ IsAutoCloseConnection = true
+ },
+ db =>
+ {
+ db.Aop.OnLogExecuting = (sql, pars) =>
+ {
+ Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响
+
+ //获取原生SQL推荐 5.1.4.63 性能OK
+ //UtilMethods.GetNativeSql(sql,pars)
+
+ //获取无参数化SQL 对性能有影响,特别大的SQL参数多的,调试使用
+ //UtilMethods.GetSqlString(DbType.SqlServer,sql,pars)
+ };
+
+ });
+ return db;
+ }
+ public DataTable execSql(string sql, List parameters, SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer)
+ {
+ //查询表的所有
+ var mydb = getErpDBCon(dbType);
+ if (mydb == null) return null;
+
+ if (!mydb.Ado.IsValidConnection())
+ mydb.Ado.Open();
+ return mydb.Ado.GetDataTable(sql, parameters);
+ }
+ #endregion
+
#endregion
}
@@ -720,6 +821,23 @@ namespace GeBoShi.SysCtrl
/// 右侧裁剪
///
public int RCrop = 0;
+
+ ///
+ /// 相机1X翻转
+ ///
+ public bool Cam1_flipX { get; set; }
+ ///
+ /// 相机1Y翻转
+ ///
+ public bool Cam1_flipY { get; set; }
+ ///
+ /// 相机2X翻转
+ ///
+ public bool Cam2_flipX { get; set; }
+ ///
+ /// 相机2Y翻转
+ ///
+ public bool Cam2_flipY { get; set; }
#endregion
#region Http/MES
@@ -771,6 +889,29 @@ namespace GeBoShi.SysCtrl
public string ExcelPrinterName { get; set; }
#endregion
+ #region ERP
+ ///
+ /// 禾欣ERP数据库
+ ///
+ public string ErpDBConStr { get; set; }
+ ///
+ /// 禾欣ERP数据读取
+ ///
+ public string ErpSql { get; set; }
+ #endregion
+
+ #region 客户
+ ///
+ /// 客户名
+ ///
+ public string CustomerName { get; set; }
+ #endregion
+
+ #region 材质配合禾欣
+ //材质Material
+ public string[] SuedeList = new string[0];
+ #endregion
+
public SysConfigParams()
{
DefectSrcImag = new ImageSaveParam("D:\\Image\\DefectSrcImag");
@@ -825,6 +966,16 @@ namespace GeBoShi.SysCtrl
PdtServerIP = "127.0.0.1";
PdtServerPort = 10573;
IsPdtServer = true;
+
+ ErpDBConStr = "";
+ ErpSql = "";
+
+ CustomerName = "";
+
+ Cam1_flipX = false;
+ Cam1_flipY = false;
+ Cam2_flipX = false;
+ Cam2_flipY = false;
}
}
#endregion
diff --git a/LeatherProject/GeBoShi/SysCtrl/OpencvUtils.cs b/LeatherProject/GeBoShi/SysCtrl/OpencvUtils.cs
new file mode 100644
index 0000000..79c47ba
--- /dev/null
+++ b/LeatherProject/GeBoShi/SysCtrl/OpencvUtils.cs
@@ -0,0 +1,463 @@
+using OpenCvSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeBoShi.SysCtrl
+{
+ public static class OpencvUtils
+ {
+ public static int image_width = 2048;
+ public static int image_height = 2048;
+ #region 图像预处理
+ public static Mat Resize(Mat mat, int width, int height, out int xw)
+ {
+ OpenCvSharp.Size dsize = new OpenCvSharp.Size(width, height);
+ Mat mat2 = new Mat();
+ //Cv2.Resize(mat, mat2, dsize);
+ ResizeUniform(mat, dsize, out mat2, out xw);
+ return mat2;
+ }
+ ///
+ /// 等比例缩放
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static int ResizeUniform(Mat src, Size dst_size, out Mat dst, out int xw)
+ {
+ xw = 0;
+ int w = src.Cols;
+ int h = src.Rows;
+ int dst_w = dst_size.Width;
+ int dst_h = dst_size.Height;
+ //std::cout << "src: (" << h << ", " << w << ")" << std::endl;
+ dst = new Mat(dst_h, dst_w, MatType.CV_8UC3, new Scalar(114, 114, 114));
+
+ float[] ratio = new float[2];
+ float ratio_src = w * 1.0f / h;
+ float ratio_dst = dst_w * 1.0f / dst_h;
+
+ int tmp_w = 0;
+ int tmp_h = 0;
+ if (ratio_src > ratio_dst)
+ {
+ tmp_w = dst_w;
+ tmp_h = (int)(dst_w * 1.0f / w) * h;
+
+ ratio[0] = (float)w / (float)tmp_w;
+ ratio[1] = (float)h / (float)tmp_h;
+ }
+ else if (ratio_src < ratio_dst)
+ {
+ tmp_h = dst_h;
+ tmp_w = (int)((dst_h * 1.0f / h) * w);
+
+ ratio[0] = (float)w / (float)tmp_w;
+ ratio[1] = (float)h / (float)tmp_h;
+ }
+ else
+ {
+ Cv2.Resize(src, dst, dst_size);
+
+ ratio[0] = (float)w / (float)tmp_w;
+ ratio[1] = (float)h / (float)tmp_h;
+ return 0;
+ }
+
+ //std::cout << "tmp: (" << tmp_h << ", " << tmp_w << ")" << std::endl;
+ Mat tmp = new Mat();
+ Cv2.Resize(src, tmp, new Size(tmp_w, tmp_h));
+
+ unsafe
+ {
+ if (tmp_w != dst_w)
+ { //高对齐,宽没对齐
+ int index_w = (int)((dst_w - tmp_w) / 2.0);
+ xw = index_w;
+ //std::cout << "index_w: " << index_w << std::endl;
+ for (int i = 0; i < dst_h; i++)
+ {
+ Buffer.MemoryCopy(IntPtr.Add(tmp.Data, i * tmp_w * 3).ToPointer(), IntPtr.Add(dst.Data, i * dst_w * 3 + index_w * 3).ToPointer(), tmp_w * 3, tmp_w * 3);
+ }
+ }
+ else if (tmp_h != dst_h)
+ { //宽对齐, 高没有对齐
+ int index_h = (int)((dst_h - tmp_h) / 2.0);
+ //std::cout << "index_h: " << index_h << std::endl;
+ Buffer.MemoryCopy(tmp.Data.ToPointer(), IntPtr.Add(dst.Data, index_h * dst_w * 3).ToPointer(), tmp_w * tmp_h * 3, tmp_w * tmp_h * 3);
+ }
+ else
+ {
+ }
+ }
+ return 0;
+ }
+ public static Mat ResizeMat(Mat mat, int width, int height)
+ {
+ OpenCvSharp.Size dsize = new OpenCvSharp.Size(width, height);
+ Mat mat2 = new Mat();
+ Cv2.Resize(mat, mat2, dsize);
+ return mat2;
+ }
+
+ ///
+ /// 计算合理宽幅
+ ///
+ /// 多个相机图像总宽(外部去除重合部分)
+ ///
+ public static int GetWidthForResize(int sumWidth)
+ {
+ //保证计算8x2 16个小图
+ int count = (int)Math.Round(sumWidth * 1.0f / image_width, 0);
+ count = 8;
+ return count * image_width;
+
+ //int count = sumWidth / image_width;
+ ////int remainder = sumWidth % image_width;
+ //if (count % 2 == 0)
+ // return count * image_width;
+ //else
+ // return count * image_width+ image_width;
+ }
+ ///
+ /// 裁切指定区域
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Mat CutImage(Mat mat, int x, int y, int width, int height)
+ {
+ Rect roi = new Rect(x, y, width, height);
+ return new Mat(mat, roi).Clone();
+ }
+ #endregion
+
+ #region 裁边
+ ///
+ /// 裁边
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Mat getMaxInsetRect2(Mat mat_rgb, bool isLeft, int marginHoleWidth, out int marginWidth)
+ {
+ int bian = 3500;
+ Rect Roi;
+ if (!isLeft)
+ Roi = new Rect(mat_rgb.Width - bian, 0, bian, mat_rgb.Height);
+ else
+ Roi = new Rect(0, 0, bian, mat_rgb.Height);
+ int type = isLeft ? 1 : 0;
+ int len = EdgeClipping2(mat_rgb, type, Roi, isLeft);
+#if false
+ //Mat mat_rgb = new Mat("E:\\CPL\\测试代码\\边缘检测\\test\\test\\test\\img\\19.bmp");
+ Mat image_gray = new Mat();
+ Cv2.CvtColor(mat_rgb, image_gray, ColorConversionCodes.BGR2GRAY);
+ //cvtColor(image_RGB, image, COLOR_RGB2GRAY);
+ int height = image_gray.Rows;
+ int width = image_gray.Cols;
+
+ // 算法定义:取均分5段图片的五条横线,经过一系列处理之后,二值化,找到沿边位置,然后取均值作为直边,在缩进一段有针眼的位置
+ // 定义每段的行数
+ int num_rows = 5;
+ int segment_height = height / num_rows - 1;
+
+ // 定义空数组保存结果
+ int[] total = new int[num_rows];
+
+ // 平均截取5行数据并处理图像
+ for (int i = 0; i < num_rows; i++)
+ {
+ // 截取当前行的图像
+ int start_row = i * segment_height;
+ Rect roi = new Rect(0, start_row, width, 1);
+ Mat current_segment = image_gray.Clone(roi);
+
+ // 对当前行的图像进行平滑处理
+ Mat smoothed_image = new Mat();
+ Cv2.GaussianBlur(current_segment, smoothed_image, new Size(5, 1), 0);
+
+ // 计算当前行的灰度直方图
+ Mat absolute_histo = new Mat();
+ Cv2.CalcHist(new Mat[] { smoothed_image }, new int[] { 0 }, new Mat(), absolute_histo, 1, new int[] { 256 }, new Rangef[] { new Rangef(0, 256) });
+ Cv2.GaussianBlur(current_segment, smoothed_image, new Size(19, 1), 0);
+
+ // 对图片进行分割i+1
+ //double otsu_threshold;
+ //threshold(smoothed_image, smoothed_image, 0, 255, THRESH_BINARY + THRESH_OTSU, &otsu_threshold);
+ Cv2.Threshold(smoothed_image, smoothed_image, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
+
+ // 使用形态学操作进行孔洞填充
+ Mat kernel = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(25, 1));
+ Mat filled_image = new Mat();
+ Cv2.MorphologyEx(smoothed_image, filled_image, MorphTypes.Close, kernel);
+
+ // 取较长的一个值作为皮革的宽度
+ int num_255 = Cv2.CountNonZero(filled_image);
+ int length_t = (num_255 > width / 2) ? num_255 : width - num_255;
+ total[i] = (length_t);
+ API.OutputDebugString($"getMaxInsetRect2: 【{i + 1}】{length_t}={num_255}|{width}");
+ }
+ // 取平均值作为宽度
+ int length = (int)total.Average();
+ marginWidth = width-length;
+#endif
+ int length = (len > mat_rgb.Width / 2) ? len : mat_rgb.Width - len;
+ marginWidth = mat_rgb.Width - length;
+ // 判断数据是否异常,判断当前线段的宽度是否大于设定像素的偏差
+ //int abnormal_pxl = 200;
+ //for (int i = 0; i < num_rows; i++)
+ //{
+ // if (Math.Abs(total[i] - length) > abnormal_pxl)
+ // throw new Exception("数据异常,当段图片的宽度有问题!");
+ //}
+
+ //右侧相机,拍摄产品,边缘位于右侧判断,缩进100像素,去点针眼
+ //Cv2.Line(mat_rgb, new Point(length - 100, 0), new Point(length - 100, height), new Scalar(255, 0, 0), 20);
+ ////左侧相机,拍摄产品,边缘位于左侧判断,缩进100像素,去点针眼
+ //Cv2.Line(mat_rgb, new Point(width - length + 100, 0), new Point(width - length + 100, height), new Scalar(0, 255, 0), 20);
+
+ //int decWidth = width - length + marginHoleWidth;
+ //if (isLeft)
+ // return cutImage(mat_rgb, decWidth, 0, width- decWidth, height);
+ //else
+ // return cutImage(mat_rgb, 0, 0, width - decWidth, height);
+
+ //API.OutputDebugString($"getMaxInsetRect2:margin={marginWidth},length={length}({marginHoleWidth}),isLeft={isLeft},mat_rgb={mat_rgb.Width}*{mat_rgb.Height},w={length - marginHoleWidth},h={mat_rgb.Height}");
+ if (isLeft)
+ return CutImage(mat_rgb, mat_rgb.Width - length + marginHoleWidth, 0, length - marginHoleWidth, mat_rgb.Height);
+ else
+ return CutImage(mat_rgb, 0, 0, length - marginHoleWidth, mat_rgb.Height);
+ }
+
+ ///
+ /// 寻边算法
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static int EdgeClipping2(Mat image, int FindType, Rect Roi, bool IsLeft)
+ {
+ DateTimeOffset startTime = DateTimeOffset.Now;
+ Mat mat_rgb = image.Clone(Roi);
+ int height = mat_rgb.Rows;
+ int width = mat_rgb.Cols;
+ int sf = 10; //缩放比例
+ int pix = 5; //获取均值区域长宽像素
+ int pointNum = 15; //获取找遍点数
+ int offsetGray = 5; //二值化偏差
+
+ //按比例缩放
+ int sf_height = height / sf;
+ int sf_width = width / sf;
+ Cv2.Resize(mat_rgb, mat_rgb, new Size(sf_width, sf_height), 0, 0, InterpolationFlags.Linear);
+ Mat himg = new Mat();
+ himg = mat_rgb.Clone();
+ DateTimeOffset endTime = DateTimeOffset.Now;
+ //Console.WriteLine("图片缩小(ms): " + (endTime - startTime).TotalMilliseconds.ToString("0.000"));
+ startTime = DateTimeOffset.Now;
+
+ //滤过去除多余噪声
+ //Cv2.EdgePreservingFilter(himg, himg, EdgePreservingMethods.NormconvFilter);
+ //Cv2.PyrMeanShiftFiltering(himg, himg, 1, 2, 1);
+ Cv2.PyrMeanShiftFiltering(himg, himg, 10, 17, 2);
+ //himg.ImWrite("himg.jpg");
+ endTime = DateTimeOffset.Now;
+ //Console.WriteLine("滤过去除多余噪声(ms): " + (endTime - startTime).TotalMilliseconds.ToString("0.000"));
+
+ startTime = DateTimeOffset.Now;
+ //转灰度图
+ Mat image_gray = new Mat();
+ Cv2.CvtColor(himg, image_gray, ColorConversionCodes.BGR2GRAY);
+ //image_gray.ImWrite("image_gray.jpg");
+
+ Mat image_Canny = new Mat();
+ Cv2.Canny(image_gray, image_Canny, 32, 64);
+ //image_Canny.ImWrite("image_Canny.jpg");
+
+
+ //二值化
+ Mat image_Otsu = new Mat();
+ int hDis = sf_height / (pointNum + 2); //去除边缘两点
+#if false //二值算法
+ List LeftAvg = new List();
+ List RightAvg = new List();
+ //double thb = Cv2.Threshold(image_gray, image_Otsu, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
+ #region 多点获取二值化均值
+ for (int i = 0; i < pointNum; i++)
+ {
+ Rect roiLeft = new Rect(0, hDis + hDis * i, pix, pix);
+ Mat current_segmentL = image_gray.Clone(roiLeft);
+ //Scalar ttr = current_segmentL.Mean();
+ LeftAvg.Add(current_segmentL.Mean().Val0);
+
+ Rect roiRight = new Rect(sf_width - pix, hDis + hDis * i, pix, pix);
+ Mat current_segmentR = image_gray.Clone(roiRight);
+ RightAvg.Add(current_segmentR.Mean().Val0);
+ }
+ double thres = 0;
+ if (IsLeft)
+ {
+ if (LeftAvg.Average() > RightAvg.Average())
+ thres = RightAvg.Max() + offsetGray;
+ else
+ thres = RightAvg.Min() - offsetGray;
+ }
+ else
+ {
+ if (LeftAvg.Average() > RightAvg.Average())
+ thres = LeftAvg.Min() - offsetGray;
+ else
+ thres = LeftAvg.Max() + offsetGray;
+ }
+ //double thres = (RightAvg.Average() + )/2;
+ #endregion
+#endif
+#if false
+ double min, max;
+
+ image_gray.MinMaxLoc(out min, out max);
+ double thres = (min + max) / 2;
+#endif
+
+#if false //二值化图片
+ //Cv2.Threshold(image_gray, image_Otsu, 0, 255, ThresholdTypes.Otsu);
+ double thb = Cv2.Threshold(image_gray, image_Otsu, thres, 255, ThresholdTypes.Binary);
+ image_Otsu.ImWrite("Otsu1.jpg");
+ Cv2.MedianBlur(image_Otsu, image_Otsu, 21);
+ image_Otsu.ImWrite("Otsu2.jpg");
+ endTime = DateTimeOffset.Now;
+ Console.WriteLine("灰度图二值化(ms): " + (endTime - startTime).TotalMilliseconds.ToString("0.000"));
+ startTime = DateTimeOffset.Now;
+#else
+ image_Otsu = image_Canny;
+#endif
+ // 定义空数组保存结果
+ int[] total = new int[pointNum];
+ List total_t = new List();
+ bool isLeft = FindType == 0 ? true : false;
+ // 平均截取pointNum行数据并处理图像
+ for (int i = 0; i < pointNum; i++)
+ {
+ // 截取当前行的图像
+ Rect roi = new Rect(0, hDis + hDis * i, sf_width, 1);
+ Mat current_segment = image_Otsu.Clone(roi);
+
+#if false
+ #region 预处理
+ // 对当前行的图像进行平滑处理
+ Mat smoothed_image2 = new Mat();
+ Cv2.GaussianBlur(current_segment, smoothed_image2, new Size(5, 1), 0);
+
+ // 计算当前行的灰度直方图
+ Mat absolute_histo2 = new Mat();
+
+ Cv2.CalcHist(new Mat[] { smoothed_image2 }, new int[] { 0 }, new Mat(), absolute_histo2, 1, new int[] { 256 }, new Rangef[] { new Rangef(0, 256) });
+ Cv2.GaussianBlur(current_segment, smoothed_image2, new Size(9, 1), 0);
+
+ // 对图片进行分割
+ //double otsu_threshold;
+ //threshold(smoothed_image, smoothed_image, 0, 255, THRESH_BINARY + THRESH_OTSU, &otsu_threshold);
+ double otsu_threshold2 = Cv2.Threshold(smoothed_image2, smoothed_image2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
+
+ // 使用形态学操作进行孔洞填充
+ Mat kernel3 = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(5, 1));
+ Mat filled_image3 = new Mat();
+ Cv2.MorphologyEx(smoothed_image2, filled_image3, MorphTypes.Close, kernel3);
+ #endregion
+#else
+ //Mat filled_image3 = current_segment.Clone();
+ Mat filled_image3 = current_segment;
+#endif
+#if true
+ //从左到右判断边和从右到左判断边
+ int numX = 0;
+ byte tempVal = 0;
+ if (isLeft)
+ {
+ tempVal = filled_image3.At(0, 0);
+ for (int j = 0; j < filled_image3.Cols; j++)
+ {
+ if (filled_image3.At(0, j) != tempVal)
+ {
+ numX = j;
+ break;
+ }
+ }
+ }
+ else
+ {
+ tempVal = filled_image3.At(0, filled_image3.Cols - 1);
+ for (int j = filled_image3.Cols - 1; j >= 0; j--)
+ {
+ if (filled_image3.At(0, j) != tempVal)
+ {
+ numX = j;
+ break;
+ }
+ }
+ }
+#else
+ int numX = Cv2.CountNonZero(filled_image3);
+#endif
+ //int length_t = (numX > (sf_width / 2)) ? numX :sf_width - numX;
+ int length_t = numX;
+ total[i] = (length_t);
+ if (length_t > 0)
+ total_t.Add(length_t);
+ }
+
+
+ // 取平均值作为宽度
+ int length = 0;
+ if(total_t.Count> 0)
+ length = (int)total_t.Average();
+
+ endTime = DateTimeOffset.Now;
+ //Console.WriteLine("计算边(ms): " + (endTime - startTime).TotalMilliseconds.ToString("0.000"));
+
+ // 判断数据是否异常,判断当前线段的宽度是否大于设定像素的偏差
+ //int abnormal_pxl = 100 / 4;
+ //for (int i = 0; i < pointNum; i++)
+ //{
+ // if (Math.Abs(total[i] - length) > abnormal_pxl)
+ // Console.WriteLine("数据异常!");
+ // //出现数据异常,当段图片的宽度有问题
+ //}
+
+ //乘上换算系数还原
+ length = length * sf + Roi.X;
+ return length;
+ }
+ #endregion
+
+ #region 合并
+ ///
+ /// 合并MAT(宽高必需一致)
+ ///
+ ///
+ ///
+ ///
+ public static Mat MergeImage_sameSize(Mat[] mats, bool isHorizontal = true)
+ {
+ Mat matOut = new Mat();
+ if (isHorizontal)
+ Cv2.HConcat(mats, matOut);//横向拼接
+ else
+ Cv2.VConcat(mats, matOut);//纵向拼接
+ return matOut;
+ }
+ #endregion
+ }
+}
diff --git a/LeatherProject/GeBoShi/SysCtrl/SysEnum.cs b/LeatherProject/GeBoShi/SysCtrl/SysEnum.cs
index b54f747..898a4a9 100644
--- a/LeatherProject/GeBoShi/SysCtrl/SysEnum.cs
+++ b/LeatherProject/GeBoShi/SysCtrl/SysEnum.cs
@@ -24,48 +24,25 @@ namespace GeBoShi.SysCtrl
}
public enum DOName
{
- 三色灯红灯 = 0,
- 三色灯绿灯 = 1,
- 三色灯黄灯 = 2,
- 三色灯蜂鸣器 = 3,
+ 三色灯红灯 = 10,
+ 三色灯绿灯 = 11,
+ 三色灯黄灯 = 12,
+ 三色灯蜂鸣器 = 13,
+
+ 启动 = 0,
+ 复位 = 9,
+ 停止 = 1,
- 测厚气缸 = 4,
- 加紧气缸 = 5,
-
- 双手启动绿灯 = 7,
- 启动按钮绿灯 = 8,
- 复位按钮黄灯 = 9,
- 停止按钮红灯 = 10,
-
- 触发张力按钮灯 = 11,
-
- 日光灯 = 12,
-
- X1回原 = 13,
- X2回原 = 14,
-
- Y轴回原点 = 15
+ 日光灯 = 15,
}
public enum DIName
{
启动按钮 = 14,
- 暂停按钮 = 3,
+ 暂停按钮 = 1,
复位按钮 = 2,
- 触发张力 = 4,
-
- 产品有无 = 5,
-
- 右夹紧缩回 = 6,
- 右夹紧伸出 = 7,
- 前夹紧缩回 = 8,
- 前夹紧伸出 = 9,
- 侧推伸出 = 0,
- 侧推缩回 = 1,
-
- 双手启动 = 10,
+
门磁 = 11,
- Y轴回原点完成 = 15
}
}
diff --git a/LeatherProject/GeBoShi/SysCtrl/SysMgr.cs b/LeatherProject/GeBoShi/SysCtrl/SysMgr.cs
index 752282e..2c7a5e2 100644
--- a/LeatherProject/GeBoShi/SysCtrl/SysMgr.cs
+++ b/LeatherProject/GeBoShi/SysCtrl/SysMgr.cs
@@ -1,22 +1,41 @@
-using BarTenderPrint;
+#define Online
+using BarTenderPrint;
+using CCWin.Win32.Const;
using GeBoShi.ImageDefect;
+using HalconDotNet;
using HZH_Controls.Forms;
using MaiMuControl.Device;
+using MaiMuControl.Device.CamDev;
using MaiMuControl.Device.IOCardDev;
using MaiMuControl.Device.IOCardDev.Advantech;
using MaiMuControl.Device.LightDev;
using MaiMuControl.Device.LightDev.CST;
using MaiMuControl.Device.LightDev.Rsee;
+using MaiMuControl.Device.PlcDev;
using MaiMuControl.SysStatusMgr.CloudMgr;
using MaiMuControl.SysStatusMgr.StatusMgr;
using MaiMuControl.SysStatusMgr.UserMgr;
+using MaiMuControl.Utils;
+using Models;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using OpenCvSharp;
+using OpenCvSharp.Extensions;
+using S7.Net;
+using SqlSugar;
using System;
+using System.Collections;
using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
using ToolKits.Disk;
namespace GeBoShi.SysCtrl
@@ -71,7 +90,63 @@ namespace GeBoShi.SysCtrl
private List productIdList = new List();
public List ProductIdList { get { return productIdList; } }
- Service.ProductService PdtService = new Service.ProductService();
+ ///
+ /// 当前产品
+ ///
+ private Models.Product CurrProductModel = null;
+
+ //数据锁
+ private object lockCurrKey = new object();
+ //当前运行数据key
+ private int currKey = 0;
+ //线程管控
+ private Hashtable htTask = new Hashtable();//默认单线程写入不用lock, 多线程安全同步读取用Synchronized
+
+ //是否处理完成
+ private bool _isDefect = false;
+ //计算速度用,暂停时停止计数
+ private Stopwatch pStopWatch = new Stopwatch();
+
+ //图片队列
+ private int listCntMax = 5;
+ private int Cam1Cnt = 0;
+ private int Cam2Cnt = 0;
+ #region 处理类型
+ private class ScanPhotoInfo
+ {
+ ///
+ ///
+ ///
+ ///
+ /// 1-n 第1张会把1改为0
+ ///
+ public ScanPhotoInfo(int _devIndex, int _photoIndex, string _path)
+ {
+ devIndex = _devIndex;
+ photoIndex = _photoIndex;
+ path = _path;
+ }
+ public ScanPhotoInfo(int _devIndex, int _photoIndex, Mat _mat)
+ {
+ devIndex = _devIndex;
+ photoIndex = _photoIndex;
+ mat = _mat;
+ }
+ public int devIndex { get; set; }
+ ///
+ /// 0-n
+ ///
+ public int photoIndex { get; set; }
+ public string path { get; set; }
+ public Mat mat { get; set; }
+
+ }
+ #endregion
+ private Queue _matList1 = new Queue();
+ private Queue _matList2 = new Queue();
+
+ private Service.ProductService PdtService = new Service.ProductService();
+ private Service.RecordsService RecordService = new Service.RecordsService();
#endregion
#region 公开字段
@@ -96,6 +171,8 @@ namespace GeBoShi.SysCtrl
#region 私有流程
//主流程
private Thread _mainThread;
+ private Thread _Cam1Thread;
+ private Thread _Cam2Thread;
private CancellationTokenSource _cts;
#endregion
@@ -121,6 +198,10 @@ namespace GeBoShi.SysCtrl
init_Cloud = false;
cloudMgr = new CloudMgr();
DailyOutput = 0;
+
+ Service.InitDB.ConnectionString = confMgr.DBConStr;
+ PdtService = new Service.ProductService();
+ RecordService = new Service.RecordsService();
}
#region 本地云上传
@@ -254,6 +335,7 @@ namespace GeBoShi.SysCtrl
SendStatus();
//Thread.Sleep(200);
+
// 硬件初始化
if (!InitAllDev())
{
@@ -269,10 +351,9 @@ namespace GeBoShi.SysCtrl
}
InitLog("加载硬件驱动参数完成!");
//Thread.Sleep(200);
-
// 处理运行
InitLog("AI算法核心初始化...");
-
+ defectLib = new DefectLib();
if (!defectLib.start())
throw new Exception("外观检测核心初始化失败...");
InitLog("AI算法核心初始化完成!");
@@ -305,11 +386,15 @@ namespace GeBoShi.SysCtrl
///
public bool InitDefectEvent()
{
- defectLib.WarningEvent = (warning, msg) =>
+ if (defectLib != null)
{
- Log("缺陷检测", msg, warning);
- };
- return true;
+ defectLib.WarningEvent = (warning, msg) =>
+ {
+ Log("缺陷检测", msg, warning);
+ };
+ return true;
+ }
+ return false;
}
public bool InitCloudConnect()
@@ -339,6 +424,20 @@ namespace GeBoShi.SysCtrl
});
_mainThread.IsBackground = true;
_mainThread.Start();
+
+ _Cam1Thread = new Thread(() =>
+ {
+ Cam1ThreadFunction();
+ });
+ _Cam1Thread.IsBackground = true;
+ _Cam1Thread.Start();
+
+ _Cam2Thread = new Thread(() =>
+ {
+ Cam2ThreadFunction();
+ });
+ _Cam2Thread.IsBackground = true;
+ _Cam2Thread.Start();
}
#endregion
@@ -352,6 +451,200 @@ namespace GeBoShi.SysCtrl
return statusMgr.Status == SystemStsEnum.Pause || statusMgr.Warning == WarningEnum.High;
}
///
+ /// 相机1采图预处理
+ ///
+ private void Cam1ThreadFunction()
+ {
+ while (true)
+ {
+ try
+ {
+ if (_cts.IsCancellationRequested)
+ break;
+
+ if (IsRuning)
+ {
+ ////暂停开始
+ //stopWatch.Start();
+ do
+ {
+ #region 实时采图
+#if Online
+ //采集图片
+ Acquisition acq = _LinecamDev1.GetFrames(1, 10);
+ if (acq.GrabStatus == "GrabPass")
+ {
+ //显示
+ OnAutoRuning(new RunEventArgs(1, acq.Image));
+ lock (lockCurrKey)
+ {
+ //存在数据队列
+ if (currKey != 0 || htTask.ContainsKey(currKey))
+ {
+ Mat img = CamDev.HImageToMat(acq.Image.CopyObj(1, -1));
+ if (_matList1.Count > listCntMax)
+ {
+ _matList1.Dequeue();
+ System.GC.Collect();
+ }
+ //预处理
+ Stopwatch stopWatch = new Stopwatch();
+ Log($"图像预处理", $"相机1-{Cam1Cnt}");
+ string time = "";
+ stopWatch.Start();
+ int errStep = 0;
+ Mat mat = img;
+ try
+ {
+ errStep = 1;
+
+ //反转+相机索引调换
+
+ //裁边,两侧和中间重合部分
+ if (confMgr.SysConfigParams.MidCoin > 0)//中间重合部分
+ {
+ errStep = 3;
+ int width = mat.Width - confMgr.SysConfigParams.MidCoin / 2;
+ mat = OpencvUtils.CutImage(mat, 0, 0, width, mat.Height);
+ time += $"->相机1-去重({stopWatch.ElapsedMilliseconds})";
+ }
+ Log($"裁边", $"(相机1-图像{Cam1Cnt})-左图去重后:{mat.Width}*{mat.Height}," + $"重复值:{confMgr.SysConfigParams.MidCoin / 2}");
+ errStep = 4;
+ //左裁边
+ int marginWidth0;
+ mat = OpencvUtils.getMaxInsetRect2(mat, true, confMgr.SysConfigParams.HolePx, out marginWidth0);
+ errStep = 5;
+ time += $"->相机1裁边({stopWatch.ElapsedMilliseconds})";
+ }
+ catch (Exception e)
+ {
+ Log($"图像处理", $"异常({errStep}):(相机1-图像{Cam1Cnt})-{e.Message}", WarningEnum.High);
+ }
+ //Cv2.Flip(img, img, FlipMode.XY);//翻转
+ _matList1.Enqueue(new ScanPhotoInfo(0, Cam1Cnt++, mat.Clone()));
+ }
+ else
+ Log($"相机1", $"(图像)-未扫码,图像丢弃!", WarningEnum.Low);
+ }
+
+ }
+#endif
+ #endregion
+ Thread.Sleep(50);
+ } while (!isBreakProcessRun());
+ //暂停中断
+ //stopWatch.Stop();
+ pStopWatch.Stop();
+ //_isRuning = false;
+ }
+ Thread.Sleep(10);
+ }
+ catch (Exception e)
+ {
+ _isRuning = false;
+
+ Log("运行报警", "相机1流程运行出错:" + e.Message + "\n", WarningEnum.High);
+ }
+ }
+ }
+ ///
+ /// 相机2采图预处理
+ ///
+ private void Cam2ThreadFunction()
+ {
+ while (true)
+ {
+ try
+ {
+ if (_cts.IsCancellationRequested)
+ break;
+
+ if (IsRuning)
+ {
+ ////暂停开始
+ //stopWatch.Start();
+ do
+ {
+ #region 实时采图
+#if Online
+ //采集图片
+ Acquisition acq = _LinecamDev2.GetFrames(1, 10);
+ if (acq.GrabStatus == "GrabPass")
+ {
+ //显示
+ OnAutoRuning(new RunEventArgs(2, acq.Image));
+ lock (lockCurrKey)
+ {
+ //存在数据队列
+ if (currKey != 0 || htTask.ContainsKey(currKey))
+ {
+ Mat img = CamDev.HImageToMat(acq.Image.CopyObj(1, -1));
+ if (_matList2.Count > listCntMax)
+ {
+ _matList2.Dequeue();
+ System.GC.Collect();
+ }
+ //预处理
+ Stopwatch stopWatch = new Stopwatch();
+ Log($"图像预处理", $"相机2-{Cam2Cnt}");
+ string time = "";
+ stopWatch.Start();
+ int errStep = 0;
+ Mat mat = img;
+ try
+ {
+ errStep = 1;
+
+ //反转+相机索引调换
+
+ //裁边,两侧和中间重合部分
+ if (confMgr.SysConfigParams.MidCoin > 0)//中间重合部分
+ {
+ errStep = 3;
+ int width = mat.Width - confMgr.SysConfigParams.MidCoin / 2;
+ mat = OpencvUtils.CutImage(mat, confMgr.SysConfigParams.MidCoin / 2, 0, width, mat.Height);
+ time += $"->相机2-去重({stopWatch.ElapsedMilliseconds})";
+ }
+ Log($"裁边", $"(相机2-图像{Cam2Cnt})-右图去重后:{mat.Width}*{mat.Height}," + $"重复值:{confMgr.SysConfigParams.MidCoin / 2}");
+ errStep = 4;
+ //右裁边
+ int marginWidth0;
+ mat = OpencvUtils.getMaxInsetRect2(mat, false, confMgr.SysConfigParams.HolePx, out marginWidth0);
+ errStep = 5;
+ time += $"->相机2裁边({stopWatch.ElapsedMilliseconds})";
+ }
+ catch (Exception e)
+ {
+ Log($"图像处理", $"异常({errStep}):(相机2-图像{Cam2Cnt})-{e.Message}", WarningEnum.High);
+ }
+ //Cv2.Flip(img, img, FlipMode.XY);//翻转
+ _matList2.Enqueue(new ScanPhotoInfo(1, Cam2Cnt++, mat.Clone()));
+ }
+ else
+ Log($"相机2", $"(图像)-未扫码,图像丢弃!", WarningEnum.Low);
+ }
+
+ }
+#endif
+#endregion
+ Thread.Sleep(50);
+ } while (!isBreakProcessRun());
+ //暂停中断
+ //stopWatch.Stop();
+ pStopWatch.Stop();
+ //_isRuning = false;
+ }
+ Thread.Sleep(10);
+ }
+ catch (Exception e)
+ {
+ _isRuning = false;
+
+ Log("运行报警", "相机1流程运行出错:" + e.Message + "\n", WarningEnum.High);
+ }
+ }
+ }
+ ///
/// 后台运行主线程
///
private void MainThreadFunction()
@@ -367,13 +660,184 @@ namespace GeBoShi.SysCtrl
{
////暂停开始
//stopWatch.Start();
- //do
- //{
- // CurrProcessIndex = nextProcess(CurrProductModel, CurrProcessIndex);
- //} while (CurrProcessIndex >= 0 && !isBreakProcessRun());
- ////暂停中断
- //stopWatch.Stop();
+ do
+ {
+ #region 长度剩余提醒
+ //长度剩余提醒
+ Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
+ if (CurrProductModel.residueWarnningLen > 0 && curRecord.ErpLen > 0 && CurrProductModel.residueWarnningLen >= curRecord.ErpLen - curRecord.Len)
+ {
+ Log($"长度告警", $"已达剩余长度不足提醒!({curRecord.ErpLen - curRecord.Len}<={CurrProductModel.residueWarnningLen})", WarningEnum.Low);
+ }
+ #endregion
+ #region 处理2次判定
+ //处理2次判定
+ #endregion
+
+ #region 图像裁边预处理
+ //预处理,队列都有数据,且数据长度一致
+#if Online
+ if (_matList1.Count > 0 && _matList2.Count > 0 && (_matList1.Count == _matList2.Count))
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ ScanPhotoInfo scanPhotos0 = _matList1.Dequeue();
+ ScanPhotoInfo scanPhotos1 = _matList2.Dequeue();
+ Log($"图像拼接处理", $"相机1-{scanPhotos0.photoIndex},相机2-{scanPhotos1.photoIndex}");
+ string time = "";
+ stopWatch.Start();
+ int errStep = 0;
+ try
+ {
+ if (scanPhotos0.mat.Height != scanPhotos1.mat.Height)
+ {
+ Log($"警告", $"两相机采集图高度不一致({scanPhotos0.photoIndex}),dev1.Height={scanPhotos0.mat.Height},dev2.Height={scanPhotos1.mat.Height},重新resize...", WarningEnum.Low);
+ if (scanPhotos0.mat.Height > scanPhotos1.mat.Height)
+ scanPhotos1.mat = OpencvUtils.ResizeMat(scanPhotos1.mat, scanPhotos0.mat.Width, scanPhotos0.mat.Height);
+ else
+ scanPhotos0.mat = OpencvUtils.ResizeMat(scanPhotos0.mat, scanPhotos1.mat.Width, scanPhotos1.mat.Height);
+ }
+ errStep = 1;
+
+ //反转+相机索引调换
+ Mat mat0 = scanPhotos1.mat;
+ Mat mat1 = scanPhotos0.mat;
+
+ //水平合并l
+ Mat mat = OpencvUtils.MergeImage_sameSize(new Mat[] { mat0, mat1 });//这里相机反装,左右反转下
+ Log($"合并", $"(图像{scanPhotos0.photoIndex})-裁边去孔洞后:({mat0.Width}+{mat1.Width});合并后(去孔洞):{mat.Width}*{mat.Height}");
+ //float widthRatio = mat.Width * 1.0f / resize.Width;//宽度比例
+ time += $"->图1+2合并({stopWatch.ElapsedMilliseconds})";
+
+ //门幅更新(含两侧孔洞)x,y cm
+ float faceWidthX_cm = (float)Math.Round((scanPhotos0.photoIndex + 1) * mat.Height * 1.0f / confMgr.SysConfigParams.Cm2px_y, 2);
+ float faceWidthY_cm = (float)Math.Round((mat.Width + confMgr.SysConfigParams.HolePx * 2) * 1.0f / confMgr.SysConfigParams.Cm2px_x, 2);
+#else
+ string imgfilePath = "E:\\CPL\\测试代码\\革测试\\1-1\\现场原图";
+
+ if (!Directory.Exists(imgfilePath))
+ {
+ Log($"图像处理", $"模拟错误-路径错误{imgfilePath}", WarningEnum.High);
+ break;
+ }
+ string[] files = Directory.GetFiles(imgfilePath, $"*.bmp", SearchOption.TopDirectoryOnly);
+
+ if (files.Length > 0 && Cam1Cnt < files.Length)
+ {
+ Stopwatch stopWatch = new Stopwatch();
+
+ string time = "";
+ //stopWatch.Start();
+
+ ScanPhotoInfo scanPhotos0 = new ScanPhotoInfo(0, Cam1Cnt, new Mat(4096, 4096 * 2, MatType.CV_8UC3, new Scalar(0, 0, 0)));
+ ScanPhotoInfo scanPhotos1 = new ScanPhotoInfo(1, Cam1Cnt, new Mat(4096, 4096 * 2, MatType.CV_8UC3, new Scalar(0, 0, 0)));
+
+ stopWatch.Start();
+ int errStep = 0;
+ try
+ {
+ Log($"图像处理", $"模拟{files[Cam1Cnt]}");
+ Mat mat = new Mat(files[Cam1Cnt]);
+ Cam1Cnt++;
+ Mat mat0 = scanPhotos1.mat;
+ Mat mat1 = scanPhotos0.mat;
+
+ float faceWidthX_cm = (float)Math.Round((scanPhotos0.photoIndex + 1) * mat.Height * 1.0f / confMgr.SysConfigParams.Cm2px_y, 2);
+ float faceWidthY_cm = (float)Math.Round((mat.Width + confMgr.SysConfigParams.HolePx * 2) * 1.0f / confMgr.SysConfigParams.Cm2px_x, 2);
+#endif
+ //显示图片
+ OnAutoRuning(new RunEventArgs(mat.Clone()));
+
+ faceWidthX_cm = (float)Math.Round(faceWidthX_cm, 2);
+ faceWidthY_cm = (float)Math.Round(faceWidthY_cm, 2);
+ if (curRecord.FaceWidthMin == 0 || curRecord.FaceWidthMin > faceWidthY_cm)
+ curRecord.FaceWidthMin = faceWidthY_cm;
+ if (curRecord.FaceWidthMax < faceWidthY_cm)
+ curRecord.FaceWidthMax = faceWidthY_cm;
+ var point = new float[] { faceWidthX_cm, faceWidthY_cm };// new System.Drawing.PointF(faceWidthX_cm, faceWidthY_cm);
+ Log($"门幅", $"(图像{scanPhotos0.photoIndex})-({scanPhotos0.photoIndex})位置:{point[0]}; 幅宽:{point[1]}");
+ curRecord.FacePointList.Add(point);
+
+ //判定门幅
+ //if (x < XSizeRange[0])
+ // Log($"绘图", $"门幅宽度超限 1!!!! {x}<{XSizeRange[0]}", WarningEnum.High);
+ //if (x > XSizeRange[1])
+ // Log($"绘图", $"门幅宽度超限 2!!!! {x}>{XSizeRange[1]}", WarningEnum.High);
+ //if (item[1] < YSizeRange[0])
+ // Log($"绘图", $"门幅宽度超限 3!!!! {item[1]}<{YSizeRange[0]}", WarningEnum.High);
+ //if (item[1] > YSizeRange[1])
+ // Log($"绘图", $"门幅宽度超限 4!!!! {item[1]}>{YSizeRange[1]}", WarningEnum.High);
+
+ //显示门幅绘图
+ OnAutoRuning(new RunEventArgs(curRecord.FacePointList));
+ errStep = 7;
+ time += $"->门幅刷新({stopWatch.ElapsedMilliseconds})";
+ //去除两侧孔洞(门幅计算时不能去除)
+ //if (Config.MarginHoleWidth > 0)
+ // mat = OpenCVUtil.cutImage(mat, Config.MarginHoleWidth, 0, mat.Width - Config.MarginHoleWidth * 2, mat.Height);
+
+ //计算速度
+ double lenMi = Math.Round(faceWidthX_cm / 100, 2);
+ curRecord.Len = lenMi;
+ curRecord.TimeLen = pStopWatch.ElapsedMilliseconds / 1000.0d / 60.0d;//总时间 分
+ //显示速度
+ OnAutoRuning(new RunEventArgs(lenMi, Math.Round(lenMi / curRecord.TimeLen, 2)));
+
+ errStep = 9;
+ time += $"->速度刷新({stopWatch.ElapsedMilliseconds})";
+ //----缺陷队列
+ //比例缩放图片
+ int xw;
+ int resizeWidth = OpencvUtils.GetWidthForResize(mat0.Width + mat1.Width - confMgr.SysConfigParams.MidCoin);
+ if (resizeWidth == 0)
+ throw new Exception("GetWidthForResize result 0 失败!");
+ var resize = new System.Drawing.Size(resizeWidth, OpencvUtils.image_height * 2);//固定8192*2张*4096
+ mat = OpencvUtils.Resize(mat, resize.Width, resize.Height, out xw);
+ Log($"图像处理", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}");
+ defectLib.add(new DefectTask()
+ {
+ modelName = curRecord.ProductInfo.ModelName,
+ record = curRecord,
+ bmp = mat,
+ bmpTag = mat.Clone(),
+ photoIndex = scanPhotos0.photoIndex,//0-n 首张必需为0,因下面计算长度是从0开始
+ widthRatio = 1.0f,//等比例缩放,高度不变
+ qualifiedLimitList = curRecord.ProductInfo.QualifiedLimitList,
+ labelDic = GetDefectCode(),
+ finishEvent = callBackDefectEvent,
+ xw = xw,
+ cm2px_x = confMgr.SysConfigParams.Cm2px_x,
+ cm2px_y = confMgr.SysConfigParams.Cm2px_y,
+ expand_pixel = confMgr.SysConfigParams.Expand_pixel,
+ });
+ errStep = 10;
+ time += $"->加入瑕疵待检队列({stopWatch.ElapsedMilliseconds})";
+ }
+ catch (Exception ex)
+ {
+ curRecord.ScannerPhotoFinishCount++;//失败时不能因数量不一致无法保存
+ Log( $"图像处理", $"异常({errStep}):(图像{scanPhotos0.photoIndex})-{ex.Message}", WarningEnum.High);
+ //string dirPath = FileUtil.initFolder($"{Config.ImagePath}{curRecord.BatchId}_{curRecord.ReelId}\\Err\\");
+ //OpenCvSharp.Extensions.BitmapConverter.ToBitmap(scanPhotos0.mat).Save($"{dirPath}{scanPhotos0.photoIndex}_0_Step{errStep}.bmp", ImageFormat.Bmp);
+ //OpenCvSharp.Extensions.BitmapConverter.ToBitmap(scanPhotos1.mat).Save($"{dirPath}{scanPhotos1.photoIndex}_1_Step{errStep}.bmp", ImageFormat.Bmp);
+ }
+ finally
+ {
+ Log($"图像处理", $"(图像{scanPhotos0.photoIndex})-进度计时:{time}");
+ scanPhotos0.mat.Dispose();
+ scanPhotos1.mat.Dispose();
+ scanPhotos0 = scanPhotos1 = null;
+ //task = null;
+ System.GC.Collect();
+ }
+ }
+#endregion
+
+ Thread.Sleep(50);
+ } while (!isBreakProcessRun());
+ //暂停中断
+ //stopWatch.Stop();
+ pStopWatch.Stop();
_isRuning = false;
}
Thread.Sleep(10);
@@ -386,6 +850,317 @@ namespace GeBoShi.SysCtrl
}
}
}
+#endregion
+
+ #region 模型label
+ private JArray _defectItemList;
+ ///
+ /// 获取模型对应标签信息
+ ///
+ private void GetDefectAllLabel()
+ {
+ string labels = CurrProductModel.ModelName.Replace(".trt", ".json");
+ string configPath = confMgr.SysConfigParams.AIModelPath + $"\\{labels}";
+ string lsTmp = File.ReadAllText(configPath);
+ JArray defectItemList = JArray.Parse(lsTmp);
+ _defectItemList = defectItemList;
+ //var item = defectItemList.FirstOrDefault(m => m.Value("id") == id);
+ //if (item == null)
+ // return null;
+ //return (JObject)item;
+ }
+ ///
+ /// 根据id获取标签信息
+ ///
+ ///
+ ///
+ public JObject GetDefectLabel(int id)
+ {
+ if (_defectItemList != null && _defectItemList.Count > 0)
+ {
+ var item = _defectItemList.FirstOrDefault(m => m.Value("id") == id);
+ if (item == null)
+ return null;
+ return (JObject)item;
+ }
+ else
+ return null;
+ }
+ ///
+ /// 根据name获取标签信息
+ ///
+ ///
+ ///
+ public JObject GetDefectLabel(string name)
+ {
+ if (_defectItemList != null && _defectItemList.Count > 0)
+ {
+ var item = _defectItemList.FirstOrDefault(m => m.Value("name") == name);
+ if (item == null)
+ return null;
+ return (JObject)item;
+ }
+ else
+ return null;
+ }
+ public string GetDefectName(string code)
+ {
+ if (_defectItemList != null && _defectItemList.Count > 0)
+ {
+ var item = _defectItemList.FirstOrDefault(m => m.Value("code") == code);
+ if (item == null)
+ return null;
+ return item.Value("name");
+ }
+ else
+ return null;
+ }
+ public Dictionary GetDefectCode()
+ {
+ Dictionary dic = new Dictionary();
+ for (int i = 0; i < _defectItemList.Count; i++)
+ {
+ var tt = _defectItemList[i];
+ dic.Add(tt.Value("id"), tt.Value("code"));
+ }
+ return dic;
+ }
+ #endregion
+
+ #region 推理完成处理
+ private void callBackDefectEvent(DefectTask res)
+ {
+ {
+ int step = 0;
+ try
+ {
+ Log($"检测完成", $"图像队列:{res.record.ScannerPhotoFinishCount + 1}/{res.record.ScannerPhotoCount} (图像{res.photoIndex})检测结果:{res.isSucceed}");
+ //string dirPath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\");
+ //string dirSourcePath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\源图\\");
+ //Cv2.Flip(res.bmp, res.bmp, FlipMode.XY);//翻转
+ string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSrcImag.SavePath, new List { $"{ res.record.BatchId }_{ res.record.ReelId }" });
+ if (confMgr.SysConfigParams.DefectSrcImag.AutoSave)//保存所有原图
+ OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmp).Save($"{dirPath}+{res.photoIndex}.bmp", ImageFormat.Bmp);
+
+ if (res.isSucceed)
+ {
+ step = 1;
+ Log($"检测完成", $"(图像{res.photoIndex})-瑕疵检测完成,共{res.excelTable.Rows.Count}个瑕疵!各环节用时:{string.Join(",", res.stopwatch)}");
+ //AddTextEvent(DateTime.Now,$"打标完成", $"第 ({res.photoIndex}) 张照片,计算过程:{res.resultInfo}");
+ //if (!Config.IsSaveAllImage && Config.IsSaveDefectSourceImage)
+ // OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmp).Save($"{dirSourcePath}{res.photoIndex}.bmp", ImageFormat.Bmp);
+
+ step = 2;
+ if (res.excelTable.Rows.Count > 0)
+ {
+ res.record.dicPhoto_Defect[res.photoIndex] = true;//改为此图有瑕疵
+ //有瑕疵打标图必需保存 Jpeg
+ dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSplicImag.SavePath, new List { $"{res.record.BatchId}_{res.record.ReelId}" });
+ if (confMgr.SysConfigParams.DefectSplicImag.AutoSave)//保存瑕疵图
+ OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmpTag).Save($"{dirPath}{res.photoIndex}_tag.jpg", ImageFormat.Jpeg);
+ step = 3;
+ res.record.DefectTotalCount += res.excelTable.Rows.Count;
+ if (res.record.DefectInfoList == null)
+ res.record.DefectInfoList = new List();
+
+ step = 4;
+ JObject defectNameInfo;
+ DefectInfo defectInfo = null;
+ List