From 267ffc1263e9975adf0d3dcca9ccc5d7dbd239f6 Mon Sep 17 00:00:00 2001 From: zxx <zxx> Date: 星期六, 31 五月 2025 17:54:14 +0800 Subject: [PATCH] jushi --- HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs | 95 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 80 insertions(+), 15 deletions(-) diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs index 0c4700b..7687ea1 100644 --- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs +++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs @@ -26,6 +26,7 @@ using System.ComponentModel; using Newtonsoft.Json.Linq; using S7.Net; +using System.Threading.Tasks; namespace HH.WCS.JuShi.process { @@ -823,6 +824,53 @@ { list.RemoveAll(s => loca.Contains(s.S_CODE)); } + // 3. 濡傛灉鏄珛搴撳叆搴撳尯锛屾鏌�PLC 鏄惁鍏佽鍗歌浇 + var reservoirs = Settings.ReservoirAreas.FirstOrDefault(s => s.areaName == "绔嬪簱鍏ュ簱鍖�); + if (reservoirs != null && reservoirs.areaCode.Equals(area)) + { + var plcDeviceTable = S7Helper.plcDeviceTables; + // 鍏堟敹闆嗚绉婚櫎鐨勮揣浣嶏紝閬垮厤鍦ㄩ亶鍘嗘椂淇敼闆嗗悎 + List<Location> locationsToRemove = new List<Location>(); + + foreach (var location in list) + { + var safeInteraction = Settings.SafeInteractions.FirstOrDefault(s => s.location == location.S_CODE); + if (safeInteraction != null) + { + // 妫�煡 PLC 鏄惁鍏佽鍗歌浇锛堝彇绗簩浣嶆暟瀛楋紝鍒ゆ柇鏄惁涓�1锛�+ string allowUnloadStr = plcDeviceTable.RGVAllowUnload[safeInteraction.code].ToString(); + int allowUnload = int.Parse(allowUnloadStr.Substring(1, 1)); + + if (allowUnload != 1) + { + locationsToRemove.Add(location); // 涓嶅厑璁稿嵏杞斤紝鍔犲叆寰呯Щ闄ゅ垪琛�+ } + } + } + + // 閬嶅巻缁撴潫鍚庯紝鍐嶇粺涓�Щ闄や笉绗﹀悎鏉′欢鐨勮揣浣�+ foreach (var locToRemove in locationsToRemove) + { + list.Remove(locToRemove); + } + } + ////杩囨护涓�笅 鍏佽杩涘叆鐨勬墠鍒嗛厤 + //var reservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "绔嬪簱鍏ュ簱鍖�).FirstOrDefault(); + //if (reservoirs.areaCode.Equals(area)) + //{ + // var plcDeviceTable = S7Helper.plcDeviceTables; + // foreach (var l in list) + // { + // var safeInteraction = Settings.SafeInteractions.Where(s => s.location == l.S_CODE).FirstOrDefault(); + // var res = int.Parse(plcDeviceTable.RGVAllowUnload[safeInteraction.code].ToString().Substring(1, 1)); + // if (res!=1) + // { + // list.Remove(l); + // } + // } + //} + + //绗﹀悎鏉′欢鐨勬帓搴忛�绗竴涓� 鍏堟壘绗竴涓� if (list.Count > 0) { @@ -1762,7 +1810,7 @@ { LogHelper.Info($"RGV瀹夊叏浜や簰 璇锋眰鐐逛綅锛歿model.STATION_NAME}璇锋眰鐮侊細{model.APPLY_CODE}"); //澶勭悊淇″彿 - var res =int.Parse(plcDeviceTable.RGVAllowUnload[reservoirs.code].ToString().Substring(1, 1)); + var res = int.Parse(plcDeviceTable.RGVAllowUnload[reservoirs.code].ToString().Substring(1, 1)); //鏍规嵁ip璇荤姸鎬� LogHelper.Info($"RGV瀹夊叏浜や簰缂撳瓨淇″彿{res}锛寋JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}"); //鍗歌揣璇锋眰杩涘叆 @@ -1779,7 +1827,20 @@ else if (model.APPLY_CODE.Equals("8")) { //鍙戦�鍗歌揣瀹屾垚銆佸浣嶄俊鍙�- safeAssistant(reservoirs.code,res); + //鍗歌揣瀹屾垚淇″彿 + S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10 + 1)); + + // 鍚姩鍚庡彴浠诲姟澶勭悊寤惰繜澶嶄綅 + Task.Run(async () => + { + //10绉掑悗澶嶄綅 + await Task.Delay(10000); + S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10)); + LogHelper.Info($"RGV瀹夊叏浜や簰 澶嶄綅瀹屾垚"); + }); + //10绉掑悗澶嶄綅 + //S7Helper.WriteInt(50, reservoirs.code * 2 - 2, (short)(reservoirs.code * 10)); + //safeAssistant(reservoirs.code, res); LogHelper.Info($"RGV瀹夊叏浜や簰 鍗歌揣瀹屾垚"); return new safeResult() { code = "0", msg = "success" }; } @@ -1862,19 +1923,23 @@ } } //寰幆鍙戦�淇″彿 - private static void safeAssistant(int code,int res) { - //2鍗歌揣瀹屾垚纭 - if (res != 2) - { - //鍗歌揣瀹屾垚淇″彿 - S7Helper.WriteInt(50, 0, (short)(code * 10 + 1)); - Thread.Sleep(3000); - safeAssistant(code,res); - } - else - { - S7Helper.WriteInt(50, 0, (short)(code * 10)); - } + private static void safeAssistant(int code, int res) + { + Thread.Sleep(10000); + S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10)); + LogHelper.Info($"RGV瀹夊叏浜や簰 澶嶄綅瀹屾垚"); + ////2鍗歌揣瀹屾垚纭 + //if (res != 2) + //{ + // //鍗歌揣瀹屾垚淇″彿 + // S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10 + 1)); + // Thread.Sleep(3000); + // safeAssistant(code, res); + //} + //else + //{ + // S7Helper.WriteInt(50, code * 2 - 2, (short)(code * 10)); + //} } -- Gitblit v1.9.1