From caf4dd3c752f5982adcd3708d2e8f976f81ff49f Mon Sep 17 00:00:00 2001 From: kingno <30263@KINGNO> Date: 星期一, 23 六月 2025 09:59:57 +0800 Subject: [PATCH] Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M200 --- src/Bro.M141.Process/M141Process.cs | 81 ++++++++++++++++++++++++++++------------ 1 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs index a68780c..3302e67 100644 --- a/src/Bro.M141.Process/M141Process.cs +++ b/src/Bro.M141.Process/M141Process.cs @@ -17,6 +17,7 @@ using ScottPlot.Drawing.Colormaps; using Sunny.UI; using Sunny.UI.Win32; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing.Imaging; @@ -52,7 +53,15 @@ //volatile int _productIndex = 0; - M141Process_Mysql mysqlhelper = new M141Process_Mysql(); + public M141Process_Mysql mysqlhelper = new M141Process_Mysql(); + + public event Action RerefreshBasketcodeUI; + + public void RerefreshBasketcode() + { + RerefreshBasketcodeUI?.Invoke(); + } + public override void InitialProcessMethods() @@ -111,7 +120,7 @@ _positionSpecHeads.Clear(); mysqlhelper.IniDBIP(M141Config.IPforall); - + RerefreshBasketcode(); } @@ -496,33 +505,58 @@ throw new Exception($"浜у搧{string.Join(",", pidList)}妫�娴媨measureBind.GetDisplayText()}鏈兘鑾峰彇鍥剧墖瀵硅薄"); } + RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); + RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); + //妫�娴嬮『搴� ML->鑷畾涔夋娴� if (!string.IsNullOrWhiteSpace(measureBind.DetectionId)) { string detectionName = (ML.InitialConfig as MLInitialConfigBase).DetectionConfigs.FirstOrDefault(u => u.Id == measureBind.DetectionId)?.Name; - //List<string> pidList2 = new List<string>();//pidList.Select(u => u.Split('_')[u.Split('_').Length - 1]).ToList(); - //Dictionary<string, string> dicpid = new Dictionary<string, string>(); - //for (int i = 0; i < pidList.Count; i++) - //{ - // var tem = pidList[i].Split('_')[pidList[i].Split('_').Length - 1]; - // pidList2.Add(tem); - // dicpid[tem] = pidList[i]; - //} + List<DetectResult> detectResults = ML?.RunMLDetectionSync(imgSet, pidList, measureBind.DetectionId, false, null, null, "", products[0].ImagePaths); - //var c=products[0].ImagePaths; - List<DetectResult> detectResults = ML?.RunMLDetectionSync(imgSet, pidList, measureBind.DetectionId,false,null,null,"", products[0].ImagePaths); + + + if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0) + { + var defecttem = detectResults.SelectMany(u => u.NetResults.SelectMany(m => m.DetectDetails)).Where(u => u.NetName == M141Config.defectname).ToList(); + List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE); + + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN} 杩涘叆S3S5妫�娴� S3鏁版嵁{Netdefectdetails.Count} S5鏁版嵁{defecttem.Count}"); + + int num = 0; + foreach (var item1 in defecttem) + { + double x1 = item1.Rect.Point_LU.X + item1.Rect.Width / 2.0; + double y1 = item1.Rect.Point_LU.Y + item1.Rect.Height / 2.0; + num++; + //HOperatorSet.AffineTransPoint2d(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + //HOperatorSet.ProjectiveTransPixel(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN}鍘熷潗鏍噞num} {x1},{y1}"); + HOperatorSet.ProjectiveTransPixel(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN}鏂板潗鏍噞num} {qx},{qy}"); + + + Netdefectdetail temc = new Netdefectdetail() + { + centerX = qx, + centerY = qy, + name = M141Config.defectname, + }; + if (Netdefectdetails.Any(u => u == temc)) + { + item1.IsAbandoned = false; + item1.FinalResult = ResultState.NG; + LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"浜у搧{products[0].PID}_{products[0].SEQUENCE}宸ヤ綅{measureBind.WorkPosition} S3S5缁勫悎妫�娴嬫鍑虹己闄�:{item1.NetName}"); + break; + } + } + } + List<DetectResult> ngResults = new List<DetectResult>(); - - - //for (int i = 0; i < detectResults.Count; i++) - //{ - // detectResults[i].PID = dicpid[detectResults[i].PID]; - //} - - detectResults.GroupBy(u => u.PID).ToList().ForEach(u => { if (u.ToList().Count > 0 && u.ToList().Any(m => m.ResultState != EnumHelper.ResultState.OK)) @@ -540,8 +574,7 @@ detectResults.AddRange(ngResults); resultList.AddRange(detectResults); } - RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); - RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); + } catch (Exception ex) { @@ -1130,7 +1163,7 @@ if (positionSet.IsLastPosition) { UpdateProductResultAsync(p); - mysqlhelper.NewForAll(p, M141Config.StationCode); + mysqlhelper.NewForAll(p, M141Config.StationCode, M141Config.defectname); if (M141Config.IsfinDevice) { SummaryAllprodata(p); @@ -1207,7 +1240,7 @@ newp.Details.AddRange(item.Details); } } - LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"AllDeviceProductRecord浠庢暟鎹簱鑾峰彇鍒版暟鎹畕p.SEQUENCE} plist鏁伴噺{plist.Count} Details鏁伴噺{newp.Details.Count}"); + //LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"AllDeviceProductRecord浠庢暟鎹簱鑾峰彇鍒版暟鎹畕p.SEQUENCE} plist鏁伴噺{plist.Count} Details鏁伴噺{newp.Details.Count}"); //newp.Details.AddRange(p.Details); -- Gitblit v1.8.0