private static void Cam1AutoProcess() { while (Cam1AcqThread.IsAlive || Cam1ImageQueue.Count > 0) { if (Cam1ImageQueue.Count > 0) { SortedList <string, string> rs = RunCam1Program(Cam1ImageQueue.Dequeue()); if (Cam1ResultAvailable != null) { Cam1ResultAvailable(null, new VisionResultAvailableEventArgs(Tb1.CreateLastRunRecord(), rs)); } } } }
public static SortedList <string, string> RunCam1Program(ICogImage iCogImage) { WriteBlockInput(Tb1, "Image", iCogImage); Tb1.Run(); Tb1.CreateLastRunRecord(); SortedList <string, string> rs = new SortedList <string, string>() { }; rs["RunStatus"] = Tb1.RunStatus.Result.ToString(); if (rs["RunStatus"] != "Accept") { //检测异常 rs["Result"] = "4"; rs["ResultString"] = "检测失败"; return(rs); } //处理结果,生成结果 rs["Result"] = "1"; rs["ResultString"] = "OK"; rs["NGKeys"] = ""; foreach (CogToolBlockTerminal item in Tb1.Outputs) { ConfigItem cfg = ProductManager.GetCurProduct().Configs.Find(cfi => cfi.CamIndex == 1 && cfi.Key == item.Name); double value = 0; double.TryParse(item.Value.ToString(), out value); value = Math.Round(value, 3); rs.Add(item.Name, value.ToString()); if (value > cfg.Usl || value < cfg.Lsl) { rs["Result"] = "2"; rs["ResultString"] = "NG"; rs["NGKeys"] += item.Name + ","; } } return(rs); }