From ef83aea1ac3325003b4ed8cddd23d295c6a01b1d Mon Sep 17 00:00:00 2001
From: zxx <Zxx@HanInfo>
Date: 星期一, 09 六月 2025 17:31:56 +0800
Subject: [PATCH] jushi

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs |  666 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 516 insertions(+), 150 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 b36f0fd..79e9833 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JuShi/process/TaskProcess.cs
@@ -20,6 +20,13 @@
 using Opc.Ua;
 using System.Collections;
 using System.Xml.Linq;
+using System.Threading;
+using static HH.WCS.JuShi.dispatch.NDC;
+using static HH.WCS.JuShi.util.Settings;
+using System.ComponentModel;
+using Newtonsoft.Json.Linq;
+using S7.Net;
+using System.Threading.Tasks;
 
 namespace HH.WCS.JuShi.process
 {
@@ -99,17 +106,129 @@
         /// <param name="state"></param>
         internal static void OperateStatus(WCSTask mst, int state)
         {
-            if (state == 4)
+            if (state == 4)//鍙栬揣瀹屾垚
             {
                 CacheBitUpdate(mst, true);
+                //鎷嗘墭鏈哄畨鍏ㄤ氦浜�+                //ctjSafe(mst);
+
             }
             if (state == 6)//鍗歌揣瀹屾垚
             {
                 CacheBitUpdate(mst, false);
+                ////rgv瀹夊叏浜や簰
+                //rgvSafe(mst);
+                ////鎷嗘墭鏈哄畨鍏ㄤ氦浜�+                //ctjSafe(mst);
+
             }
             if (state == 7)
             {
                 CacheBitCancelUpdate(mst);
+            }
+        }
+        //rgv瀹夊叏浜や簰
+        private static void rgvSafe(WCSTask mst)
+        {
+            //rgv瀹夊叏浜や簰  鏍规嵁缁堢偣璐т綅鎵惧埌鏄摢涓猺gv
+            var reservoir = Settings.ReservoirAreas.Where(a => a.areaName == "绔嬪簱鍏ュ簱鍖�).FirstOrDefault();
+            if (mst.S_END_AREA.Equals(reservoir.areaCode))
+            {
+                var safeInteractions = Settings.SafeInteractions.Where(a => a.location == mst.S_END_LOC).FirstOrDefault();
+                var rgvSafeInteraction = DeviceProcess.rgvSafeInteraction;
+                //澶勭悊淇″彿
+                var startsub = safeInteractions.code;
+                var res = rgvSafeInteraction.Substring((startsub - 1) * 2 + 1, 1);
+                //var safelists = JsonConvert.DeserializeObject<List<SafeInteraction>>(DeviceProcess.rgvSafeInteraction);
+                LogHelper.Info($"RGV瀹夊叏浜や簰缂撳瓨淇″彿{rgvSafeInteraction}");
+                //涓嶇瓑浜�2鍗歌揣瀹屾垚纭淇″彿 灏辨帴鐫�彂
+                if (res != "2")
+                {
+                    string datastr = "3f001020304050600d0a";
+                    string a = ((startsub - 1) * 2).ToString();
+                    //杩斿洖淇″彿澶勭悊
+                    datastr = datastr.Replace(a + "0", a + "1");
+
+                    LogHelper.Info($"RGV瀹夊叏浜や簰鍙戦�淇″彿{safeInteractions.ip},{datastr}");
+                    PlcHelper.SendHex(safeInteractions.ip, datastr);
+                    //浼戠湢3绉掑啀璋�+                    Thread.Sleep(3000);
+                    rgvSafe(mst);
+                }
+                else
+                {
+                    //浼戠湢10绉掑啀鍙戜俊鍙�锛堢粰鐜板満璁惧鍚稿悎鏃堕棿璇存槸锛�+                    Thread.Sleep(10000);
+                    LogHelper.Info($"RGV瀹夊叏浜や簰鍙戦�淇″彿{safeInteractions.ip},3f001020304050600d0a");
+                    //鏃犵姸鎬佷俊鍙�+                    PlcHelper.SendHex(safeInteractions.ip, "3f001020304050600d0a");
+
+                }
+            }
+        }
+        //鎷嗘墭鏈哄畨鍏ㄤ氦浜�+        private static void ctjSafe(WCSTask mst)
+        {
+            PlcDeviceTable plcDeviceTable = S7Helper.plcDeviceTables;
+            string deviceno = null;//绾夸綋
+            //鎵惧埌绾夸綋 鏍规嵁绾夸綋鎵惧唴瀛橀噷鐨勭姸鎬�+            var rkreservoirs = Settings.ConveyorLinesInfos.Where(s => s.location == mst.S_END_LOC).FirstOrDefault();
+            var ckreservoirs = Settings.ConveyorLinesInfos.Where(s => s.location == mst.S_START_LOC).FirstOrDefault();
+            //鍏ュ彛
+            if (rkreservoirs != null)
+            {
+                if (rkreservoirs.deviceNo == "1")
+                {
+                    deviceno = "1";
+                }
+                else if (rkreservoirs.deviceNo == "2")
+                {
+                    deviceno = "4";
+                }
+            }
+            //鍑哄彛
+            else if (ckreservoirs != null)
+            {
+                if (ckreservoirs.deviceNo == "1")
+                {
+                    deviceno = "3";
+                }
+                else if (rkreservoirs.deviceNo == "2")
+                {
+                    deviceno = "6";
+                }
+            }
+            LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜掑啓鍏ュ弬鏁皗deviceno},{JsonConvert.SerializeObject(plcDeviceTable)}");
+            if (plcDeviceTable != null && deviceno != null)
+            {
+                //var plcDeviceTables = S7Helper.plcDeviceTables.Where(s => s.DeviceNo == plcDeviceTable.DeviceNo);
+
+                //s7鍐欏叆
+                int addr = 182;         //鍋忕Щ閲�+                int offsetAddr = 0;         //鍋忕Щ閲�+                string deviceNo = null;//鎷嗘墭鏈哄彿
+                if (deviceno == "3")
+                {
+                    offsetAddr = 1;
+                    deviceNo = "1";
+                }
+                else if (deviceno == "6")
+                {
+                    offsetAddr = 3;
+                    deviceNo = "2";
+                }
+                else if (deviceno == "1")
+                {
+                    offsetAddr = 0;
+                    deviceNo = "1";
+                }
+                else if (deviceno == "4")
+                {
+                    offsetAddr = 2;
+                    deviceNo = "2";
+                }
+                LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜掑啓鍏deviceNo}锛寋addr}");
+                S7Helper.WriteDouble(deviceNo, 9, addr, offsetAddr, 1);
             }
         }
 
