From 993e734be337d5acea34cba80c6f0de2db9fe1bc Mon Sep 17 00:00:00 2001 From: czw <selecti@yeah.net> Date: 星期三, 09 七月 2025 11:29:04 +0800 Subject: [PATCH] 1 --- 2025年6月12日/AuxAllWCS/Build/Project/代码/VS自定义类/AutoThread.cs | 350 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 306 insertions(+), 44 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 7f33c68..eb835b9 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" @@ -26,6 +26,8 @@ using System.Net; using System.Threading; using System.IO; +using GZ.Device.Agv; +using System.Net.NetworkInformation; namespace GZ.Projects.AuxAllWCS { @@ -125,6 +127,61 @@ } } + + public void ThreaTotal(Tag tag) + { + List<Task> tasks = new List<Task>(); + tasks.Add(GetTask(ThreadMXC3, tag, 3000)); + tasks.Add(GetTask(ThreadMXC4, tag, 3000)); + tasks.Add(GetTask(ResetGats, tag, 3000)); + + + + + + Task.WaitAll(tasks.ToArray()); + } + public static bool IsMachineOnline(string hostNameOrIp, int timeout = 1000) + { + try + { + using (var ping = new Ping()) + { + var reply = ping.Send(hostNameOrIp, timeout); + return reply.Status == IPStatus.Success; + } + } + catch (PingException) + { + return false; + } + catch (Exception) + { + // 鍏朵粬寮傚父澶勭悊 + return false; + } + } + + private Task GetTask(Action<Tag> action, Tag tag, int i = 2500) + { + var task = Task.Run(() => + { + while (true) + { + try + { + action(tag); + } + catch (Exception ex) + { + LogHelper.Error(ex.Message, ex); + } + Thread.Sleep(i); + } + }); + return task; + } + public string WriteLine(string value = "") { @@ -166,6 +223,7 @@ { //tag.Js1.D1212_LAST = 0; RedisHelper.Add($"Js鎹烽『1.D1202_LAST", "0", out string msg); + //Conn.榛樿Redis.SetValue(VERX.deviceName + ".D1224", "0", VERX.deviceName + "Queue"); } if (tag.Js1.D1213_LAST == 0 && TcpServer.GetBitdata(tag.Js1.D1212, 3) == 1) @@ -187,6 +245,7 @@ { //tag.Js1.D1213_LAST = 0; RedisHelper.Add($"Js鎹烽『1.D1203_LAST", "0", out string msg); + //Conn.榛樿Redis.SetValue(VERX.deviceName + ".D1225", "0", VERX.deviceName + "Queue"); } } } @@ -647,11 +706,18 @@ } if (tag.RGV.taskend == 125) { - LogHelper.Info($"RGV 鏈�25鍛戒护鏈墽琛屻�"); + LogHelper.Info($"RGV 鏈�25鍛戒护鏈墽琛屻� "); + LogHelper.Info($"RGV125鍛戒护鏈墽琛�浠诲姟鏁版嵁 workmode:{tag.RGV.workMod}\n taskmod{tag.RGV.taskmod} \n t1No:{tag.RGV.taskno1}\n t1do:{tag.RGV.task1do} \n t2No:{tag.RGV.taskno2}\n t2do:{tag.RGV.task2do}\n taskend:{tag.RGV.taskend} "); + + if (tag.RGV.workMod == 0 && tag.RGV.taskmod == 0 && tag.RGV.taskno1 == tag.RGV.ReadTask1No && tag.RGV.taskno2 == tag.RGV.ReadTask2No) + { + LogHelper.Info($"RGV125鍛戒护鏈墽琛�tag.RGV.workMod == 0 && tag.RGV.taskmod == 0 && tag.RGV.taskno1 == tag.RGV.ReadTask1No && tag.RGV.taskno2 == tag.RGV.ReadTask2No 鑷姩娓呴櫎125"); + Conn.榛樿Redis.SetValue("RGV.taskend", "0", "RGVQueue", false); + } System.Threading.Thread.Sleep(3000); return; } - LogHelper.Info($"浠诲姟涓嬪彂 Rgv 浠诲姟 杩涘叆 Rgv淇℃伅 W1鐘舵�{tag.RGV.w1status} ReadTask1No>{tag.RGV.ReadTask1No} bit1taskOver>{tag.RGV.bit1taskOver} W2鐘舵�{tag.RGV.w2status} ReadTask2No>{tag.RGV.ReadTask2No} bit2taskOver>{tag.RGV.bit2taskOver}"); + LogHelper.Info($"浠诲姟涓嬪彂 Rgv 浠诲姟 杩涘叆 Rgv淇℃伅 W1鐘舵�{tag.RGV.w1status} ReadTask1No>{tag.RGV.ReadTask1No} 1宸ヤ綅鏉$爜:{tag.RGV.bit1Code} bit1taskOver>{tag.RGV.bit1taskOver} W2鐘舵�{tag.RGV.w2status} ReadTask2No>{tag.RGV.ReadTask2No} 2宸ヤ綅鏉$爜:{tag.RGV.bit2Code} bit2taskOver>{tag.RGV.bit2taskOver}"); TaskEntity task1 = null; TaskEntity task2 = null; var task1Isrun = false; @@ -713,7 +779,7 @@ task1.S_B_STATE = "鍙栬揣瀹屾垚"; } //tag.RGV.bit1taskOver = 0; - LogHelper.Info($"RGV 1宸ヤ綅浠诲姟{task1.S_TASK_NO} 鐘舵�鍒囨崲涓簕task1.S_B_STATE}"); + LogHelper.Info($"RGV 1宸ヤ綅浠诲姟{task1.S_TASK_NO} 鏉$爜锛歿tag.RGV.bit1Code} 鐘舵�鍒囨崲涓簕task1.S_B_STATE}"); //tag.RGV.bit1taskOver_LAST = 1; RedisHelper.Add($"RGV.bit1taskOver_LAST", "1", out string msg); LogHelper.Info($"RGV 1宸ヤ綅浠诲姟鍐欏鐞�); @@ -755,7 +821,7 @@ task2.S_B_STATE = "鍙栬揣瀹屾垚"; } //tag.RGV.bit2taskOver = 0; - LogHelper.Info($"RGV 2宸ヤ綅浠诲姟{task2.S_TASK_NO} 鐘舵�鍒囨崲涓簕task2.S_B_STATE}"); + LogHelper.Info($"RGV 2宸ヤ綅浠诲姟{task2.S_TASK_NO} 鏉$爜锛歿tag.RGV.bit2Code} 鐘舵�鍒囨崲涓簕task2.S_B_STATE}"); RedisHelper.Add($"RGV.bit2taskOver_LAST", "1", out string msg); LogHelper.Info($"RGV 2宸ヤ綅浠诲姟鍐欏鐞�); taskservice.Update(task2); @@ -996,7 +1062,18 @@ var taskCOdes = new List<string> { "Sarrive", "Srelease", "Earrive", "Erelease" }; TaskActRepository taskActRepository = new TaskActRepository(); TaskRepository taskRepository = new TaskRepository(); - var requires = taskActRepository.FindList(x => DateTime.Now.Subtract(x.T_CREATE).TotalHours < 1 && taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0).OrderBy(x => x.T_CREATE); + var requires = taskActRepository.FindList(x => taskCOdes.Contains(x.S_ACTION_CODE) && x.N_CREATEMETHOD == 0).OrderBy(x => x.T_CREATE).ToList(); + var timeMorhours = requires.FindAll(x => DateTime.Now.Subtract(x.T_CREATE).TotalHours > 1); + if (timeMorhours.Any()) + { + foreach (var mor in timeMorhours) + { + mor.N_CREATEMETHOD = 2; + mor.S_REVIEW_COMMENT = "瓒呮椂涓嶅鐞�; + taskActRepository.Update(mor); + } + requires = requires.Except(timeMorhours).ToList(); + } foreach (var item in requires) { LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE}鍏夋爡澶勭悊 =================> "); @@ -1004,6 +1081,7 @@ if (tin == -1) { item.N_CREATEMETHOD = -1; + item.S_REVIEW_COMMENT = $"淇″彿鏈煡{item.S_ACTION_CODE}涓嶅鐞�; taskActRepository.Update(item); continue; } @@ -1011,6 +1089,7 @@ if (task == null) { item.N_CREATEMETHOD = -1; + item.S_REVIEW_COMMENT = $"浠诲姟涓㈠け涓嶅鐞�; taskActRepository.Update(item); continue; } @@ -1048,57 +1127,85 @@ Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1220" : "D1221"), "0", dev.deviceName + "Queue"); Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1222" : "D1223"), "1", dev.deviceName + "Queue"); } + else if (dev.deviceType == 5) + { + LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 寮�惎鍏夋爡澶勭悊 =================> "); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D2211" : "D2216"), "1", dev.deviceName + "Queue"); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D2212" : "D2217"), "0", dev.deviceName + "Queue"); + } LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 寮�惎鍏夋爡澶勭悊瀹屾垚 =================> "); item.N_CREATEMETHOD = 1; + item.S_REVIEW_COMMENT = $"鍏夋爡寮�惎瀹屾垚"; taskActRepository.Update(item); } //杞﹁杩涘叆浜や簰銆� else { - if (dev.deviceType == 1) + if (dev.deviceType == 4) { - LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊 =================> "); - var tf = Conn.榛樿Redis.GetValue(dev.deviceName + "." + (V ? "R50" : "R52"));//璇诲叧闂姸鎬�- LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{tf}"); - if (tf?.ToLower() == "true") - { - LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�); - continuuuuu = true; - } - else - { - LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue")); - Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue", false); - } - LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊瀹屾垚 =================> "); + LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} SSX AGV 浜や簰銆傘�銆�); + //tag.SA1019.Sagverr } - else if (dev.deviceType == 2) + else { LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊 =================> "); - var tf = Conn.榛樿Redis.GetValue(dev.deviceName + ".D1202"); - int numm = int.Parse(string.IsNullOrEmpty(tf) ? "0" : tf); - int close = TcpServer.GetBitdata(numm, (V ? 0 : 1)); - LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{close}"); - if (close == 1) + if (dev.deviceType == 1) { - LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�); - continuuuuu = true; + var tf = Conn.榛樿Redis.GetValue(dev.deviceName + "." + (V ? "R50" : "R52"));//璇诲叧闂姸鎬�+ LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{tf}"); + if (tf?.ToLower() == "true") + { + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�); + continuuuuu = true; + } + else + { + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue")); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "R01" : "R03"), "true", dev.deviceName + "Queue", false); + } } - else + else if (dev.deviceType == 2) { - LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "D1220" : "D1221"), "1", dev.deviceName + "Queue")); - Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1222" : "D1223"), "0", dev.deviceName + "Queue"); - Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1220" : "D1221"), "1", dev.deviceName + "Queue"); + var tf = Conn.榛樿Redis.GetValue(dev.deviceName + ".D1202"); + int numm = int.Parse(string.IsNullOrEmpty(tf) ? "0" : tf); + int close = TcpServer.GetBitdata(numm, (V ? 0 : 1)); + LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏夋爡鍏抽棴淇″彿{close}"); + if (close == 1) + { + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�); + continuuuuu = true; + } + else + { + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆� + string.Format("{0}{1}{2}", dev.deviceName + "." + (V ? "D1220" : "D1221"), "1", dev.deviceName + "Queue")); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1222" : "D1223"), "0", dev.deviceName + "Queue"); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D1220" : "D1221"), "1", dev.deviceName + "Queue"); - string d12201 = RedisHelper.Get<string>(dev.deviceName + "." + (V ? "D1220" : "D1221"), out string msg); - LogHelper.Info($"ThreadGrats 鍐檣(dev.deviceName + "." + (V ? "D1220" : "D1221"))}涓�1 锛�鍚庤{d12201}"); + string d12201 = RedisHelper.Get<string>(dev.deviceName + "." + (V ? "D1220" : "D1221"), out string msg); + LogHelper.Info($"ThreadGrats 鍐檣(dev.deviceName + "." + (V ? "D1220" : "D1221"))}涓�1 锛�鍚庤{d12201}"); + } + } + else if (dev.deviceType == 3) + { + + var close = (System.UInt16)System.Convert.ChangeType(Conn.榛樿Redis.GetValue(dev.deviceName + "." + (V ? "D2220" : "D2225")), typeof(System.UInt16)); + if (close == 1) + { + LogHelper.Info($"{dev.deviceName}{(V ? "宸� : "鍙�)} 鍏夋爡{(goin ? "鍏抽棴" : "寮�惎")} 鐢宠銆�宸茬粡鍏抽棴锛�); + continuuuuu = true; + } + else + { + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D2212" : "D2217"), "1", dev.deviceName + "Queue"); + Conn.榛樿Redis.SetValue(dev.deviceName + "." + (V ? "D2211" : "D2216"), "0", dev.deviceName + "Queue"); + } } LogHelper.Info($"ThreadGrats {item.S_TASK_NO} >{item.S_ACTION_CODE} 璁惧鏄瘂dev.deviceName} 鍏抽棴鍏夋爡澶勭悊瀹屾垚 =================> "); } } - } + if (continuuuuu) { LogHelper.Info($"{item.S_TASK_NO}{item.S_ACTION_CODE} 杞﹁締鍙戦�缁х画浠诲姟锛�); @@ -1108,10 +1215,14 @@ taskCode = item.S_TASK_NO }); item.N_CREATEMETHOD = 1; + item.S_REVIEW_COMMENT = $"杞﹀瓙缁х画浠诲姟OK"; taskActRepository.Update(item); } } System.Threading.Thread.Sleep(3000); + } + public void ResetGats(Tag tag) + { LogHelper.Info($"ThreadGrats deviceType2鍏夋爡鍐欏叆浣嶉噸缃�=================> "); //閲嶇疆淇″彿 foreach (var dev in Settings.deviceInfos.FindAll(x => x.deviceType == 2)) @@ -1141,6 +1252,20 @@ } } LogHelper.Info($"ThreadGrats deviceType2鍏夋爡鍐欏叆浣嶉噸缃畬鎴愩� =================> "); + LogHelper.Info($"ThreadGrats deviceType5鍏夋爡鍐欏叆浣嶉噸缃�=================> "); + //閲嶇疆淇″彿 + //foreach (var dev in Settings.deviceInfos.FindAll(x => x.deviceType == 5)) + { + if (tag.DZ1.D2211 == 1 && tag.DZ1.D2220 == 1) + tag.DZ1.D2211 = 0; + if (tag.DZ1.D2216 == 1 && tag.DZ1.D2225 == 1) + tag.DZ1.D2216 = 0; + if (tag.DZ2.D2211 == 1 && tag.DZ2.D2220 == 1) + tag.DZ2.D2211 = 0; + if (tag.DZ2.D2216 == 1 && tag.DZ2.D2225 == 1) + tag.DZ2.D2216 = 0; + } + LogHelper.Info($"ThreadGrats deviceType5鍏夋爡鍐欏叆浣嶉噸缃畬鎴愩� =================> "); } /// <summary> /// 1020 1023绌烘涓嬬嚎 @@ -1171,7 +1296,7 @@ var listtep = new List<string>(); if (Bssx == "1020") { - if (tag.SF涓嬫枡浣�RArrive1003 == 1) + if (!string.IsNullOrEmpty(tag.SFT涓嬫枡鍙f墭鐩�R1003Barcode) && string.IsNullOrEmpty(tag.SFT涓嬫枡鍙f墭鐩�R1011Barcode)) { listtep = new List<string> { "1012", "1004" }; } @@ -1182,7 +1307,8 @@ } else { - if (tag.SF涓嬫枡浣�RArrive1005 == 1) + //if (tag.SF涓嬫枡浣�RArrive1005 == 1) + if (!string.IsNullOrEmpty(tag.SFT涓嬫枡鍙f墭鐩�R1005Barcode) && string.IsNullOrEmpty(tag.SFT涓嬫枡鍙f墭鐩�R1013Barcode)) { listtep = new List<string> { "1014", "1006" }; } @@ -1970,12 +2096,12 @@ { if (device2.deviceName.Contains("Js鎹烽『")) { - Task.Run(() => - { - var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0; - string V = inde ? "D1224" : "D1225"; - Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue"); - }); + //Task.Run(() => + //{ + var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0; + string V = inde ? "D1224" : "D1225"; + Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue"); + //}); var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new { @@ -2004,6 +2130,31 @@ })); LogHelper.Info($"{ssloc}鐢宠mes浠诲姟缁撴灉{str}"); } + } + switch (device2.deviceType) + { + case 4: + { + if (wcsTask.S_END_LOC == "2001") + { + + } + } + break; + case 5: + { + var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0; + string V = inde ? "D2210" : "D2215"; + Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue"); + } + break; + case 6: + { + //var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0; + //string V = inde ? "D2210" : "D2215"; + //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue"); + } + break; } } @@ -2127,18 +2278,129 @@ } } + /// <summary> + /// 瀹氬瓙1鍙风嚎銆�+ /// 1.澧炲姞涓嬬嚎閫昏緫銆� 2. 鏈夊彇绛愪俊鍙峰氨鍐欙紝娌′俊鍙峰珣鍐�+ /// </summary> + /// <param name="tag"></param> + public void ThreadMXC3(Tag tag) + { + var VERX = Settings.deviceInfos.Find(x => x.deviceType == 5 && x.deviceName.Contains("1鍙�)); + if (VERX == null) + { + LogHelper.Info("瀹氬瓙1鍙风嚎 deviceType 5 娌℃湁閰嶇疆銆�); + return; + } + LogHelper.Info($" {VERX.deviceName} D2221>{tag.DZ1.D2221} D2221_LAST>{tag.DZ1.D2221_LAST} D2226>{tag.DZ1.D2226} D2226_LAST>{tag.DZ1.D2226_LAST}"); + if (tag.DZ1.D2221 == 1 && tag.DZ1.D2221_LAST == 0) + { + var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new + { + requestType = 7, + startBit = VERX.location[0], + unLockStartBitOutbin = true + })); + LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}"); + var strr = JsonConvert.DeserializeObject<Messss>(str); + if (strr != null && strr.success && strr.data?.state == 0) + RedisHelper.Add($"D瀹氬瓙1鍙锋満姊版墜.D2221_LAST", "1", out string msg); + } + else if (tag.DZ1.D2221 == 0 && tag.DZ1.D2221_LAST == 1) + { + LogHelper.Info($"閲嶇疆 D瀹氬瓙1鍙锋満姊版墜.D2221_LAST > 0"); + RedisHelper.Add($"D瀹氬瓙1鍙锋満姊版墜.D2221_LAST", "0", out string msg); + + string V = 0 == 0 ? "D2210" : "D2215"; + Conn.榛樿Redis.SetValue(VERX.deviceName + "." + V, "0", VERX.deviceName + "Queue"); + } + if (tag.DZ1.D2226 == 1 && tag.DZ1.D2226_LAST == 0) + { + var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new + { + requestType = 7, + startBit = VERX.location[1], + unLockStartBitOutbin = true + })); + LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}"); + var strr = JsonConvert.DeserializeObject<Messss>(str); + if (strr != null && strr.success && strr.data?.state == 0) + RedisHelper.Add($"D瀹氬瓙1鍙锋満姊版墜.D2226_LAST", "1", out string msg); + } + else if (tag.DZ1.D2226 == 0 && tag.DZ1.D2226_LAST == 1) + { + LogHelper.Info($"閲嶇疆 D瀹氬瓙1鍙锋満姊版墜.D2226_LAST > 0"); + RedisHelper.Add($"D瀹氬瓙1鍙锋満姊版墜.D2226_LAST", "0", out string msg); + string V = 1 == 0 ? "D2210" : "D2215"; + Conn.榛樿Redis.SetValue(VERX.deviceName + "." + V, "0", VERX.deviceName + "Queue"); + } + } + /// <summary> + /// 瀹氬瓙2鍙风嚎銆�+ /// </summary> + /// <param name="tag"></param> + public void ThreadMXC4(Tag tag) + { + var VERX = Settings.deviceInfos.Find(x => x.deviceType == 5 && x.deviceName.Contains("2鍙�)); + if (VERX == null) + { + LogHelper.Info("瀹氬瓙2鍙风嚎 deviceType 5 娌℃湁閰嶇疆銆�); + return; + } + LogHelper.Info($" {VERX.deviceName} D2221>{tag.DZ1.D2221} D2221_LAST>{tag.DZ1.D2221_LAST} D2226>{tag.DZ1.D2226} D2226_LAST>{tag.DZ1.D2226_LAST}"); + if (tag.DZ2.D2221 == 1 && tag.DZ2.D2221_LAST == 0) + { + var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new + { + requestType = 7, + startBit = VERX.location[0], + unLockStartBitOutbin = true + })); + LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}"); + var strr = JsonConvert.DeserializeObject<Messss>(str); + if (strr != null && strr.success && strr.data?.state == 0) + RedisHelper.Add($"D瀹氬瓙2鍙锋満姊版墜.D2221_LAST", "1", out string msg); + } + else if (tag.DZ2.D2221 == 0 && tag.DZ2.D2221_LAST == 1) + { + LogHelper.Info($"閲嶇疆 D瀹氬瓙2鍙锋満姊版墜.D2221_LAST > 0"); + RedisHelper.Add($"D瀹氬瓙2鍙锋満姊版墜.D2221_LAST", "0", out string msg); + string V = 0 == 0 ? "D2210" : "D2215"; + Conn.榛樿Redis.SetValue(VERX.deviceName + "." + V, "0", VERX.deviceName + "Queue"); + } + if (tag.DZ2.D2226 == 1 && tag.DZ2.D2226_LAST == 0) + { + var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new + { + requestType = 7, + startBit = VERX.location[1], + unLockStartBitOutbin = true + })); + LogHelper.Info($"{VERX.location[0]}鐢宠mes浠诲姟缁撴灉{str}"); + var strr = JsonConvert.DeserializeObject<Messss>(str); + if (strr != null && strr.success && strr.data?.state == 0) + RedisHelper.Add($"D瀹氬瓙2鍙锋満姊版墜.D2226_LAST", "1", out string msg); + } + else if (tag.DZ2.D2226 == 0 && tag.DZ2.D2226_LAST == 1) + { + LogHelper.Info($"閲嶇疆 D瀹氬瓙2鍙锋満姊版墜.D2226_LAST > 0"); + RedisHelper.Add($"D瀹氬瓙2鍙锋満姊版墜.D2226_LAST", "0", out string msg); + string V = 1 == 0 ? "D2210" : "D2215"; + Conn.榛樿Redis.SetValue(VERX.deviceName + "." + V, "0", VERX.deviceName + "Queue"); + } - + } } + + public class HttpServer { System.Net.HttpListener HttpSvcHost = null; -- Gitblit v1.9.1