From 58a5ed6791a00cb98337525be289dd2d7f33269e Mon Sep 17 00:00:00 2001 From: czw <selecti@yeah.net> Date: 星期四, 24 七月 2025 10:24:48 +0800 Subject: [PATCH] 1 --- 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs | 68 +++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 9 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 c2d5e15..f3448ea 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" @@ -30,9 +30,33 @@ using System.Net.NetworkInformation; using System.Windows.Documents; using System.Text.RegularExpressions; +using GZ.Device.PLC; namespace GZ.Projects.AuxAllWCS { + public static class ExtendClass + { + public static void Disnull(this TaskRepository repository) + { + repository.dbcontext.Dispose(); + repository = null; + } + public static void Disnull(this LocRepository repository) + { + repository.dbcontext.Dispose(); + repository = null; + } + public static void Disnull(this TaskActRepository repository) + { + repository.dbcontext.Dispose(); + repository = null; + } + public static void Disnull(this SYSRepository repository) + { + repository.dbcontext.Dispose(); + repository = null; + } + } public partial class AutoThread { @@ -90,7 +114,7 @@ } catch (Exception ex) { - LogHelper.Error($"InvokeMethod > cacheKey-{ex.Message}", ex); + LogHelper.Error($"InvokeMethod > cacheKey:{cacheKey}-{ex.Message}", ex); throw ex; } } @@ -126,6 +150,7 @@ // return _repository; // } //} + /// <summary> /// 閰嶇疆鍒濆鍖栥� /// </summary> @@ -152,9 +177,11 @@ } + public void ThreaTotal(Tag tag, Device device) { List<Task> tasks = new List<Task>(); + LogHelper.Info("ThreaTotal 绾跨▼鎬荤嚎鍚姩"); tasks.Add(GetTask(delegate (Tag tag1, Device device1) { try @@ -216,9 +243,26 @@ tasks.Add(GetTask(ThreadMXC5, tag, 3000)); tasks.Add(GetTask(ThreadMXC6, tag, 3000)); + tasks.Add(GetTask(ThreadS7helper, tag, 3000)); + LogHelper.Info("ThreaTotal 绾跨▼鎬荤嚎runing"); Task.WaitAll(tasks.ToArray()); + LogHelper.Info("ThreaTotal 绾跨▼鎬荤嚎over"); } + + + private void ThreadS7helper(Tag tag) + { + //var plc = new Plc(CpuType.S71500,); + + //foreach (var item in collection) + //{ + // S7.Net.Plc plc = new Plc(CpuType.S71500, item.address, 0, 1); + // Link(plc); + // PLCS.Add(item.deviceName, plc); + //} + } + void taskssss1(Tag tag) { sa1025(tag); @@ -238,7 +282,7 @@ sa3010(tag); } - public static ConcurrentDictionary<string, bool> Iponlines = new ConcurrentDictionary<string, bool>(); + //public static ConcurrentDictionary<string, bool> Iponlines = new ConcurrentDictionary<string, bool>(); public bool IsMachineOnline(string hostNameOrIp, int timeout = 1000) { //device.p鍙戦偅绉�涓嬬嚎.Config.IP @@ -1213,6 +1257,8 @@ } } } + task1 = null; + task2 = null; LogHelper.Info($"rgv 澶勭悊瀹屾垚銆倀askend 125"); #endregion } @@ -1236,7 +1282,6 @@ TaskRepository taskRepository = new TaskRepository(); try { - var requires1 = taskActRepository.FindList(x => taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0).OrderBy(x => x.T_CREATE).ToList(); var timeMorhours = requires1.FindAll(x => DateTime.Now.Subtract(x.T_CREATE).TotalHours > 1); if (timeMorhours.Any()) @@ -1629,9 +1674,10 @@ else if (dev.deviceType == 6) { var close = (System.UInt16)System.Convert.ChangeType(Conn.榛樿Redis.GetValue(dev.deviceName + "." + (V ? "RD1203" : "RD1204")), typeof(System.UInt16)); - LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�鍏抽棴鐘舵�锛歿close}锛�); + var canDo = (System.UInt16)System.Convert.ChangeType(Conn.榛樿Redis.GetValue(dev.deviceName + "." + (locindex == 0 ? "RD1200" : locindex == 1 ? "RD1201" : "RD1202")), typeof(System.UInt16)); - if (close == 0) + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆傚畞姹�鍏抽棴鐘舵�锛歿close}锛�鍏佽鎿嶄綔鐘舵�锛歿canDo}"); + if (close == 0 && canDo == 1) { continuuuuu = true; } @@ -1680,6 +1726,8 @@ } } + requires1 = null; + timeMorhours = null; } catch (Exception ex) { @@ -2421,10 +2469,10 @@ private void sa2008(Tag tag) { var rdisTcode = RedisHelper.Get<string>($"Arrive{2008}BarcodeLast", out string msg); - LogHelper.Info($"2008 鎵樼洏鍙穥tag.SA2030.R鎵樼洏鐮亇 redis Arrive{2008}BarcodeLast鎵樼洏鍙凤細{rdisTcode} 鍖归厤鏍¢獙銆�); - if (!string.IsNullOrEmpty(tag.ssx杈撻�绾�s2008.R鎵樼洏鐮� && rdisTcode != tag.ssx杈撻�绾�s2008.R鎵樼洏鐮� + var ntr = tag.ssx杈撻�绾�s2008.R鎵樼洏鐮� + LogHelper.Info($"2008 鎵樼洏鍙穥ntr} redis Arrive{2008}BarcodeLast鎵樼洏鍙凤細{rdisTcode} 鍖归厤鏍¢獙銆�); + if (!string.IsNullOrEmpty(ntr) && rdisTcode != ntr) { - var ntr = tag.ssx杈撻�绾�s2008.R鎵樼洏鐮� var str = Settings.apiHelper.Post(Settings.MESbaseUrl + "mom-basic/dataTransmission/json/service/224", JsonConvert.SerializeObject(new { cntrCode = ntr, @@ -2612,6 +2660,8 @@ LogHelper.Info($"寰幆{i}娆�> 娓呯┖鎺у埗鍙般�"); i = 0; } + + LogHelper.Info($"_methodCache>>>>"+ _methodCache.Count+">>>>"+JsonConvert.SerializeObject(_methodCache.Keys)); //Console.WriteLine($"SA2030 浠诲姟鐘舵�锛� =====>"); //Console.WriteLine($"SA2030 浠诲姟鐘舵�锛歿tag.SA2030.RtaskState}- 绌洪棽{tag.SA2030.R5绌洪棽} - barcode:{tag.SA2030.R鎵樼洏鐮亇"); @@ -3489,7 +3539,7 @@ Console.WriteLine($"ip= {ip.ToString()}"); new HttpServer(ip.ToString()).HttpServerRun(); new TcpServer(ip.ToString()); - var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); + //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); //var client = new WebSocketClient($"http://{ip.ToString()}:8809/").ConnectAsync(); break; } -- Gitblit v1.9.1