@@ -316,70 +435,45 @@
                     string parmeD = "}";
                     string parme = parmeS + src + dst + parmeD;
                     int res = 0;
-                    if (mst.S_TYPE == "鍛煎彨绌烘墭" || mst.S_TYPE == "鎸夐挳鐩掕皟鐢ㄧ┖鎵� || mst.S_TYPE == "鎷嗘墭")
-                    {
-                        PlcDeviceTable plcDeviceTable = null;
-                        //鎵惧埌绾夸綋 鏍规嵁绾夸綋鎵惧唴瀛橀噷鐨勭姸鎬�-                        var reservoirs1 = Settings.ConveyorLinesInfos.Where(s => s.location == startLoc.S_CODE).FirstOrDefault();
-                        plcDeviceTable = S7Helper.plcDeviceTables.Find(a => a.DeviceNo == reservoirs1.code);
-                        if (plcDeviceTable != null)
-                        {
-                            if (mst.S_TYPE == "鍛煎彨绌烘墭" || mst.S_TYPE == "鎸夐挳鐩掕皟鐢ㄧ┖鎵�)
-                            {
-                                LogHelper.Info($"鍛煎彨绌烘墭鐘舵�鍙傛暟{JsonConvert.SerializeObject(plcDeviceTable)}", "浠诲姟");
-                                //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀湁鎵樼洏涓旇姹傚彇妗嗘墠璧�-                                if (plcDeviceTable.workMode == 1 && plcDeviceTable.lightAction == 1 && plcDeviceTable.requestTake)
-                                {
-                                    LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
-                                    res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
-                                }
-                            }
-                            else if (mst.S_TYPE == "鎷嗘墭")
-                            {
-                                LogHelper.Info($"鎷嗘墭鐘舵�鍙傛暟{JsonConvert.SerializeObject(plcDeviceTable)}", "浠诲姟");
-                                //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀棤鎵樼洏涓斿厑璁告斁妗嗘墠璧�-                                if (plcDeviceTable.workMode == 1 && plcDeviceTable.lightAction == 0 && plcDeviceTable.requestPut)
-                                {
-                                    LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
-                                    res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
-                                }
-                            }
-                            //浠诲姟瀹屾垚鍐欏叆s7
-                            if (res > 0)
-                            {
-                                //s7鍐欏叆 agv鍙栨瀹屾垚
-                                double addr = 0;         //鍋忕Щ閲�-                                string deviceNo = null;//鎷嗘墭鏈哄彿
-                                if (plcDeviceTable.DeviceNo == 1003)
-                                {
-                                    addr = 90.1;
-                                    deviceNo = "1";
-                                }
-                                else if (plcDeviceTable.DeviceNo == 1006)
-                                {
-                                    addr = 180.1;
-                                    deviceNo = "2";
-                                }
-                                else if (plcDeviceTable.DeviceNo == 1001)
-                                {
-                                    addr = 30.0;
-                                    deviceNo = "1";
-                                }
-                                else if (plcDeviceTable.DeviceNo == 1004)
-                                {
-                                    addr = 120.0;
-                                    deviceNo = "2";
-                                }
-                                S7Helper.WriteDouble(deviceNo, 9, addr, 1);
-
-                            }
-                        }
-                    }
-                    else
-                    {
-                        LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
-                        res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
-                    }
+                    LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
+                    res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
+                    #region
+                    //if (mst.S_TYPE == "鍛煎彨绌烘墭" || mst.S_TYPE == "鎸夐挳鐩掕皟鐢ㄧ┖鎵� || mst.S_TYPE == "鎷嗘墭")
+                    //{
+                    //    PlcDeviceTable plcDeviceTable = null;
+                    //    //鎵惧埌绾夸綋 鏍规嵁绾夸綋鎵惧唴瀛橀噷鐨勭姸鎬�+                    //    var reservoirs1 = Settings.ConveyorLinesInfos.Where(s => s.location == startLoc.S_CODE).FirstOrDefault();
+                    //    plcDeviceTable = S7Helper.plcDeviceTables.Find(a => a.DeviceNo == reservoirs1.code);
+                    //    if (plcDeviceTable != null)
+                    //    {
+                    //        if (mst.S_TYPE == "鍛煎彨绌烘墭" || mst.S_TYPE == "鎸夐挳鐩掕皟鐢ㄧ┖鎵�)
+                    //        {
+                    //            LogHelper.Info($"鍛煎彨绌烘墭鐘舵�鍙傛暟{JsonConvert.SerializeObject(plcDeviceTable)}", "浠诲姟");
+                    //            //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀湁鎵樼洏涓旇姹傚彇妗嗘墠璧�+                    //            if (plcDeviceTable.workMode == 1 && plcDeviceTable.lightAction == 1 && plcDeviceTable.requestTake)
+                    //            {
+                    //                LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
+                    //                res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
+                    //            }
+                    //        }
+                    //        else if (mst.S_TYPE == "鎷嗘墭")
+                    //        {
+                    //            LogHelper.Info($"鎷嗘墭鐘舵�鍙傛暟{JsonConvert.SerializeObject(plcDeviceTable)}", "浠诲姟");
+                    //            //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀棤鎵樼洏涓斿厑璁告斁妗嗘墠璧�+                    //            if (plcDeviceTable.workMode == 1 && plcDeviceTable.lightAction == 0 && plcDeviceTable.requestPut)
+                    //            {
+                    //                LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
+                    //                res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
+                    //            }
+                    //        }
+                    //    }
+                    //}
+                    //else
+                    //{
+                    //    LogHelper.Info($"鎺ㄩ�浠诲姟鍙傛暟{parme}", "浠诲姟");
+                    //    res = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, parme);
+                    //}
+                    #endregion
                     if (res > 0)
                     {
                         //鏇存柊浠诲姟鐘舵�
@@ -690,11 +784,6 @@
 
             return result;
 
-
-
-
-
-            return result;
         }
 
         #endregion
@@ -713,16 +802,17 @@
             {
                 //鏌ヨ杩欎釜搴撳尯鐨勭┖鎵樼洏涓庢弧鎵樼洏
                 var list = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == area).OrderByDescending(a => a.N_ROW).ToList();
-                LogHelper.Info($"鏌ヨ杩欎釜搴撳尯鐨勭┖鎵樼洏涓庢弧鎵樼洏锛歿JsonConvert.SerializeObject(list)}");
+                //LogHelper.Info($"鏌ヨ杩欎釜搴撳尯鐨勭┖鎵樼洏涓庢弧鎵樼洏锛歿JsonConvert.SerializeObject(list)}");
                 if (list.Count > 0)
                 {
                     List<string> loca = new List<string>();
                     for (int i = 0; i < list.Count; i++)
                     {
                         //濡傛灉閿佷簡鎴栬�瀹归噺婊′簡                   褰撳墠鏁伴噺                 瀹瑰櫒瀹归噺
-                        if (list[i].N_LOCK_STATE != 0 || list[i].N_CURRENT_NUM >= list[i].N_CAPACITY)
+                        if (list[i].N_LOCK_STATE != 0|| list[i].C_ENABLE != "Y" || list[i].N_CURRENT_NUM >= list[i].N_CAPACITY)
                         {
                             loca.Add(list[i].S_CODE);
+                            LogHelper.Info($"InWorkTransport  婊℃垨鑰呴攣涓婄殑璐т綅锛歿list[i].S_CODE}锛岀姸鎬亄list[i].N_LOCK_STATE}");
                         }
                     }
                     //绉婚櫎
@@ -730,11 +820,54 @@
                     {
                         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);
+                        }
+                    }
 
                     //绗﹀悎鏉′欢鐨勬帓搴忛�绗竴涓� 鍏堟壘绗竴涓�                     if (list.Count > 0)
                     {
-                        result = list.OrderBy(s => s.N_ROW).ThenBy(x => x.N_COL).FirstOrDefault();
+                        //绔嬪簱鐨勯殢鏈哄垎閰�+                        if (reservoirs != null && reservoirs.areaCode.Equals(area))
+                        {
+                            // 绔嬪簱闅忔満鍒嗛厤绠楁硶
+                            var random = new Random();
+                            result = list.OrderBy(x => random.Next()).FirstOrDefault();
+                            LogHelper.Info($"绔嬪簱闅忔満鍒嗛厤閫夋嫨璐т綅锛歿result?.S_CODE},鐘舵�{result?.N_LOCK_STATE}");
+
+                        }
+                        else
+                        {
+                            result = list.OrderBy(s => s.N_ROW).ThenBy(x => x.N_COL).FirstOrDefault();
+                        }
+
                     }
                 }
 
