From 745d1ce73a3b27d2a3507843c8060755a0c95765 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期二, 21 十月 2025 19:06:36 +0800
Subject: [PATCH] 打印机条码格式修改,增添一个点检功能方法
---
src/Bro.M141_AOI1.Process/AOI1Process.cs | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 355 insertions(+), 19 deletions(-)
diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index a6e11ba..8d82bef 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -9,10 +9,12 @@
using HalconDotNet;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+using NPOI.OpenXmlFormats.Vml;
using NPOI.POIFS.Crypt.Dsig;
using NPOI.SS.Formula.Functions;
using NPOI.XSSF.Streaming.Values;
using System.Collections.Concurrent;
+using System.Collections.Generic;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using static Bro.Common.Helper.EnumHelper;
@@ -105,6 +107,75 @@
}
+ [ProcessMethod("ImageCheck", "CheckProduction", "浜у搧鐐规", InvokeType.TestInvoke)]
+ public ResponseMessage CheckProduction(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ ResponseMessage msg = new ResponseMessage();
+
+ if (config is IImageCheckOperationConfig opConfig)
+ {
+ var results1 = GetSpecListFromConfigSelection(opConfig.SpecCollection);
+ IImageSet imageSet = null;
+ string Head = "鏃堕棿,";
+ string data = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}T,";
+ try
+ {
+ var messure = M141Config.MeasureBindCollection_Check.FirstOrDefault(u => u.CameraId == invokeDevice.Id);
+ var camera = DeviceCollection.FirstOrDefault(u => u.Id == messure.CameraId) as CameraBase;
+ try
+ {
+ imageSet = CollectHImage(camera, messure.SnapshotOpConfig);
+ }
+ catch (Exception exx)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鐐规鍔熻兘鑾峰彇鍥惧儚澶辫触{exx.ToString()}");
+ }
+ var tool = GetHalconTool(null, "", opConfig.AlgorithemPath);
+ var ret = tool.RunProcedure(null, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", imageSet.HImage } }, new List<string>() { "OUTPUT_Results" }, null);
+ //var ret = tool.RunProcedure(null, null, new List<string>() { "OUTPUT_Results" }, null);
+ List<IShapeElement> eleList = new List<IShapeElement>();
+ TextDisplay text = new TextDisplay();
+ text.LineLimit = M141Config.LineLimit_p;
+ text.FontSize = M141Config.FontSize_p;
+ eleList.Add(text);
+ text.StartX = text.StartY = 0;
+ text.AddText("鐐规杩愯鎴愬姛", Color.Lime, Color.Transparent);
+ var b = ret.Item2["OUTPUT_Results"].HTupleToDouble();
+ if (ret != null&& results1.Count== b.Count())
+ {
+ var itemDict = results1.ToDictionary(u => u.OutputIndex);
+ b.ForEach(u =>
+ {
+ int index = b.IndexOf(u); // 鑾峰彇褰撳墠鍊肩殑绱㈠紩
+ if (itemDict.TryGetValue(index, out var item))
+ {
+ double diff = u - item.StandardValue;
+ bool isInTolerance = (diff - item.Tolrenance_Positive) *(diff - item.Tolrenance_Negative) <= 0;
+ text.AddText($"{item.Code} {u}", isInTolerance == true ? Color.Lime: Color.Red, Color.Transparent);
+ Head += $"{item.Code},";
+ data += $"{u},";
+ }
+ });
+ }
+ camera.SaveFitImage(eleList, imageSet);
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规鍔熻兘杩愯鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鐐规鍔熻兘澶辫触,{ex.ToString()}");
+ }
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐐规鍥剧墖寮�濮嬮噴鏀�");
+ imageSet.HImage?.Dispose();
+ imageSet.HImage = null;
+ imageSet.Dispose();
+ imageSet = null;
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鍥剧墖宸查噴鏀�");
+ //鎶ヨ〃杈撳嚭
+ CSVRecordAsync($"鐩告満{invokeDevice.Name}_鐐规鏁版嵁璁板綍.csv", data, Head);
+ }
+ return msg;
+ }
+
[ProcessMethod("ImageCheck", "ReadBarcode", "璇荤爜", InvokeType.TestInvoke)]
public ResponseMessage ReadBarcode(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
{
@@ -140,7 +211,6 @@
{
codestr = "10";
}
-
if (codestr.Equals(mh.ToString()))
{
ret.Add(1);
@@ -158,7 +228,6 @@
}
FillSpecResults(results[0].PID, results[0].Specs, ret, opConfig.Products[0].SEQUENCE);
-
opConfig.Products[0].SN = barcode;
opConfig.Products[0].PID = barcode + "_1";
@@ -179,7 +248,6 @@
}
return msg;
}
-
[ProcessMethod("ImageCheck", "ReadBarcode2", "璇绘爮鍏风爜", InvokeType.TestInvoke)]
public ResponseMessage ReadBarcode2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -249,6 +317,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} ");
@@ -264,6 +351,7 @@
}
else
{
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
Plc1.WriteSingleAddress(1524, 1, out _);
Plc1.WriteSingleAddress(1514, 1, out _);
}
@@ -274,7 +362,6 @@
return msg;
}
-
private string BarcodeScannerCommunicate(TcpClientWrapBase client)
{
@@ -306,7 +393,6 @@
return "NOREAD";
}
-
private bool CheckBarcodeValid(string barcode)
{
bool isBarcodeValid = true;
@@ -316,7 +402,6 @@
}
return isBarcodeValid;
}
-
[ProcessMethod("ImageCheck", "CheckLineProfile", "妫�娴嬩骇鍝佺嚎杞粨搴�", InvokeType.TestInvoke)]
public ResponseMessage CheckLineProfile(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -348,8 +433,7 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"妫�娴嬩骇鍝佺嚎杞粨搴﹁緭鍏ョ偣鏁版嵁 {string.Join(',', pointdataF)}");
var tool = GetHalconTool(null, "", opConfig.AlgorithemPath);
- var ret = tool.RunProcedure(new Dictionary<string, HalconDotNet.HTuple>() { { "INPUT_Points", pointdataF.ToArray() } }, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", opConfig.ImageSet.HImage } }, new List<string>() { "OUTPUT_Results", "OUTPUT_PointZ" }, null);
-
+ var ret = tool.RunProcedure(new Dictionary<string, HalconDotNet.HTuple>() { { "INPUT_Points", pointdataF.ToArray() } }, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", opConfig.ImageSet.HImage } }, new List<string>() { "OUTPUT_Results", "OUTPUT_PointZ" }, null);
if (ret == null)
{
LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑴氭湰{opConfig.AlgorithemPath}杩愯寮傚父锛岃繑鍥炲�间负null");
@@ -436,6 +520,26 @@
else
{
item.ActualValue = retcal.Item2["OUTPUT_Results"].HTupleToDouble()[0];
+
+ if (item.IsEnableCompensation && item.CompensationValue.Count > 1)
+ {
+ string index = opConfig.TriggerStr.Split('#')[0];
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{item.Code}杩涘叆鍙岄噸琛ュ伩{index}锛屽垵濮嬪�间负{item.ActualValue}");
+
+ if (index=="1")
+ {
+ item.ActualValue += item.CompensationValue[0];
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{item.Code}杩涘叆鍙岄噸琛ュ伩,琛ュ伩鍊间负{item.CompensationValue[0]}锛屾渶缁堢粨鏋滀负{item.ActualValue}");
+ }
+ else
+ {
+ item.ActualValue += item.CompensationValue[1];
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{item.Code}杩涘叆鍙岄噸琛ュ伩,琛ュ伩鍊间负{item.CompensationValue[1]}锛屾渶缁堢粨鏋滀负{item.ActualValue}");
+ }
+
+ }
+
+
LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{results[0].PID}鑾峰彇璁$畻鍏紡鏁版嵁{item.Code} {item.GetMeasureValueStr()}");
}
}
@@ -460,7 +564,6 @@
return msg;
}
-
[ProcessMethod("ImageCheck", "GetMatrix", "鑾峰彇鐭╅樀", InvokeType.TestInvoke)]
public ResponseMessage GetMatrix(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -490,10 +593,147 @@
return msg;
}
+ [ProcessMethod("", "MESupdata", "MES姝e父涓婁紶OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+ public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ ResponseMessage msg = new ResponseMessage();
+
+ Plc3 = invokeDevice as PLCBase;
+ ///浜у搧1涓婁紶
+ var plcnum = Plc3.Read(2100, 1, out _);
+ if (plcnum[0] != 0)
+ {
+ var plist = mysqlhelper.GetProductList(plcnum + "_1");
+ ProductModel newp = new ProductModel();
+ newp.SEQUENCE = plist[0].SEQUENCE;
+ newp.PID = plist[0].PID;
+ newp.BasketCode = plist[0].BasketCode;
+ newp.Zword = plist[0].Zword;
+ newp.Result = "OK";
+ newp.SN = plist[0].SN;
+
+ var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ M141Config.mesnum2++;
+ if (tems == null)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ }
+ else
+ {
+ try
+ {
+ var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems);
+ if (obj.zstatus == "200")
+ {
+ Plc1.WriteSingleAddress(2120, 1, out _);
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {tems}");
+ }
+ else
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ catch (Exception)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ ///浜у搧1涓婁紶
+ var plcnum1 = Plc3.Read(2102, 1, out _);
+ if (plcnum1[0] != 0)
+ {
+ var plist1 = mysqlhelper.GetProductList(plcnum1 + "_1");
+ ProductModel newp1 = new ProductModel();
+ newp1.SEQUENCE = plist[0].SEQUENCE;
+ newp1.PID = plist[0].PID;
+ newp1.BasketCode = plist[0].BasketCode;
+ newp1.Zword = plist[0].Zword;
+ newp1.Result = "OK";
+ newp1.SN = plist[0].SN;
+
+ var tems1 = Task.Run(() => mqtt.MESForProduceAsync(newp1, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ M141Config.mesnum2++;
+ if (tems1 == null)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ }
+ else
+ {
+ try
+ {
+ var obj1 = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems1);
+ if (obj1.zstatus == "200")
+ {
+ Plc1.WriteSingleAddress(2120, 1, out _);
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {tems}");
+ }
+ else
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ catch (Exception)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ }
+
+ }
+ return msg;
+ }
+
+ [ProcessMethod("", "MESupFinallydata", "MES涓婁紶灏剧洏OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+ public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ {
+ ResponseMessage msg = new ResponseMessage();
+
+ Plc3 = invokeDevice as PLCBase;
+ ///浜у搧1涓婁紶
+ var plcnum = Plc3.Read(2100, 1, out _);
+ var plist = mysqlhelper.GetProductList(plcnum+"_1");
+ ProductModel newp = new ProductModel();
+ newp.SEQUENCE = plist[0].SEQUENCE;
+ newp.PID = plist[0].PID;
+ newp.BasketCode = plist[0].BasketCode;
+ newp.Zword = plist[0].Zword;
+ newp.Result = "OK";
+ newp.SN = plist[0].SN;
+ //涓婁紶灏剧洏鏁版嵁
+ var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro,"Y")).Result;
+ M141Config.mesnum2 = 0;
+ if (tems == null)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ }
+ else
+ {
+ try
+ {
+ var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(tems);
+ if (obj.zstatus == "200")
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {tems}");
-
-
+ //鎵撳嵃鑾峰彇鐨勬潯鐮�
+ if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
+ {
+ StartPrint(obj.tary_label);
+ }
+ }
+ else
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ catch (Exception)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{plist[0].PID}鏁版嵁涓婁紶MES澶辫触 {tems}");
+ }
+ }
+ return msg;
+ }
[ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]
@@ -528,6 +768,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}");
@@ -535,6 +794,7 @@
}
catch
{
+
LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 绡叿 杩涙枡鍙g┖绡� 鑾峰彇杩斿洖鍊艰В鏋愬紓甯� 杩斿洖鏁版嵁{Msg} ");
Plc1.WriteSingleAddress(1590, 2, out _);
}
@@ -548,6 +808,7 @@
}
else
{
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
Plc1.WriteSingleAddress(1590, 1, out _);
}
@@ -589,6 +850,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 _);
}
@@ -609,6 +889,7 @@
}
else
{
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
Plc1.WriteSingleAddress(1590, 1, out _);
}
@@ -639,6 +920,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}");
@@ -658,6 +958,7 @@
}
else
{
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
Plc1.WriteSingleAddress(1591, 1, out _);
}
@@ -684,7 +985,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
{
@@ -695,8 +1018,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;
@@ -712,6 +1033,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}");
@@ -730,14 +1070,10 @@
}
else
{
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴");
Plc1.WriteSingleAddress(1591, 1, out _);
}
return msg;
}
-
-
-
-
-
}
}
--
Gitblit v1.8.0