Exemplo n.º 1
0
 private static void Cam3AutoProcess()
 {
     while (Cam3AcqThread.IsAlive || Cam3ImageQueue.Count > 0)
     {
         if (Cam3ImageQueue.Count > 0)
         {
             SortedList <string, string> rs = RunCam3Program(Cam3ImageQueue.Dequeue());
             if (Cam3ResultAvailable != null)
             {
                 Cam3ResultAvailable(null, new VisionResultAvailableEventArgs(Tb3.CreateLastRunRecord(), rs));
             }
         }
     }
 }
Exemplo n.º 2
0
        public static SortedList <string, string> RunCam3Program(ICogImage iCogImage)
        {
            WriteBlockInput(Tb3, "Image", iCogImage);
            Tb3.Run();
            Tb3.CreateLastRunRecord();

            SortedList <string, string> rs = new SortedList <string, string>()
            {
            };

            rs["RunStatus"] = Tb3.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 Tb3.Outputs)
            {
                ConfigItem cfg   = ProductManager.GetCurProduct().Configs.Find(cfi => cfi.CamIndex == 3 && 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);
        }