@@ -765,7 +898,7 @@
                 for (int i = 0; i < list.Count; i++)
                 {
                     //鍒ゆ柇璐т綅鏄惁琚攣浣忎簡 涓�鏄惁鏈夋墭鐩�-                    if (list[i].N_LOCK_STATE == 0)
+                    if (list[i].N_LOCK_STATE == 0&& list[i].C_ENABLE =="Y")
                     {
                         var locCntrRel = db.Queryable<LocCntrRel>().Where(s => s.S_LOC_CODE == list[i].S_CODE).First();
 
@@ -842,7 +975,7 @@
         {
             return locations
                 .Where(l => targetAreas.Any(area => l.S_CODE.Contains(area)))
-                .Where(l => l.N_LOCK_STATE == 0 && l.N_CURRENT_NUM < l.N_CAPACITY)
+                .Where(l => l.N_LOCK_STATE == 0&& l.C_ENABLE == "Y" && l.N_CURRENT_NUM < l.N_CAPACITY)
                 .ToList();
         }
 
@@ -871,7 +1004,7 @@
                         result = db.Queryable<Location>().OrderBy(a => a.N_COL)
                             .Where(a => a.S_AREA_CODE.Trim() == area && a.N_ROW == list[i].N_ROW
                             && a.N_COL > list[i].N_COL).First();
-                        if (result != null && result.N_LOCK_STATE == 0)
+                        if (result != null && result.N_LOCK_STATE == 0 && result.C_ENABLE == "Y")
                         {
                             return result;
                         }
@@ -881,7 +1014,7 @@
                 else
                 {
                     result = db.Queryable<Location>().
-                    Where(a => a.S_AREA_CODE.Trim() == area && a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0)
+                    Where(a => a.S_AREA_CODE.Trim() == area && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == 0)
                     .OrderBy(a => a.N_COL).OrderBy(a => a.N_ROW).First();
                 }
             }
@@ -1078,7 +1211,7 @@
             {
                 //鏍¢獙璧风偣璐т綅鏄惁瀛樺湪/閿佷綇
                 var loc = db.Queryable<Location>().Where(a => a.S_CODE == model.START_LOC).First();
-                if (loc == null || loc.N_LOCK_STATE != 0)
+                if (loc == null || loc.N_LOCK_STATE != 0 || loc.C_ENABLE != "Y")
                 {
                     return new Results { Code = "1", Message = $"{model.START_LOC}搴撲綅宸茶閿佸畾!", Data = null };
                 }
@@ -1164,7 +1297,7 @@
                 }
                 //鏍¢獙缁堢偣璐т綅鏄惁瀛樺湪/閿佸畾
                 var loc = db.Queryable<Location>().Where(a => a.S_CODE == model.END_LOC).First();
-                if (loc == null || loc.N_LOCK_STATE != 0)
+                if (loc == null || loc.N_LOCK_STATE != 0 || loc.C_ENABLE != "Y")
                 {
                     return new Results { Code = "1", Message = $"{model.END_LOC}搴撲綅宸茶閿佸畾!", Data = null };
                 }
@@ -1219,7 +1352,7 @@
                 if (!string.IsNullOrEmpty(model.START_LOC))
                 {
                     var loc = db.Queryable<Location>().Where(a => a.S_CODE == model.START_LOC).First();
-                    if (loc == null || loc.N_LOCK_STATE != 0)
+                    if (loc == null || loc.N_LOCK_STATE != 0 || loc.C_ENABLE != "Y")
                     {
                         return new Results { Code = "1", Message = $"{model.START_LOC}搴撲綅宸茶閿佸畾!", Data = null };
                     }
@@ -1263,17 +1396,16 @@
             try
             {
                 var db = new SqlHelper<object>().GetInstance();
-                //涓夎〃鑱旀煡鏌ュ嚭鏈夎鐗╂枡鐨勮揣浣嶇紪鍙�
+                //涓よ〃鑱旀煡鏌ュ嚭鏈夎鐗╂枡鐨勮揣浣嶇紪鍙� 锛堢幇鍦烘病鏈夌墿鏂欒〃锛�                 var locCntrs = db.Queryable<LocCntrRel>().LeftJoin<CntrItemDetail>((p, m) => p.S_CNTR_CODE == m.S_CNTR_CODE)
-                .LeftJoin<TN_Material>((p, m, s) => m.S_ITEM_CODE == s.S_ITEM_CODE)
-                .Where((p, m, s) => s.S_ITEM_CODE == itemCode)
-                .OrderBy((p, m, s) => p.T_CREATE)  //鎸夊垱寤烘椂闂撮『搴�-                .Select((p, m, s) => p.S_LOC_CODE) // 閫夋嫨鎵樼洏鐗╂枡琛ㄧ殑鏁版嵁
+                .Where((p, m) => m.S_ITEM_CODE == itemCode)
+                .OrderBy((p, m) => p.T_CREATE)  //鎸夊垱寤烘椂闂撮『搴�+                .Select((p, m) => p.S_LOC_CODE) // 閫夋嫨鎵樼洏鐗╂枡琛ㄧ殑鏁版嵁
                 .ToList();
                 LogHelper.Info($"鏈夌墿鏂檣itemCode}鐨勮揣浣嶇紪鍙穥JsonConvert.SerializeObject(locCntrs)}");
                 //鎵惧父瑙勯�妫�尯鍐呭惈鏈夋煡鍑虹墿鏂欒揣浣嶇殑璐т綅
                 var locList = db.Queryable<Location>()
-                    .Where(p => p.S_AREA_CODE == areaCode && p.N_LOCK_STATE == 0)
+                    .Where(p => p.S_AREA_CODE == areaCode && p.N_LOCK_STATE == 0 && p.C_ENABLE == "Y")
                     .Where(s => locCntrs.Contains(s.S_CODE.Trim()))
                     .ToList();
 
@@ -1302,7 +1434,7 @@
         internal static Results UpdateFullStatus(List<CameraMonitor> models)
         {
             var result = new Results() { Code = "0", Message = "鎿嶄綔鎴愬姛", Data = null };
-            var db = new SqlHelper<Location>().GetInstance();
+            var db = new SqlHelper<object>().GetInstance();
             //鏍¢獙涓庡唴瀛樻槸鍚︿竴鑷�             if (monitorStatus != null)
             {
@@ -1319,7 +1451,7 @@
                         //鎵惧埌璇ョ偣浣嶇殑搴撳尯
                         var loc = db.Queryable<Location>().Where(a => a.S_CODE == model.PointCode).First();
                         //娌¢攣鍐嶇户缁蛋
-                        if (loc.N_LOCK_STATE == 0 && loc != null)
+                        if (loc.N_LOCK_STATE == 0 && loc.C_ENABLE =="Y" && loc != null)
                         {
                             var reservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "閫佹鍏ュ簱鍖�).FirstOrDefault();
                             //濡傛灉鏄�妫�叆搴撳尯
@@ -1388,40 +1520,50 @@
         //鎽勫儚澶寸洃娴嬬┖鎵樼紦瀛樺尯
         private static void ProcessEmptyTrayAreas(SqlSugar.ISqlSugarClient db, Location loc, string areaCode1, string areaCode2)
         {
-            var plcDeviceTable = new PlcDeviceTable();
-            string endLoc = null;
-            if (loc.S_AREA_CODE.Equals(areaCode1))
+            var plcDeviceTable = S7Helper.plcDeviceTables;
+            if (plcDeviceTable != null)
             {
-                plcDeviceTable = S7Helper.plcDeviceTables.Find(s => s.DeviceNo == 1001);
-                endLoc = Settings.linePlcInfos.Where(s => s.code == "鎷嗘墭鏈�").FirstOrDefault().inLoca;
-            }
-            else if (loc.S_AREA_CODE.Equals(areaCode2))//鍏绌烘墭
-            {
-                plcDeviceTable = S7Helper.plcDeviceTables.Find(s => s.DeviceNo == 1004);
-                endLoc = Settings.linePlcInfos.Where(s => s.code == "鎷嗘墭鏈�").FirstOrDefault().inLoca;
-            }
-            //鍒ゆ柇鏄惁鍏佽鏀炬
-            if (plcDeviceTable.workMode == 1 && plcDeviceTable.lightAction == 0 && plcDeviceTable.requestPut)
-            {
-                //鍒涘缓浠诲姟 浠庣┖鎵樼紦瀛樺尯鍙変釜鏂欏埌鎷嗘墭鏈�-                var list = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == loc.S_AREA_CODE
-                && a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_ROW)
-                .OrderByDescending(a => a.N_COL).First();
-                var startLoc = list.S_CODE;
-
-                string trayCode = ContainerHelper.GenerateCntrNo();
-
-                LogHelper.Info($"鍒涘缓浠诲姟 璧风偣:{startLoc}缁堢偣:{endLoc}", "鎷嗘墭");
-                var res = TaskProcess.CreateTransport(startLoc, endLoc, "鎷嗘墭", trayCode, 1, 1);
-                if (res)
+                string endLoc = null;
+                bool request = false;
+                if (loc.S_AREA_CODE.Equals(areaCode1))
                 {
-                    LogHelper.Info($"璧风偣:{startLoc}缁堢偣:{endLoc}浠诲姟鍒涘缓鎴愬姛", "鎷嗘墭");
+                    request = plcDeviceTable.requestPut1;
+                    endLoc = Settings.linePlcInfos.Where(s => s.code == "鎷嗘墭鏈�").FirstOrDefault().inLoca;
                 }
-                else
+                else if (loc.S_AREA_CODE.Equals(areaCode2))//鍏绌烘墭
                 {
-                    LogHelper.Info($"璧风偣:{startLoc}缁堢偣:{endLoc}浠诲姟鍒涘缓澶辫触", "鎷嗘墭");
+                    request = plcDeviceTable.requestPut2;
+                    endLoc = Settings.linePlcInfos.Where(s => s.code == "鎷嗘墭鏈�").FirstOrDefault().inLoca;
+                }
+                //鍒ゆ柇鏄惁鍏佽鏀炬
+                if (request)
+                {
+                    //鍒涘缓浠诲姟 浠庣┖鎵樼紦瀛樺尯鍒版媶鎵樻満
+                    var list = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == loc.S_AREA_CODE
+                    && a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y").OrderByDescending(a => a.N_ROW)
+                    .OrderByDescending(a => a.N_COL).First();
+                    var startLoc = list.S_CODE;
+
+                    string trayCode = ContainerHelper.GenerateCntrNo();
+
+                    LogHelper.Info($"鍒涘缓浠诲姟 璧风偣:{startLoc}缁堢偣:{endLoc}", "鎷嗘墭");
+                    var res = TaskProcess.CreateTransport(startLoc, endLoc, "鎷嗘墭", trayCode, 1, 1);
+                    if (res)
+                    {
+                        LogHelper.Info($"璧风偣:{startLoc}缁堢偣:{endLoc}浠诲姟鍒涘缓鎴愬姛", "鎷嗘墭");
+                    }
+                    else
+                    {
+                        LogHelper.Info($"璧风偣:{startLoc}缁堢偣:{endLoc}浠诲姟鍒涘缓澶辫触", "鎷嗘墭");
+                    }
                 }
             }
+            else
+            {
+                LogHelper.Info($"鏈鍙栧埌鎷嗘墭鏈轰俊鍙�, "鎷嗘墭");
+
+            }
+
         }
         /// <summary>
         /// 鎶芥涓诲姩鍛煎彨    璧风偣锛氶�妫�紦瀛樺尯
@@ -1438,13 +1580,13 @@
                 //鏍规嵁鐗╂枡鎵炬煇搴撳尯鐨勮揣浣�                 var cgreservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "閫佹缂撳瓨鍖�).FirstOrDefault();
                 var startloc = getLocByMaterial(model.S_ITEM_CODE, cgreservoirs.areaCode);
-                if (startloc==null)
+                if (startloc == null)
                 {
                     return new Results { Code = "1", Message = $"鏈壘鍒板寘鍚墿鏂檣model.S_ITEM_CODE}鐨勮揣浣�, Data = null };
                 }
                 //缁堢偣
                 var endloc = db.Queryable<Location>().Where(a => a.S_CODE == model.END_LOC).First();
-                if (endloc == null || endloc.N_LOCK_STATE != 0)
+                if (endloc == null || endloc.N_LOCK_STATE != 0 || endloc.C_ENABLE != "Y")
                 {
                     return new Results { Code = "1", Message = $"{model.END_LOC}搴撲綅宸茶閿佸畾!", Data = null };
                 }
@@ -1467,7 +1609,86 @@
                 throw;
             }
         }
+        /// <summary>
+        /// 涓诲姩鐗╂枡缁戝畾
+        /// </summary>
+        /// <param name="model.S_ITEM_CODE">鐗╂枡缂栫爜(閫夊~)</param>
+        /// <param name="model.BIND_LOC">缁戝畾璐т綅</param>
+        /// <returns></returns>
+        internal static Results bindMaterial(GetSubmitCheck model)
+        {
+            var result = new Results() { Code = "0", Message = "鐗╂枡缁戝畾鎴愬姛锛�, Data = null };
+            var db = new SqlHelper<object>().GetInstance();
+            try
+            {
+                var loc = db.Queryable<Location>().Where(a => a.S_CODE == model.BIND_LOC).First();
+                if (loc == null || loc.N_LOCK_STATE != 0 || loc.C_ENABLE != "Y")
+                {
+                    return new Results { Code = "1", Message = $"缁戝畾璐т綅涓嶅瓨鍦ㄦ垨宸茶閿�, Data = null };
 
+                }
+                string cntrStr = ContainerHelper.GenerateCntrNo();
+                var locCntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == model.BIND_LOC).First();
+                if (locCntrRel != null)
+                {
+                    cntrStr = locCntrRel.S_CNTR_CODE;
+                }
+                var res = ContainerHelper.BindLocCntrs(model.BIND_LOC, cntrStr, model.S_ITEM_CODE, "甯冨嵎");
+                if (!res)
+                {
+                    return new Results { Code = "1", Message = $"鐗╂枡{model.S_ITEM_CODE}璐т綅{model.BIND_LOC}缁戝畾澶辫触", Data = null };
+                }
+                loc.N_CURRENT_NUM++;
+                var res2 = db.Updateable(loc).UpdateColumns(it => it.N_CURRENT_NUM).ExecuteCommand() > 0;
+                if (!res2)
+                {
+                    return new Results { Code = "1", Message = $"璐т綅{model.BIND_LOC}褰撳墠鏁伴噺鑷澶辫触", Data = null };
+                }
+                return result;
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("bindMaterial:" + ex.Message + ex.StackTrace);
+                LogHelper.Error("bindMaterial:" + ex.Message, ex);
+                throw;
+            }
+        }
+        /// <summary>
+        /// 鏁存帓鐗╂枡缁戝畾
+        /// </summary>
+        /// <param name="bondLoc">缁戝畾璐т綅</param>
+        /// <returns></returns>
+        internal static Results multBindMaterial(string bondLoc)
+        {
+            var result = new Results() { Code = "0", Message = "鏁存帓鐗╂枡缁戝畾鎴愬姛锛�, Data = null };
+            var db = new SqlHelper<object>().GetInstance();
+            try
+            {
+                var location = db.Queryable<Location>().Where(a => a.S_CODE == bondLoc).First();
+                //鏌ュ嚭杩欎竴鎺掔殑璐т綅
+                var loclist = db.Queryable<Location>()
+                    .Where(a => a.S_AREA_CODE == location.S_AREA_CODE && a.N_ROW == location.N_ROW).ToList();
+                foreach (var loc in loclist)
+                {
+                    //娌¢攣鐨勪笖娌¤揣鐨勬墠缁�+                    if (loc.N_LOCK_STATE == 0 && loc.N_CURRENT_NUM < loc.N_CAPACITY)
+                    {
+
+
+                    }
+
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("multBindMaterial:" + ex.Message + ex.StackTrace);
+                LogHelper.Error("multBindMaterial:" + ex.Message, ex);
+                throw;
+            }
+
+
+            return result;
+        }
         /// <summary>
         /// 鎸夐挳鐩掕皟鐢ㄤ笅绾�         /// </summary>
@@ -1478,11 +1699,12 @@
         {
             var db = new SqlHelper<Location>().GetInstance();
 
+            LogHelper.Info($"tcpOffline=====鍙傛暟:璧风偣璐т綅{startLoc}缁堢偣搴撳尯{endArea}");
             try
             {
                 //鏍¢獙璧风偣璐т綅鏄惁瀛樺湪/閿佷綇
                 var loc = db.Queryable<Location>().Where(a => a.S_CODE == startLoc).First();
-                if (loc == null || loc.N_LOCK_STATE != 0)
+                if (loc == null || loc.N_LOCK_STATE != 0 || loc.C_ENABLE != "Y")
                 {
                     LogHelper.Info("璧风偣璐т綅涓嶅瓨鍦ㄦ垨宸查攣" + startLoc);
                     return false;
@@ -1513,6 +1735,11 @@
                 //    itemCode = model.S_ITEM_CODE;
                 //    wlName = db.Queryable<TN_Material>().Where(b => b.S_ITEM_CODE == model.S_ITEM_CODE).First().S_ITEM_NAME;
                 //}
+                if (OutLoc==null)
+                {
+                    LogHelper.Info($"缁堢偣璐т綅涓嶅瓨鍦�, "鎸夐挳鐩掍笅绾�);
+                    return false;
+                }
                 ContainerHelper.BindLocCntrs(OutLoc.S_CODE, trayCode, itemCode, wlName);
                 //鍒涘缓浠诲姟
                 LogHelper.Info($"鍒涘缓浠诲姟 璧风偣:{startLoc}缁堢偣:{OutLoc.S_CODE}", "鎸夐挳鐩掍笅绾�);
@@ -1521,8 +1748,8 @@
             }
             catch (Exception ex)
             {
-                Console.WriteLine("materialOffline:" + ex.Message + ex.StackTrace);
-                LogHelper.Error("materialOffline:" + ex.Message, ex);
+                Console.WriteLine("tcpOffline:" + ex.Message + ex.StackTrace);
+                LogHelper.Error("tcpOffline:" + ex.Message, ex);
                 throw;
             }
         }
@@ -1539,7 +1766,7 @@
             {
                 //鏍¢獙缁堢偣璐т綅鏄惁閿�                 var endloc = db.Queryable<Location>().Where(a => a.S_CODE == endLoc).First();
-                if (endloc == null || endloc.N_LOCK_STATE != 0)
+                if (endloc == null || endloc.N_LOCK_STATE != 0 || endloc.C_ENABLE != "Y")
                 {
                     LogHelper.Info("缁堢偣璐т綅宸查攣" + endLoc);
                     return false;
@@ -1570,40 +1797,122 @@
         {
             //0鍏佽杩涘叆 1涓嶅厑璁歌繘鍏�             var result = new safeResult() { code = "1", msg = "success" };
-            var db = new SqlHelper<Location>().GetInstance();
             try
             {
-                var reservoirs = Settings.SafeDoors.Where(s => s.pointCode == model.STATION_NAME).FirstOrDefault();//y0-0000 y1-0001  on-FF00  off-0000
-                TcpClient tcpClient = new TcpClient();
-                //璇锋眰杩涘叆
-                if (model.APPLY_CODE.Equals("1") || model.APPLY_CODE.Equals("5"))
+                var reservoirs = Settings.SafeInteractions.Where(s => s.location == model.STATION_NAME).FirstOrDefault();//y0-0000 y1-0001  on-FF00  off-0000
+                //var rgvSafeInteraction = DeviceProcess.rgvSafeInteraction;
+                var plcDeviceTable = S7Helper.plcDeviceTables;
+                if (plcDeviceTable != null)
                 {
-                    //鍙戦�淇″彿鍐欒姹傚紑闂�   
-                    var str = tcpClient.WriteSingleRegisterRtu("01050000FF008C3A", reservoirs.ip, int.Parse(reservoirs.port));
-                    //鍙戦�淇″彿璇婚棬鐘舵�
-                    var x0bool = tcpClient.ReadInputRegistersRtu("010200000001B9CA", reservoirs.ip, int.Parse(reservoirs.port));
-                    //濡傛灉寮�棬鍒颁綅
-                    if (x0bool)
+                    //RGV
+                    if (reservoirs.type.Equals("RGV"))
                     {
-                        return new safeResult() { code = "0", msg = "success" };
-                    }
-                }
-                //璇锋眰绂诲紑
-                else if (model.APPLY_CODE.Equals("4") || model.APPLY_CODE.Equals("8"))
-                {
-                    //鍙戦�淇″彿鍐欒姹傚叧闂�-                    var str = tcpClient.WriteSingleRegisterRtu("010500000000CDCA", reservoirs.ip, int.Parse(reservoirs.port));
-                    var str2 = tcpClient.WriteSingleRegisterRtu("01050001FF00DDFA", reservoirs.ip, int.Parse(reservoirs.port));
-                    //鍙戦�淇″彿璇婚棬鐘舵�
-                    var x0bool = tcpClient.ReadInputRegistersRtu("010200010001E80A", reservoirs.ip, int.Parse(reservoirs.port));
-                    //濡傛灉闂ㄥ凡鍏�-                    if (x0bool)
-                    {
-                        return new safeResult() { code = "0", msg = "success" };
-                    }
+                        LogHelper.Info($"RGV瀹夊叏浜や簰  璇锋眰鐐逛綅锛歿model.STATION_NAME}璇锋眰鐮侊細{model.APPLY_CODE}");
+                        //澶勭悊淇″彿
+                        var res = int.Parse(plcDeviceTable.RGVAllowUnload[reservoirs.code].ToString().Substring(1, 1));
+                        //鏍规嵁ip璇荤姸鎬�+                        LogHelper.Info($"RGV瀹夊叏浜や簰缂撳瓨淇″彿{res}锛寋JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}");
+                        //鍗歌揣璇锋眰杩涘叆
+                        if (model.APPLY_CODE.Equals("5"))
+                        {
+                            //1鍏佽鍗歌揣 
+                            if (res == 1)
+                            {
+                                LogHelper.Info($"RGV瀹夊叏浜や簰 鍏佽鍗歌揣");
+                                return new safeResult() { code = "0", msg = "success" };
+                            }
+                        }
+                        //鍗歌揣鍚庡凡绂诲紑
+                        else if (model.APPLY_CODE.Equals("8"))
+                        {
+                            //鍙戦�鍗歌揣瀹屾垚銆佸浣嶄俊鍙�+                            //鍗歌揣瀹屾垚淇″彿
+                            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" };
+                        }
+
+
+                    }
+                    //鎷嗘墭鏈�+                    else if (reservoirs.type.Equals("CTJ"))
+                    {
+                        LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜� 璇锋眰鐐逛綅锛歿model.STATION_NAME}璇锋眰鐮侊細{model.APPLY_CODE}");
+                        //鎵惧埌绾夸綋 鏍规嵁绾夸綋鎵惧唴瀛橀噷鐨勭姸鎬�+                        var reservoirs1 = Settings.ConveyorLinesInfos.Where(s => s.location == model.STATION_NAME).FirstOrDefault();
+
+                        LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜掑弬鏁皗JsonConvert.SerializeObject(plcDeviceTable)}");
+                        if (model.APPLY_CODE.Equals("1"))
+                        {
+                            //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀湁鎵樼洏涓旇姹傚彇妗嗘墠璧�+                            if ((reservoirs1.deviceNo == "1" && plcDeviceTable.requestTake1) ||
+                                (reservoirs1.deviceNo == "2" && plcDeviceTable.requestTake2))
+                            {
+                                LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜�鍏佽鍙栨");
+                                return new safeResult() { code = "0", msg = "success" };
+                            }
+
+                        }
+                        else if (model.APPLY_CODE.Equals("5"))
+                        {
+                            //0-鑴辨満鐘舵�锛�-寰呮満鐘舵�锛�-杩愯涓�   寰呮満涓旀棤鎵樼洏涓斿厑璁告斁妗嗘墠璧�+                            if ((reservoirs1.deviceNo == "1" && plcDeviceTable.requestPut1) ||
+                                (reservoirs1.deviceNo == "2" && plcDeviceTable.requestPut2))
+                            {
+                                LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜�鍏佽鏀炬");
+                                return new safeResult() { code = "0", msg = "success" };
+                            }
+                        }
+                        //鍙栬揣绂诲紑
+                        else if (model.APPLY_CODE.Equals("4"))
+                        {
+                            int offsetAddr = 8;
+                            if (reservoirs1.deviceNo == "1")
+                            {
+                                offsetAddr = 1;
+                            }
+                            else if (reservoirs1.deviceNo == "2")
+                            {
+                                offsetAddr = 3;
+                            }
+                            LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜掑啓鍏reservoirs1.deviceNo}锛寋offsetAddr}");
+                            S7Helper.WriteDouble(reservoirs1.deviceNo, 9, 182, offsetAddr, 1);
+                            LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜�鍙栨绂诲紑");
+                            return new safeResult() { code = "0", msg = "success" };
+                        }
+                        //鍗歌揣绂诲紑
+                        else if (model.APPLY_CODE.Equals("8"))
+                        {
+                            int offsetAddr = 8;//闅忎究缁欎竴涓�+                            if (reservoirs1.deviceNo == "1")
+                            {
+                                offsetAddr = 0;
+                            }
+                            else if (reservoirs1.deviceNo == "2")
+                            {
+                                offsetAddr = 2;
+                            }
+                            LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜掑啓鍏reservoirs1.deviceNo}锛寋offsetAddr}");
+                            S7Helper.WriteDouble(reservoirs1.deviceNo, 9, 182, offsetAddr, 1);
+                            LogHelper.Info($"鎷嗘墭鏈哄畨鍏ㄤ氦浜�鍙栨绂诲紑");
+                            return new safeResult() { code = "0", msg = "success" };
+                        }
+
+                    }
                 }
-                return null;
+                return result;
             }
             catch (Exception ex)
             {
@@ -1612,6 +1921,63 @@
                 throw;
             }
         }
+        //寰幆鍙戦�淇″彿
+        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));
+            //}
+
+        }
+
+        /// <summary>
+        /// 鎸夐挳鎺у埗鏈嶅姟寮�叧
+        /// </summary>
+        /// <param name="isusing.S_STATUS">鏈嶅姟鐘舵�</param>
+        /// <param name="isusing.S_TYPE">鏈嶅姟绫诲瀷</param>
+        /// <returns></returns>
+        internal static Results switchButton(Isusing isusing)
+        {
+            var db = new SqlHelper<object>().GetInstance();
+            var result = new Results() { Code = "1", Message = $"鏈嶅姟鐘舵�澶辫触锛�, Data = null };
+            var isusinglist = db.Queryable<Isusing>().Where(a => a.S_TYPE == isusing.S_TYPE).First();
+            isusinglist.S_STATUS = isusing.S_STATUS;
+            var res = db.Updateable(isusinglist).UpdateColumns(it => it.S_STATUS).ExecuteCommand() > 0;
+            if (res)
+            {
+                return new Results() { Code = "0", Message = $"鏈嶅姟鐘舵�淇敼鎴愬姛锛�, Data = null };
+
+            }
+            return result;
+        }
+        //tcp鍙戦�淇″彿 娴嬭瘯鐢�+        internal static Results tcpSend(string str)
+        {
+            var reservoirs = Settings.SafeInteractions.Where(s => s.code == 1).FirstOrDefault();
+            //娴嬭瘯鐢�+            LogHelper.Info($"RGV瀹夊叏浜や簰鍙戦�淇″彿{reservoirs.ip},{str}");
+            //鏃犵姸鎬佷俊鍙�+            bool res = PlcHelper.SendHex(reservoirs.ip, str);
+            if (res)
+            {
+                return new Results() { Code = "0", Message = $"鍙戦�鎴愬姛", Data = null };
+            }
+
+            return new Results() { Code = "1", Message = $"鍙戦�澶辫触", Data = null };
+        }
+
 
     }
 }

--
Gitblit v1.9.1