From 42178c2120a5595a57d8f3d5a394ad2caeac6585 Mon Sep 17 00:00:00 2001 From: czw <selecti@yeah.net> Date: 星期日, 06 七月 2025 13:37:44 +0800 Subject: [PATCH] 1 --- 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs | 87 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 68 insertions(+), 19 deletions(-) diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" index 6cf597f..2627aa9 100644 --- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" +++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" @@ -77,8 +77,8 @@ } // 鎵ц濮旀墭 - if (methodName != "TaskEverythingRun") - return null; + //if (methodName != "TaskEverythingRun") + // return null; return methodDelegate.DynamicInvoke(args); } @@ -255,6 +255,8 @@ if (VERX != null) { + if (tag.wxr1.R44) + LogHelper.Info($"{VERX.deviceName} R44>{tag.wxr1.R44} R44LAST>{tag.wxr1.R44_LAST} R10>{tag.wxr1.R10}"); if (tag.wxr1.R44 && !tag.wxr1.R44_LAST && tag.wxr1.R10) { if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) @@ -293,16 +295,21 @@ if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) { //涓婃姤鏍¢獙銆�+ LogHelper.Info($"{VERX.deviceNo[0]} 涓婃姤鏍¢獙>{traycode}"); + ///var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/202", requestJson); var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new { sceneType = 1, cntrCode = traycode, })); - if (str.Contains("true")) + var strr = JsonConvert.DeserializeObject<Mesrespone>(str); + if (strr != null && strr.success) + //if (str.Contains("true")) { //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue"); - tag.wxr1.R10 = true; + //tag.wxr1.R10 = true; + Conn.榛樿Redis.SetValue(VERX.deviceName + ".R10", "true", VERX.deviceName + "Queue"); //tag.wxr1.R44_LAST = false; RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "false", out string msg); } @@ -312,6 +319,10 @@ } } else { TcpServer.TcpServerSend(VERX.deviceNo[0], GZ.Device.PLC.PlcHelper.Hex2Bin("544F4E")); } + } + else if (!tag.wxr1.R10) + { + TcpServer.TrayIps.Remove(VERX.deviceNo[0]); } } } @@ -328,6 +339,8 @@ if (VERX != null) { + if (tag.wxr1.R46) + LogHelper.Info($"{VERX.deviceName} R44>{tag.wxr1.R46} R44LAST>{tag.wxr1.R46_LAST} R10>{tag.wxr1.R11}"); if (tag.wxr1.R46 && !tag.wxr1.R46_LAST && tag.wxr1.R11) { if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) @@ -365,16 +378,20 @@ if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) { //涓婃姤鏍¢獙銆�+ LogHelper.Info($"{VERX.deviceNo[1]} 涓婃姤鏍¢獙>{traycode}"); ///var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/202", requestJson); var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new { sceneType = 1, cntrCode = traycode, })); - if (str.Contains("true")) + var strr = JsonConvert.DeserializeObject<Mesrespone>(str); + if (strr != null && strr.success) + //if (str.Contains("true")) { //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue"); - tag.wxr1.R11 = true; + //tag.wxr1.R11 = true; + Conn.榛樿Redis.SetValue(VERX.deviceName + ".R11", "true", VERX.deviceName + "Queue"); //tag.wxr1.R46_LAST = false; RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "false", out string msg); } @@ -384,6 +401,10 @@ } } else { TcpServer.TcpServerSend(VERX.deviceNo[1], GZ.Device.PLC.PlcHelper.Hex2Bin("544F4E")); } + } + else if (!tag.wxr1.R11) + { + TcpServer.TrayIps.Remove(VERX.deviceNo[1]); } } } @@ -400,6 +421,8 @@ if (VERX != null) { + if (tag.wxr2.R44) + LogHelper.Info($"{VERX.deviceName} R44>{tag.wxr2.R44} R44LAST>{tag.wxr2.R44_LAST} R10>{tag.wxr2.R10}"); if (tag.wxr2.R44 && !tag.wxr2.R44_LAST && tag.wxr2.R10) { if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) @@ -437,16 +460,20 @@ if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[0], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) { //涓婃姤鏍¢獙銆�+ LogHelper.Info($"{VERX.deviceNo[0]} 涓婃姤鏍¢獙>{traycode}"); ///var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/202", requestJson); var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new { sceneType = 1, cntrCode = traycode, })); - if (str.Contains("true")) + var strr = JsonConvert.DeserializeObject<Mesrespone>(str); + if (strr != null && strr.success) + //if (str.Contains("true")) { //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue"); - tag.wxr2.R10 = true; + //tag.wxr2.R10 = true; + Conn.榛樿Redis.SetValue(VERX.deviceName + ".R10", "true", VERX.deviceName + "Queue"); //tag.wxr2.R44_LAST = false; RedisHelper.Add($"缁村笇灏旀姄鑷�.R44_LAST", "false", out string msg); } @@ -456,6 +483,10 @@ } } else { TcpServer.TcpServerSend(VERX.deviceNo[0], GZ.Device.PLC.PlcHelper.Hex2Bin("544F4E")); } + } + else if (!tag.wxr2.R10) + { + TcpServer.TrayIps.Remove(VERX.deviceNo[0]); } } } @@ -473,6 +504,8 @@ if (VERX != null) { + if (tag.wxr2.R46) + LogHelper.Info($"{VERX.deviceName} R44>{tag.wxr2.R46} R44LAST>{tag.wxr2.R46_LAST} R10>{tag.wxr2.R11}"); if (tag.wxr2.R46 && !tag.wxr2.R46_LAST && tag.wxr2.R11) { if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) @@ -511,7 +544,7 @@ else if (TcpServer.TrayIps.TryGetValue(VERX.deviceNo[1], out string traycode) && !string.IsNullOrEmpty(traycode.Trim())) { - LogHelper.Info($"Threadwxr2R 涓婃姤鏍¢獙>{traycode}"); + LogHelper.Info($"{VERX.deviceNo[1]} 涓婃姤鏍¢獙>{traycode}"); //涓婃姤鏍¢獙銆� ///var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/202", requestJson); var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new @@ -519,12 +552,17 @@ sceneType = 1, cntrCode = traycode, })); - if (str.Contains("true")) + var strr = JsonConvert.DeserializeObject<Mesrespone>(str); + if (strr != null && strr.success) { - //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R10", "true", "缁村笇灏旀姄鑷�Queue"); - tag.wxr2.R11 = true; + //Conn.榛樿Redis.SetValue("缁村笇灏旀姄鑷�.R11", "true", "缁村笇灏旀姄鑷�Queue"); + //tag.wxr2.R11 = true; + + LogHelper.Info($"Threadwxr2R銆傘� -鍐橰11 true"); + Conn.榛樿Redis.SetValue(VERX.deviceName + ".R11", "true", VERX.deviceName + "Queue"); //tag.wxr2.R46_LAST = false; RedisHelper.Add($"缁村笇灏旀姄鑷�.R46_LAST", "false", out string msg); + LogHelper.Info($"Threadwxr2R銆傘� 鏍¢獙涓嬫枡瀹屾垚銆�); } else { @@ -536,6 +574,10 @@ LogHelper.Info($"Threadwxr2R銆傘� -鍙戦�鎵爜"); TcpServer.TcpServerSend(VERX.deviceNo[1], GZ.Device.PLC.PlcHelper.Hex2Bin("544F4E")); } + } + else if (!tag.wxr2.R11) + { + TcpServer.TrayIps.Remove(VERX.deviceNo[1]); } } } @@ -1585,6 +1627,10 @@ foreach (var task in tasks) { LogHelper.Info($"瑙i噴MES浠诲姟 ->{task.S_TASK_NO} "); + if (task.S_TYPE?.Trim() == "100") + { + LogHelper.Info($"MES浠诲姟 S_TYPE 100->{task.S_TYPE} "); + } var sx = VERXs?.Find(x => x.location.Contains(task.S_END_LOC)); LogHelper.Info($"瑙i噴MES浠诲姟 ->{task.S_TASK_NO} {(sx == null ? "闈� : "鏄�)}鎬昏鏈哄櫒浜轰换鍔�); if (sx == null) @@ -2027,24 +2073,23 @@ - - } + public class HttpServer { System.Net.HttpListener HttpSvcHost = null; - private readonly string _listenerPrefix = ""; + public static string _listenerPrefix = ""; public HttpServer(string ip) { - _listenerPrefix = ip; + _listenerPrefix = $"http://{ip}:8808/"; } public void HttpServerRun() { HttpSvcHost = new System.Net.HttpListener(); HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous; - HttpSvcHost.Prefixes.Add($"http://{_listenerPrefix}:8808/"); + HttpSvcHost.Prefixes.Add(_listenerPrefix); HttpSvcHost.Start(); HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null); } @@ -2328,8 +2373,6 @@ } - - internal class WebSocketClient { private ClientWebSocket _webSocket = new ClientWebSocket(); @@ -2414,6 +2457,12 @@ public Ddata data { get; set; } public object extra { get; set; } } + class Mesrespone + { + public bool success { get; set; } + public string msg { get; set; } + public object extra { get; set; } + } public class Ddata { -- Gitblit v1.9.1