diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/899271f3-95aa-460a-a98d-abb695a1e6f7.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/899271f3-95aa-460a-a98d-abb695a1e6f7.vsidx deleted file mode 100644 index 6db0a3d..0000000 Binary files a/LeatherProject/.vs/LeatherApp/FileContentIndex/899271f3-95aa-460a-a98d-abb695a1e6f7.vsidx and /dev/null differ diff --git a/LeatherProject/.vs/LeatherApp/FileContentIndex/dd9ae3d2-46dd-4b3a-b963-37aec66a90f0.vsidx b/LeatherProject/.vs/LeatherApp/FileContentIndex/dd9ae3d2-46dd-4b3a-b963-37aec66a90f0.vsidx new file mode 100644 index 0000000..4857360 Binary files /dev/null and b/LeatherProject/.vs/LeatherApp/FileContentIndex/dd9ae3d2-46dd-4b3a-b963-37aec66a90f0.vsidx differ diff --git a/LeatherProject/LeatherApp/Config.cs b/LeatherProject/LeatherApp/Config.cs index e964791..8933f6f 100644 --- a/LeatherProject/LeatherApp/Config.cs +++ b/LeatherProject/LeatherApp/Config.cs @@ -26,7 +26,7 @@ namespace LeatherApp public static Dictionary CMDProcess; //剩余N米提示(M) - public static int residueWarnningLen = 10; + public static int residueWarnningLen = 20; //瑕疵暂停跳过几张图 public static int defectPauseSkipPhotoCount=5; diff --git a/LeatherProject/LeatherApp/Device/DefectLib.cs b/LeatherProject/LeatherApp/Device/DefectLib.cs index 3911a22..6478f20 100644 --- a/LeatherProject/LeatherApp/Device/DefectLib.cs +++ b/LeatherProject/LeatherApp/Device/DefectLib.cs @@ -474,8 +474,8 @@ namespace LeatherApp.Device { if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "jietou") { - int max = stpoint.y + 500; - int min = stpoint.y - 500 > 0? stpoint.y - 500:0; + int max = stpoint.y + 2000; + int min = stpoint.y - 2000 > 0? stpoint.y - 2000 : 0; if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) { HeBingList.Add(DefectLabelInfoList[q]); @@ -487,8 +487,8 @@ namespace LeatherApp.Device } else if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "hengdang") { - int max = stpoint.y + 500; - int min = stpoint.y - 500 > 0 ? stpoint.y - 500 : 0; + int max = stpoint.y + 2000; + int min = stpoint.y - 2000 > 0 ? stpoint.y - 2000 : 0; if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) { HeBingList2.Add(DefectLabelInfoList[q]); @@ -500,8 +500,8 @@ namespace LeatherApp.Device } else if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "jt") { - int max = stpoint.y + 500; - int min = stpoint.y - 500 > 0 ? stpoint.y - 500 : 0; + int max = stpoint.y + 2000; + int min = stpoint.y - 2000 > 0 ? stpoint.y - 2000 : 0; if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) { HeBingList3.Add(DefectLabelInfoList[q]); @@ -513,8 +513,8 @@ namespace LeatherApp.Device } else if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "tcy") { - int max = stpoint.y + 500; - int min = stpoint.y - 500 > 0 ? stpoint.y - 500 : 0; + int max = stpoint.y + 2000; + int min = stpoint.y - 2000 > 0 ? stpoint.y - 2000 : 0; if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) { HeBingList4.Add(DefectLabelInfoList[q]); @@ -548,11 +548,12 @@ namespace LeatherApp.Device var edIt = HeBingList.Find(x => (x.i % colNum) * image_width + x.x == xPos.Max()); var eZXD = HeBingList.Find(x => x.confidence == ZXD.Max()); int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; + int newh = Math.Abs(((edIt.i / colNum) * image_hight + edIt.y) - ((stIt.i / colNum) * image_hight + stIt.y)) + edIt.h; outList.Add(new DefectLabelInfo() { x=stIt.x, y=edIt.y, w = newW, //多图叠加 - h = edIt.h, + h = newh, classId = eZXD.classId, confidence = eZXD.confidence, contrast = eZXD.contrast, @@ -569,12 +570,13 @@ namespace LeatherApp.Device var edIt = HeBingList2.Find(x => (x.i % colNum) * image_width + x.x == xPos2.Max()); var eZXD = HeBingList2.Find(x => x.confidence == ZXD2.Max()); int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; + int newh = Math.Abs(((edIt.i / colNum) * image_hight + edIt.y) - ((stIt.i / colNum) * image_hight + stIt.y)) + edIt.h; outList.Add(new DefectLabelInfo() { x = stIt.x, y = edIt.y, w = newW, //多图叠加 - h = edIt.h, + h = newh, classId = eZXD.classId, confidence = eZXD.confidence, contrast = eZXD.contrast, @@ -591,12 +593,13 @@ namespace LeatherApp.Device var edIt = HeBingList3.Find(x => (x.i % colNum) * image_width + x.x == xPos3.Max()); var eZXD = HeBingList3.Find(x => x.confidence == ZXD3.Max()); int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; + int newh = Math.Abs(((edIt.i / colNum) * image_hight + edIt.y) - ((stIt.i / colNum) * image_hight + stIt.y)) + edIt.h; outList.Add(new DefectLabelInfo() { x = stIt.x, y = edIt.y, w = newW, //多图叠加 - h = edIt.h, + h = newh, classId = eZXD.classId, confidence = eZXD.confidence, contrast = eZXD.contrast, @@ -613,12 +616,13 @@ namespace LeatherApp.Device var edIt = HeBingList4.Find(x => (x.i % colNum) * image_width + x.x == xPos4.Max()); var eZXD = HeBingList4.Find(x => x.confidence == ZXD4.Max()); int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; + int newh = Math.Abs(((edIt.i / colNum) * image_hight + edIt.y) - ((stIt.i / colNum) * image_hight + stIt.y)) + edIt.h; outList.Add(new DefectLabelInfo() { x = stIt.x, y = edIt.y, w = newW, //多图叠加 - h = edIt.h, + h = newh, classId = eZXD.classId, confidence = eZXD.confidence, contrast = eZXD.contrast, diff --git a/LeatherProject/LeatherApp/Page/FHome.Designer.cs b/LeatherProject/LeatherApp/Page/FHome.Designer.cs index f8b2cc7..72409d4 100644 --- a/LeatherProject/LeatherApp/Page/FHome.Designer.cs +++ b/LeatherProject/LeatherApp/Page/FHome.Designer.cs @@ -448,6 +448,7 @@ this.button1.TabIndex = 1; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; + this.button1.Visible = false; this.button1.Click += new System.EventHandler(this.button1_Click); // // btnPause diff --git a/LeatherProject/LeatherApp/Page/FHome.cs b/LeatherProject/LeatherApp/Page/FHome.cs index 8ea6408..6e4cb23 100644 --- a/LeatherProject/LeatherApp/Page/FHome.cs +++ b/LeatherProject/LeatherApp/Page/FHome.cs @@ -62,6 +62,8 @@ namespace LeatherApp.Page //云端 private CloudMgr cloudMgr = new CloudMgr(); private bool init_Cloud; + // + private bool _residueWarnningLenStop; public FHome(FProductInfo frm) { InitializeComponent(); @@ -742,6 +744,8 @@ namespace LeatherApp.Page errCode = 4; var now = DateTime.Now; currKey = now.Hour * 10000 + now.Minute * 100 + now.Second; + + _residueWarnningLenStop = false; //var materialItem = codes[0]+"-"+ codes[1]; var colorItem = Config.getColorItem(int.Parse(codes[2])); record = new Records() @@ -1078,7 +1082,33 @@ namespace LeatherApp.Page if (Config.residueWarnningLen > 0 && curRecord.ErpLen > 0 && Config.residueWarnningLen >= curRecord.ErpLen - curRecord.Len) { AddTextEvent(DateTime.Now, $"告警{Thread.CurrentThread.ManagedThreadId}", $"已达剩余长度不足提醒!({curRecord.ErpLen - curRecord.Len}<={Config.residueWarnningLen})", WarningEnum.High); - //warning(WarningEnum.Low, true);//暂停 + + #region 剩余提示暂停 + if (!_residueWarnningLenStop) + { + _residueWarnningLenStop = true; + AddTextEvent(DateTime.Now, $"暂停{Thread.CurrentThread.ManagedThreadId}", $"已达剩余长度不足提醒!({curRecord.ErpLen - curRecord.Len}<={Config.residueWarnningLen}),进入暂停。"); + if (!Config.StopPLC) + this.devContainer.devPlc.pauseDev(); + else if (!Config.StopIO && devContainer.devIOCard.IsInit) + { + //只是设备暂停,APP没暂停 + devContainer.io_output(CMDName.绿灯输出, false, true, 0); + devContainer.io_output(CMDName.黄灯输出); + devContainer.devIOCard.writeBitState(0, 1, true); + Task.Run(async () => + { + await Task.Delay(500); + this.devContainer.devIOCard.writeBitState(0, 1, false); + }); + } + this.BeginInvoke(new System.Action(() => + { + //warning(WarningEnum.Low, true);//暂停 + MessageBox.Show($"已达剩余长度不足提醒!({curRecord.ErpLen - curRecord.Len}<={Config.residueWarnningLen}),进入暂停。", "警告",MessageBoxButtons.OK, MessageBoxIcon.Warning); + })); + } + #endregion } errStep = 6; //厚度检测提示 @@ -1526,7 +1556,7 @@ namespace LeatherApp.Page //----缺陷队列 int oxw, oxh; mat = OpenCVUtil.resize(mat, resize.Width, resize.Height, out oxw, out oxh); - AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}", WarningEnum.Low, false); + AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}-{oxw}*{oxh}", WarningEnum.Low, false); devContainer.libDefect.add(new Device.DefectLib.DefectTask() { modelName= curRecord.ProductInfo.ModelName, diff --git a/LeatherProject/LeatherApp/Page/FProductInfo.cs b/LeatherProject/LeatherApp/Page/FProductInfo.cs index fe7bdb3..c76b449 100644 --- a/LeatherProject/LeatherApp/Page/FProductInfo.cs +++ b/LeatherProject/LeatherApp/Page/FProductInfo.cs @@ -196,6 +196,8 @@ namespace LeatherApp.Page numDefectCountLimit.Text = model.DefectCountLimit.ToString(); swcDefectPauseForUser.Active = model.DefectPauseForUser; + this.uiSwitch1.Active = model.OpenThicknessDetection; + uiNumPadTextBox1.Text = model.ThicknessDetectionStopDis.ToString(); //uiDataGridView fill string code; QualifiedLimit item1; diff --git a/LeatherProject/LeatherApp/Utils/OpenCVUtil.cs b/LeatherProject/LeatherApp/Utils/OpenCVUtil.cs index 58774f5..220a2c1 100644 --- a/LeatherProject/LeatherApp/Utils/OpenCVUtil.cs +++ b/LeatherProject/LeatherApp/Utils/OpenCVUtil.cs @@ -162,7 +162,8 @@ namespace LeatherApp.Utils //Cv2.Resize(mat, mat2, dsize); //ResizeUniform(mat, dsize, out mat2, out xw, out xh); - xw = xh = 0; + xw = (width - mat.Cols) / 2; + xh = (height - mat.Rows) / 2; Mat mat2 = new Mat(height, width, MatType.CV_8UC3, new Scalar(114, 114, 114)); Rect roi = new Rect((width - mat.Cols) / 2, (height - mat.Rows) / 2, mat.Cols, mat.Rows); mat.CopyTo(new Mat(mat2, roi));