| | |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.Interface; |
| | | using Bro.Common.Model; |
| | | using Bro.DataBase.Model; |
| | | using Bro.M135.Common; |
| | | using Bro.M135.DBManager; |
| | | using HalconDotNet; |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } while (true); |
| | | |
| | | |
| | | var Defaultclass = M141Config.DefectClassCollection.FirstOrDefault(u => u.IsDefault); |
| | | productList.ForEach(p => |
| | | { |
| | | if (Defaultclass == null) |
| | | { |
| | | if (string.IsNullOrEmpty(p.Result)) |
| | | { |
| | | p.Result = "NG"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (string.IsNullOrEmpty(p.Result)) |
| | | { |
| | | p.Result = Defaultclass.ClassName; |
| | | } |
| | | } |
| | | var Defaultclass = M141Config.DefectClassCollection.FirstOrDefault(u => u.ClassName == productList[0].Result); |
| | | |
| | | Plc1.WriteSingleAddress(1526, p.Result.ToUpper().Contains("NG") ? 2 : 1, out _); |
| | | }); |
| | | if (M141Config.StationCode == "S4" && productList[0].Result == "OK") |
| | | { |
| | | ////mysqlhelper.GetS2Result(productList[0].SEQUENCE); |
| | | Plc1.WriteSingleAddress(1526, mysqlhelper.GetS2Result(productList[0].SEQUENCE) ? 1 : 2, out _); |
| | | } |
| | | else |
| | | { |
| | | Plc1.WriteSingleAddress(1526, Defaultclass?.ClassValue ?? 2, out _); |
| | | } |
| | | |
| | | Plc1.WriteSingleAddress(1516, 1, out _); |
| | | |
| | | return msg; |
| | |
| | | else |
| | | { |
| | | _isDemoStarted = true; |
| | | OfflineDemoAsync(opConfig.ImageFolder); |
| | | OfflineDemoAsync(opConfig.ImageFolder, opConfig.IsOK, opConfig.SaveImageTime); |
| | | } |
| | | } |
| | | |
| | | return new ResponseMessage(); |
| | | } |
| | | |
| | | private async void OfflineDemoAsync(string imageFolder) |
| | | private async void OfflineDemoAsync(string imageFolder, bool isok, int saveimagetime) |
| | | { |
| | | await Task.Run(() => |
| | | { |
| | |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var imageFile = Path.GetFileNameWithoutExtension(imageFileNames[i]); |
| | | if (imageFile.EndsWith("Fit")) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var nameDatas = imageFile.Split(new char[] { '_'}, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | if (imageFile.EndsWith("OK") & isok == false) |
| | | { |
| | | continue; |
| | | } |
| | | if (imageFile.EndsWith("NG") & isok == true) |
| | | { |
| | | continue; |
| | | } |
| | | var nameDatas = imageFile.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | if (nameDatas.Count != 5) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"文件{imageFile}命名不符合规范,不执行离线测试"); |
| | |
| | | } |
| | | |
| | | var sn = nameDatas[0]; |
| | | var imageSeq = nameDatas[1]; |
| | | |
| | | var imageSeq = nameDatas[2][^1].ToString(); |
| | | var measureBind = M141Config.MeasureBindCollection.FirstOrDefault(u => u.ImageSaveSeq == imageSeq); |
| | | |
| | | if (measureBind == null || !measureBind.IsFixed) |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"离线测试,工位{(measureBind == null ? "未匹配" : $"{measureBind.WorkPosition}未开启")}"); |
| | |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"离线测试,产品{sn}开始工位{measureBind.WorkPosition}离线检测"); |
| | | MLImageSet imgSet = new MLImageSet(); |
| | | |
| | | imgSet.HImage = new HalconDotNet.HImage(imageFileNames[i]); |
| | | imgSet.PID = sn; |
| | | |
| | | var detectResults = ML.RunMLDetectionSync(imgSet, null, measureBind.DetectionId); |
| | | |
| | | Thread.Sleep(saveimagetime); |
| | | imgSet.HImage?.Dispose(); |
| | | imgSet.HImage = null; |
| | | |
| | | |
| | | |
| | | //var defectFields = M141Config.DefectLocationSettings.FirstOrDefault(u => u.PositionCode == measureBind.WorkPosition); |
| | | |
| | | |
| | | //var list = detectResults.SelectMany(u => u.NetResults.SelectMany(m => m.DetectDetails)).ToList(); |
| | | ////if (list.Count > 0) |
| | | ////{ |
| | | //// //list.ForEach(d => |
| | | //// //{ |
| | | //// // //if (defectFields == null) |
| | | //// // //{ |
| | | //// // // d.Tag = ""; |
| | | //// // //} |
| | | //// // //else |
| | | //// // //{ |
| | | //// // // RectangleF rect = new RectangleF(d.Rect.Point_LU.X, d.Rect.Point_LU.Y, d.Rect.Width, d.Rect.Height); |
| | | //// // // //var rectList = defectFields.Display.RectDict.Where(u => rect.IntersectsWith(u.Value)).ToList(); |
| | | //// // // //if (rectList.Count > 0) |
| | | //// // // //{ |
| | | //// // // // d.Tag = string.Join(" ", rectList.Select(u => u.Key).OrderBy(u => u)); |
| | | //// // // //} |
| | | //// // // //else |
| | | //// // // //{ |
| | | //// // // // d.Tag = ""; |
| | | //// // // //} |
| | | //// // //} |
| | | //// //}); |
| | | ////} |
| | | |
| | | //Bitmap originImage = new Bitmap(imageFileNames[i]); |
| | | //DetectResultSaveExcelAsync(detectResults, sn, originImage, DateTime.Now); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | [ProcessMethod("printer", "printer", "打印机打印", InvokeType.TestInvoke)] |
| | |
| | | |
| | | UpdateDefectAsync(defects); |
| | | var defectClass = GetDefectClassFromDefectList(defects); |
| | | UpdateResult(DateTime.Now, p.SN, defectClass.ClassName, ""); |
| | | UpdateResult(DateTime.Now, p.SN, defectClass.ClassName, "", p.ImagePaths); |
| | | |
| | | //产品序号+1 |
| | | //Interlocked.Increment(ref _productIndex); |