From 66e0168fe68ae5641041b2bceb3f0bb9640df09f Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 22 八月 2025 09:21:39 +0800
Subject: [PATCH] 添加MES超时队列匹配功能,vision错误自动累加和清零动作

---
 src/Bro.M141_AOI1.Process/AOI1Process.cs |  127 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 119 insertions(+), 8 deletions(-)

diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index 6a88850..e2a093d 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -249,6 +249,25 @@
                                 }
                                 else
                                 {
+                                    try
+                                    {
+                                        if (zwordstr.Contains("version閿欒"))
+                                        {
+                                            Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                            MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                            if (matches[0] != null && matches.Count == 3)
+                                            {
+                                                ConfigAOI1.mesnum2 = int.Parse(matches[0].Value)+1;
+                                            }
+                                            else
+                                            {
+                                                ConfigAOI1.mesnum2 = 0;
+                                            }
+                                        }
+                                    }
+                                    catch (Exception ex) 
+                                    {
+                                    }                                 
                                     Plc1.WriteSingleAddress(1524, 2, out _);
                                     Plc1.WriteSingleAddress(1514, 1, out _);
                                     LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ zwoid鑾峰彇澶辫触 {zwordstr} ");
@@ -547,6 +566,25 @@
                             }
                             else
                             {
+                                try
+                                {
+                                    if (Msg.Contains("version閿欒"))
+                                    {
+                                        Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                        MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                        if (matches[0] != null && matches.Count == 3)
+                                        {
+                                            ConfigAOI1.mesnum1 = int.Parse(matches[0].Value)+ 1;
+                                        }
+                                        else
+                                        {
+                                            ConfigAOI1.mesnum1 = 0;
+                                        }
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                }
                                 Plc1.WriteSingleAddress(1590, 2, out _);
                             }
                             LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  杩涙枡鍙g┖绡� 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
@@ -554,6 +592,7 @@
                         }
                         catch
                         {
+                            
                             LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  杩涙枡鍙g┖绡� 鑾峰彇杩斿洖鍊艰В鏋愬紓甯�  杩斿洖鏁版嵁{Msg} ");
                             Plc1.WriteSingleAddress(1590, 2, out _);
                         }
@@ -608,6 +647,25 @@
                             }
                             else
                             {
+                                try
+                                {
+                                    if (Msg.Contains("version閿欒"))
+                                    {
+                                        Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                        MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                        if (matches[0] != null && matches.Count == 3)
+                                        {
+                                            ConfigAOI1.mesnum1 = int.Parse(matches[0].Value) + 1;
+                                        }
+                                        else
+                                        {
+                                            ConfigAOI1.mesnum1 = 0;
+                                        }
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                }
                                 Plc1.WriteSingleAddress(1590, 2, out _);
                             }
 
@@ -658,6 +716,25 @@
                         }
                         else
                         {
+                            try
+                            {
+                                if (Msg.Contains("version閿欒"))
+                                {
+                                    Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                    MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                    if (matches[0] != null && matches.Count == 3)
+                                    {
+                                        ConfigAOI1.mesnum3 = int.Parse(matches[0].Value)+1;
+                                    }
+                                    else
+                                    {
+                                        ConfigAOI1.mesnum3 = 0;
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                            }
                             Plc1.WriteSingleAddress(1591, 2, out _);
                         }
                         LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  涓嬫枡鍙g┖绡� 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
@@ -703,7 +780,29 @@
                         {
                             ConfigAOI1.mesnum3++;
                         }
-                        LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  涓嬫枡鍙f弧杞�1 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
+                        else
+                        {
+                            try
+                            {
+                                if (Msg.Contains("version閿欒"))
+                                {
+                                    Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                    MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                    if (matches[0] != null && matches.Count == 3)
+                                    {
+                                        ConfigAOI1.mesnum3 = int.Parse(matches[0].Value) + 1;
+                                    }
+                                    else
+                                    {
+                                        ConfigAOI1.mesnum3 = 0;
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                            }
+                        }
+                            LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  涓嬫枡鍙f弧杞�1 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
                     }
                     catch
                     {
@@ -714,8 +813,6 @@
                 {
                     LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  涓嬫枡鍙f弧杞�1 鑾峰彇杩斿洖鍊艰В鏋愬紓甯�  杩斿洖鏁版嵁null ");
                 }
-
-
                 Thread.Sleep(1000);
                 //mqtt.Send("4", "DS02217", ConfigAOI1.Dicbasketcode.ContainsKey(num) ? ConfigAOI1.Dicbasketcode[num] : ConfigAOI1.basketcode, "1", num.ToString());
                 Msg = Task.Run(() => mqtt.MESForBasketAsync("4", "DS02217", ConfigAOI1.PlcAndBasketcodes.Any(u => u.id == num) ? ConfigAOI1.PlcAndBasketcodes.FirstOrDefault(u => u.id == num).code : "NoRead", "1", ConfigAOI1.mesnum4.ToString())).Result;
@@ -731,6 +828,25 @@
                         }
                         else
                         {
+                            try
+                            {
+                                if (Msg.Contains("version閿欒"))
+                                {
+                                    Regex reg = new Regex("[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromSeconds(2));
+                                    MatchCollection matches = reg.Matches(obj.zerrmsg);
+                                    if (matches[0] != null && matches.Count == 3)
+                                    {
+                                        ConfigAOI1.mesnum4 = int.Parse(matches[0].Value) + 1;
+                                    }
+                                    else
+                                    {
+                                        ConfigAOI1.mesnum4 = 0;
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                            }
                             Plc1.WriteSingleAddress(1591, 2, out _);
                         }
                         LogAsync(DateTime.Now, obj?.zstatus == "200" ? EnumHelper.LogLevel.Information : EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿  涓嬫枡鍙f弧杞� 涓婁紶{(obj?.zstatus == "200" ? "鎴愬姛" : "澶辫触")}   {obj?.zstatus}");
@@ -753,10 +869,5 @@
             }
             return msg;
         }
-
-
-
-
-
     }
 }

--
Gitblit v1.8.0