林豪 左 1 rok temu
rodzic
commit
4645a0de5e
22 zmienionych plików z 982 dodań i 314 usunięć
  1. 31 3
      ServiceCenter/Extensions/TypeExtension.cs
  2. 52 0
      ServiceCenter/Logs/LogHub.cs
  3. 16 19
      ServiceCenter/Redis/RedisHub.cs
  4. 3 2
      WCS.Core/DataBlock.cs
  5. 1 1
      WCS.Core/ProtocolProxyBase.cs
  6. 4 0
      WCS.Service/Worker.cs
  7. 2 1
      WCS.Service/appsettings.json
  8. 1 1
      业务工程/分拣库/WCS.Entity.Protocol/TDengineBaseEntity.cs
  9. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Extensions/DeviceExtension.cs
  10. 4 4
      业务工程/分拣库/WCS.WorkEngineering/Extensions/TaskExtension.cs
  11. 67 67
      业务工程/分拣库/WCS.WorkEngineering/ProtocolProxy.cs
  12. 28 17
      业务工程/分拣库/WCS.WorkEngineering/Systems/AgvSystems.cs
  13. 374 11
      业务工程/分拣库/WCS.WorkEngineering/Systems/DataCollectionSysyem.cs
  14. 4 6
      业务工程/分拣库/WCS.WorkEngineering/Systems/RGVSystems.cs
  15. 3 3
      业务工程/分拣库/WCS.WorkEngineering/Systems/UpLoadSystems.cs
  16. 18 18
      业务工程/分拣库/WCS.WorkEngineering/Systems/分拣支线/桁架分流点.cs
  17. 13 12
      业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架.cs
  18. 10 10
      业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架缓存放行点.cs
  19. 3 2
      业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛结束.cs
  20. 1 1
      业务工程/分拣库/WCS.WorkEngineering/WebApi/Controllers/AgvApi.cs
  21. 326 124
      业务工程/分拣库/WCS.WorkEngineering/WorkStart.cs
  22. 20 11
      业务工程/分拣库/WCS.WorkEngineering/数据采集.cs

+ 31 - 3
ServiceCenter/Extensions/TypeExtension.cs

@@ -174,21 +174,49 @@ namespace ServiceCenter.Extensions
             return d;
         }
 
+
+        public static object Copy(this object obj, object type)
+        {
+            foreach (var p in type.GetType().GetProperties())
+            {
+                var p2 = obj.GetType().GetProperty(p.Name);
+                if (p2 != null && p2.PropertyType == p.PropertyType)
+                {
+                    var a = p2.GetValue(obj);
+                    p.SetValue(type, p2.GetValue(obj));
+                }
+            }
+            return type;
+        }
+
         public static object Copy(this object obj, Type type)
         {
             var res = Activator.CreateInstance(type);
             foreach (var p in type.GetProperties())
             {
                 var p2 = obj.GetType().GetProperty(p.Name);
-                if (p2 != null && p2.PropertyType == p.PropertyType)
+                if (p2 != null)
                 {
-                    var a = p2.GetValue(obj);
-                    p.SetValue(res, p2.GetValue(obj));
+                    var value = p2.GetValue(obj);
+                    p.SetValue(res, value);
                 }
             }
             return res;
         }
 
+
+        //public static object Copy(this object source, Type t)
+        //{
+        //    var obj = Activator.CreateInstance(t);
+        //    foreach (var p in t.GetProperties())
+        //    {
+        //        var p2 = source.GetType().GetProperty(p.Name);
+        //        var value = p2.GetValue(source);
+        //        p.SetValue(obj, value);
+        //    }
+        //    return obj;
+        //}
+
         /// <summary>
         /// 获取字典
         /// </summary>

+ 52 - 0
ServiceCenter/Logs/LogHub.cs

@@ -1,7 +1,9 @@
 using Newtonsoft.Json;
+using PlcSiemens.Core.Extension;
 using ServiceCenter.Extensions;
 using ServiceCenter.Redis;
 using System.Collections.Concurrent;
+using System.Diagnostics;
 using WCS.Core;
 
 namespace ServiceCenter.Logs
@@ -108,9 +110,55 @@ namespace ServiceCenter.Logs
         {
             while (true)
             {
+                var sw = new Stopwatch();
+                sw.Start();
                 LogModel log = new LogModel();
                 try
                 {
+                    //var res = RedisHub.Default.LRange("LogHub", 0, 5000).ToList();
+                    //var logHubList = new List<LogModel>();
+                    //Parallel.ForEach(res, x =>
+                    //{
+                    //    var log = JsonConvert.DeserializeObject<LogModel>(x);
+                    //    if (log != null)
+                    //    {
+                    //        logHubList.Add(log);
+                    //    }
+                    //});
+                    //Parallel.ForEach(logHubList.GroupBy(x => x.path).ToList(), logHub =>
+                    //{
+                    //    Parallel.ForEach(logHub.GroupBy(x => x.Title).ToList(), log =>
+                    //    {
+                    //        foreach (var item in log)
+                    //        {
+                    //            if (item.Con.IsNullOrEmpty())
+                    //            {
+                    //                if (!Directory.Exists(item.path)) Directory.CreateDirectory(item.path);
+                    //                File.AppendAllText(Path.Combine(item.path, item.Title), item.Con);
+                    //            }
+                    //        }
+                    //    });
+                    //});
+
+                    //RedisHub.Default.LRem("LogHub", 0, 5000);
+                    //foreach (var logHub in logHubList)
+                    //{
+                    //    try
+                    //    {
+                    //        log = ;
+                    //        if (log != null)
+                    //        {
+                    //            if (!Directory.Exists(log.path)) Directory.CreateDirectory(log.path);
+                    //            File.AppendAllText(Path.Combine(log.path, log.Title), log.Con);
+                    //            count++;
+                    //        }
+                    //    }
+                    //    catch (Exception e)
+                    //    {
+                    //        // ignored
+                    //    }
+                    //}
+
                     var logHub = RedisHub.Default.BLPop("LogHub", 0);
                     log = JsonConvert.DeserializeObject<LogModel>(logHub);
                     if (log != null)
@@ -131,6 +179,10 @@ namespace ServiceCenter.Logs
                     if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                     //File.AppendAllText(Path.Combine($"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\日志处理进程", "Error.txt"), $"{JsonConvert.SerializeObject(log)}--{ex.Message}--{ex.StackTrace}\n");
                 }
+                sw.Stop();
+                var path1 = $"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\日志处理进程";
+                if (!Directory.Exists(path1)) Directory.CreateDirectory(path1);
+                File.AppendAllText(Path.Combine(path1, "耗时.txt"), $"耗时:{sw.ElapsedMilliseconds}\n");
             }
         }
     }

+ 16 - 19
ServiceCenter/Redis/RedisHub.cs

@@ -181,26 +181,23 @@ namespace ServiceCenter.Redis
         /// <exception cref="Exception"></exception>
         public static void Do(string key, string lockKey, Action<RedisClient> act)
         {
-            lock (redisLock)
+            if (!RedisClients.Any()) throw new Exception($"请调用{nameof(CreateContext)}方法设置设置数据库连接");
+            var redis = Context(key);
+            lockKey = "ConcurrentLock:" + lockKey;
+            try
             {
-                if (!RedisClients.Any()) throw new Exception($"请调用{nameof(CreateContext)}方法设置设置数据库连接");
-                var redis = Context(key);
-                lockKey = "ConcurrentLock:" + lockKey;
-                try
-                {
-                    if (redis.Exists(lockKey)) throw new Exception($"重复调用:{lockKey}");
-                    redis.Set(lockKey, lockKey);
-                    redis.Expire(lockKey, 60);
-                    act(redis);
-                }
-                catch (Exception ex)
-                {
-                    throw new KnownException($"{ex.Message}", LogLevelEnum.Mid);
-                }
-                finally
-                {
-                    redis.Del(lockKey);
-                }
+                if (redis.Exists(lockKey)) throw new Exception($"重复调用:{lockKey}");
+                redis.Set(lockKey, lockKey);
+                redis.Expire(lockKey, 60);
+                act(redis);
+            }
+            catch (Exception ex)
+            {
+                throw new KnownException($"{ex.Message}", LogLevelEnum.Mid);
+            }
+            finally
+            {
+                redis.Del(lockKey);
             }
         }
     }

+ 3 - 2
WCS.Core/DataBlock.cs

@@ -36,7 +36,7 @@ namespace WCS.Core
             var isPing = false;
             try
             {
-                if (!Entity.PLCInfo.Ex().Ping)
+                if (failed && !Entity.PLCInfo.Ex().Ping)
                 {
                     isPing = true;
                     throw new Exception($"网络异常IP为{Entity.PLCInfo.IP}的设备PLC无法访问");
@@ -56,11 +56,12 @@ namespace WCS.Core
                     Data = data;
                     DbChanged?.Invoke(Data);
                 }
+                failed = false;
             }
             catch (Exception ex)
             {
+                failed = true;
                 if (isPing) throw new Exception($"{ex.Message}");
-
                 throw new Exception($"{ex.Message}:\r{ex.StackTrace}");
             }
         }

+ 1 - 1
WCS.Core/ProtocolProxyBase.cs

@@ -126,7 +126,7 @@ namespace WCS.Core
             var item = Items[propertyName] as PlcItem<T>;
             var res = item.Value;
             var channel = Ltc.GetChannel();
-            //if (channel != null) this.World.OnInternalLog(channel, $"获取值:{Device.Code}.{ProtocolType.Name}.{propertyName}:{res}");
+            if (channel != null && !ProtocolType.Name.Contains("525") && !ProtocolType.Name.Contains("83")) this.World.OnInternalLog(channel, $"获取值:{Device.Code}.{ProtocolType.Name}.{propertyName}:{res}");
             return res;
         }
 

+ 4 - 0
WCS.Service/Worker.cs

@@ -120,6 +120,10 @@ namespace WCS.Service
             List<ConnectionConfig> connectionConfigs = new List<ConnectionConfig>();
             foreach (var connectionString in ServiceHub.DbConnectionStrings!)
             {
+                if (connectionString.Key == "PLC")
+                {
+                    var b = 1;
+                }
                 connectionConfigs.Add(new ConnectionConfig()
                 {
                     ConfigId = connectionString.Key,

+ 2 - 1
WCS.Service/appsettings.json

@@ -7,6 +7,7 @@
     }
   },
   "ConnectionStrings": {
-    "Redis": "10.30.37.1,password=123456,database=0,prefix=Sorting:"
+    "Redis": "127.0.0.1,database=0,prefix=Sorting:",
+    //"Redis": "10.30.37.1,password=123456,database=0,prefix=Sorting:"
   }
 }

+ 1 - 1
业务工程/分拣库/WCS.Entity.Protocol/TDengineBaseEntity.cs

@@ -10,7 +10,7 @@ namespace WCS.Entity.Protocol
     public class TDengineBaseEntity : STable
     {
         [SugarColumn(IsPrimaryKey = true, InsertServerTime = true)]
-        public DateTime ExTime { get; set; }
+        public DateTime Frame { get; set; }
 
         public string Code { get; set; }
 

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Extensions/DeviceExtension.cs

@@ -56,7 +56,7 @@ namespace WCS.WorkEngineering.Extensions
                         Port = 102,
                         Rack = 0,
                         Slot = 1,
-                        Type = PLCType.Siemens
+                        //Type = PLCType.Siemens
                     }
                 }
             };

+ 4 - 4
业务工程/分拣库/WCS.WorkEngineering/Extensions/TaskExtension.cs

@@ -87,7 +87,7 @@ namespace WCS.WorkEngineering.Extensions
         {
             if (taskInfo.Status == TaskStatus.NewBuild) return;
             // 同步任务信息
-            var taskOld = db.Queryable<WCS_TaskOld>().SplitTable(tabs => tabs.Take(2)).Where(v => v.Id == taskInfo.ID).OrderByDescending(v => v.AddTime).First();
+            var taskOld = db.Queryable<WCS_TaskOld>().Where(v => v.Id == taskInfo.ID).SplitTable(tabs => tabs.Take(2)).OrderByDescending(v => v.AddTime).First();
             if (taskOld is not null)
             {
                 if (taskInfo.Status >= TaskStatus.Finish) taskInfo.CompleteOrCancelTasks(db);
@@ -113,7 +113,7 @@ namespace WCS.WorkEngineering.Extensions
         {
             if (taskInfo.Status is not Entity.TaskStatus.Finish and not Entity.TaskStatus.Cancel) throw new KnownException("任务未完成或取消,无法执行WCS_TaskInfo与WCS_TaskOld同步动作", LogLevelEnum.Mid);
             // 任务完成或取消,进行相关同步动作
-            var taskOld = db.Queryable<WCS_TaskOld>().SplitTable(tabs => tabs.Take(2)).Where(v => v.Id == taskInfo.ID).OrderByDescending(v => v.AddTime).First();
+            var taskOld = db.Queryable<WCS_TaskOld>().Where(v => v.Id == taskInfo.ID).SplitTable(tabs => tabs.Take(2)).OrderByDescending(v => v.AddTime).First();
             if (taskOld is not null)
             {
                 taskOld = taskInfo.Mapper<WCS_TaskOld, WCS_TaskInfo>();
@@ -253,8 +253,8 @@ namespace WCS.WorkEngineering.Extensions
                 //构造位信息
                 foreach (var loc in item)
                 {
-                    var palletizingLoc = db.Queryable<WCS_PalletizingLoc>()
-                        .Single(x => x.PalletizingRowId == palletizingRow.Id && x.XYNo == loc.XYNo);
+                    var palletizingLoc = db.Queryable<WCS_PalletizingLoc>().Single(x => x.PalletizingRowId == palletizingRow.Id && x.XYNo == loc.XYNo);
+
                     if (palletizingLoc == null)
                     {
                         palletizingLoc = new WCS_PalletizingLoc()

+ 67 - 67
业务工程/分拣库/WCS.WorkEngineering/ProtocolProxy.cs

@@ -23,75 +23,75 @@ namespace WCS.WorkEngineering
 
         protected override void DataChanged()
         {
-            if (Device.Code == "RGV1" && Info.DBInfo.No == 520)
-            {
-                var a = Items;
-                //var dev=Device.Protocol(ProtocolType)
-                var b = a;
-            }
-
-            try
-            {
-                var datas = DataCollectionSysyem.AllDatas;
-                if (Device.Code.All(char.IsNumber))
-                {
-                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new StationData { Code = Device.Code };
-                }
-                else if (Device.Code.Contains("SRM"))
-                {
-                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new SRMData { Code = Device.Code };
-                }
-                else if (Device.Code.Contains("Truss"))
-                {
-                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new TrussData() { Code = Device.Code };
-                }
-                else if (Device.Code.Contains("Robot"))
-                {
-                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new RobotData() { Code = Device.Code };
-                }
-                else if (Device.Code.Contains("RGV"))
-                {
-                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new RGVData { Code = Device.Code };
-                }
-
-                if (!datas.TryGetValue(Device.Code, out var data)) return;
-                data.Frame = DateTime.Now;
-                var p = data.GetType().GetProperties().FirstOrDefault(v => v.PropertyType == ProtocolDataType);
-                //var ty90 = WCS_Station90;
-                //if (p.getty is ty90 or)
-                //{
-                //}
-                if (p == null) return;
-                p.SetValue(data, DictionaryToEntity(ProtocolDataType, Items, data));
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine(ex.Message);
-            }
+            //if (Device.Code == "RGV1" && Info.DBInfo.No == 520)
+            //{
+            //    var a = Items;
+            //    //var dev=Device.Protocol(ProtocolType)
+            //    var b = a;
+            //}
+
+            //try
+            //{
+            //    var datas = DataCollectionSysyem.AllDatas;
+            //    if (Device.Code.All(char.IsNumber))
+            //    {
+            //        if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new StationData { Code = Device.Code };
+            //    }
+            //    else if (Device.Code.Contains("SRM"))
+            //    {
+            //        if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new SRMData { Code = Device.Code };
+            //    }
+            //    else if (Device.Code.Contains("Truss"))
+            //    {
+            //        if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new TrussData() { Code = Device.Code };
+            //    }
+            //    else if (Device.Code.Contains("Robot"))
+            //    {
+            //        if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new RobotData() { Code = Device.Code };
+            //    }
+            //    else if (Device.Code.Contains("RGV"))
+            //    {
+            //        if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new RGVData { Code = Device.Code };
+            //    }
+
+            //    if (!datas.TryGetValue(Device.Code, out var data)) return;
+            //    data.Frame = DateTime.Now;
+            //    var p = data.GetType().GetProperties().FirstOrDefault(v => v.PropertyType == ProtocolDataType);
+            //    //var ty90 = WCS_Station90;
+            //    //if (p.getty is ty90 or)
+            //    //{
+            //    //}
+            //    if (p == null) return;
+            //    p.SetValue(data, DictionaryToEntity(ProtocolDataType, Items, data));
+            //}
+            //catch (Exception ex)
+            //{
+            //    Console.WriteLine(ex.Message);
+            //}
         }
 
-        public object DictionaryToEntity(Type type, Dictionary<string, PlcItem> plcItems, DeviceData data)
+        public void DictionaryToEntity(Type type, Dictionary<string, PlcItem> plcItems, DeviceData data)
         {
-            var entity = Activator.CreateInstance(type);
-            //采集量
-            Parallel.ForEach(type.GetProperties(), ty =>
-            {
-                if (plcItems.Any(x => x.Key == ty.Name))
-                {
-                    var item = plcItems.First(x => ty.Name == x.Key);
-                    ty.SetValue(entity, item.Value.Value);
-                }
-            });
-
-            Parallel.ForEach(type.GetProperties(), ty =>
-            {
-                var items = data.GetType().GetProperties();
-                if (items.Any(x => x.Name == ty.Name))
-                {
-                    var item = items.First(x => ty.Name == x.Name);
-                    ty.SetValue(entity, item.GetValue(data));
-                }
-            });
+            //var entity = Activator.CreateInstance(type);
+            ////采集量
+            //Parallel.ForEach(type.GetProperties(), ty =>
+            //{
+            //    if (plcItems.Any(x => x.Key == ty.Name))
+            //    {
+            //        var item = plcItems.First(x => ty.Name == x.Key);
+            //        ty.SetValue(entity, item.Value.Value);
+            //    }
+            //});
+
+            //Parallel.ForEach(type.GetProperties(), ty =>
+            //{
+            //    var items = data.GetType().GetProperties();
+            //    if (items.Any(x => x.Name == ty.Name))
+            //    {
+            //        var item = items.First(x => ty.Name == x.Name);
+            //        ty.SetValue(entity, item.GetValue(data));
+            //    }
+            //});
 
             //foreach (var ty in type.GetProperties().Where(x => x.Name == nameof(TDengineBaseEntity.CreateSql)))
             //{
@@ -224,7 +224,7 @@ namespace WCS.WorkEngineering
             //            break;
             //    }
             //}
-            return entity;
+            //return entity;
         }
 
         public string GetString(string value)

+ 28 - 17
业务工程/分拣库/WCS.WorkEngineering/Systems/AgvSystems.cs

@@ -9,7 +9,6 @@ using WCS.Entity.Protocol.Station;
 using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.WebApi.Controllers;
 using WCS.WorkEngineering.Worlds;
-using TaskStatus = WCS.Entity.TaskStatus;
 
 namespace WCS.WorkEngineering.Systems
 {
@@ -30,7 +29,7 @@ namespace WCS.WorkEngineering.Systems
 
         public override void Do(Device<IStation520> obj)
         {
-            if (obj.Entity.Code == "出库AGV")
+            if (obj.Entity.Code == "2534")
             {
                 var agvTaskInfos = new List<WCS_AgvTaskInfo>();
                 //获取所有未结束的叫料及背负式补空AGV任务
@@ -113,7 +112,7 @@ namespace WCS.WorkEngineering.Systems
                     }
                 }
             }
-            else if (obj.Entity.Code == "入库AGV")
+            else if (obj.Entity.Code == "2533")
             {
                 List<WCS_AgvTaskInfo> agvTaskInfos = new List<WCS_AgvTaskInfo>();
                 //获取所有未结束的入库AGV任务
@@ -158,7 +157,7 @@ namespace WCS.WorkEngineering.Systems
                                                     break;
 
                                                 case "1S":
-                                                    positionList.AddRange(new List<string>() { /*"2701", "2705", "2709", "2713"*/"2501", "2505", "2509", "2513" });
+                                                    positionList.AddRange(new List<string>() { "2701", "2705", "2709", "2713"/*"2501", "2505", "2509", "2513"*/ });
                                                     break;
 
                                                 case "2N":
@@ -197,18 +196,30 @@ namespace WCS.WorkEngineering.Systems
                                             }
 
                                             //获取没有光电信息的设备集合
-                                            var devs = Device.All.Where(x => endDevs.Contains(x.Code)).Select(x => new Device<IStation520, IStation521, IStation523>(x, World));
-                                            devs = devs.Where(x => !x.Data3.Status.HasFlag(StationStatus.Run) && !x.Data3.Status.HasFlag(StationStatus.PH_Status) && x.Data3.Status.HasFlag(StationStatus.Auto)).ToList();
-                                            if (!devs.Any()) throw new Exception($"可用站台均有货或有执行中任务");
-                                            World.Log($"任务执行过程:开始{agv.ID}-{JsonConvert.SerializeObject(devs)}");
-                                            agv.Status = AGVTaskStatus.Complete1;
-                                            agv.Station = devs.MinBy(x => x.Entity.Code).Entity.Code;
-                                            db.Default.Updateable(agv).SplitTable(x => x.Take(2)).ExecuteCommand();
-                                            World.Log($"任务执行过程:完成agv任务更新{agv.ID}--{agv.Station}");
-                                            task.AddWCS_TASK_DTL(db.Default, "皮盘返库任务分配巷道", agv.Station, $"任务分配至:{agv.Station}");
-                                            World.Log($"任务执行过程:完成任务明细添加{agv.Station}");
-                                            AgvApi.ContinueTask(agv.AgvID, agv.Station);
-                                            World.Log($"任务执行过程:任务成功下发AGV{agv.AgvID}--{agv.Station}");
+                                            try
+                                            {
+                                                var devs = Device.All.Where(x => endDevs.Contains(x.Code)).Select(x =>
+                                                    new Device<IStation520, IStation521, IStation523>(x, World));
+                                                devs = devs.Where(x =>
+                                                    !x.Data3.Status.HasFlag(StationStatus.Run) &&
+                                                    !x.Data3.Status.HasFlag(StationStatus.PH_Status) &&
+                                                    x.Data3.Status.HasFlag(StationStatus.Auto)).ToList();
+                                                if (!devs.Any()) throw new Exception($"可用站台均有货或有执行中任务");
+                                                World.Log($"任务执行过程:开始{agv.ID}-{JsonConvert.SerializeObject(devs.Select(x => x.Entity.Code).ToList())}");
+                                                agv.Status = AGVTaskStatus.Complete1;
+                                                agv.Station = devs.MinBy(x => x.Entity.Code).Entity.Code;
+                                                db.Default.Updateable(agv).SplitTable(x => x.Take(2)).ExecuteCommand();
+                                                World.Log($"任务执行过程:完成agv任务更新{agv.ID}--{agv.Station}");
+                                                task.AddWCS_TASK_DTL(db.Default, "皮盘返库任务分配巷道", agv.Station,
+                                                    $"任务分配至:{agv.Station}");
+                                                World.Log($"任务执行过程:完成任务明细添加{agv.Station}");
+                                                AgvApi.ContinueTask(agv.AgvID, agv.Station);
+                                                World.Log($"任务执行过程:任务成功下发AGV{agv.AgvID}--{agv.Station}");
+                                            }
+                                            catch (Exception e)
+                                            {
+                                                throw new Exception($"执行错误:{e.Message + e.StackTrace}");
+                                            }
 
                                             break;
                                         }
@@ -257,7 +268,7 @@ namespace WCS.WorkEngineering.Systems
 
         public override bool Select(Device dev)
         {
-            return dev.Code is "出库AGV" or "入库AGV";
+            return dev.Code is "2533" or "2534";
         }
     }
 }

+ 374 - 11
业务工程/分拣库/WCS.WorkEngineering/Systems/DataCollectionSysyem.cs

@@ -5,7 +5,13 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.Text;
 using WCS.Core;
+using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.DataStructure;
+using WCS.Entity.Protocol.RGV;
+using WCS.Entity.Protocol.Robot;
+using WCS.Entity.Protocol.SRM;
+using WCS.Entity.Protocol.Station;
+using WCS.Entity.Protocol.Truss;
 using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.Worlds;
 
@@ -14,7 +20,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  数据采集系统
     /// </summary>
-    //[BelongTo(typeof(DataCollectionWorld))]
+    [BelongTo(typeof(DataCollectionWorld))]
     [Description("数据采集系统")]
     public class DataCollectionSysyem : DeviceSystem<SRM>
     {
@@ -24,16 +30,16 @@ namespace WCS.WorkEngineering.Systems
 
         public DataCollectionSysyem()
         {
-            //var gs = Device.All.SelectMany(v => v.Protocols.Select(d => new { DB = $"{d.Value.DBInfo.No}:{d.Value.DBInfo.PLCInfo.IP}", d.Value.Position, TypeStr = d.Key, Dev = v }))
-            //    .GroupBy(v => v.DB);
-            //foreach (var g in gs.Where(x => !x.Key.Contains("10.30.37.211") && !x.Key.Contains("10.30.37.217") && !x.Key.Contains("10.30.37.223")))
-            //{
-            //    var min = g.OrderBy(v => v.Position).First();
-            //    var max = g.OrderByDescending(v => v.Position).First();
-            //    var t = Type.GetType(min.TypeStr);
-            //    min.Dev.Protocol(t, this.World);
-            //    max.Dev.Protocol(t, this.World);
-            //}
+            var gs = Device.All.SelectMany(v => v.Protocols.Select(d => new { DB = $"{d.Value.DBInfo.No}:{d.Value.DBInfo.PLCInfo.IP}", d.Value.Position, TypeStr = d.Key, Dev = v }))
+                .GroupBy(v => v.DB);
+            foreach (var g in gs)
+            {
+                var min = g.OrderBy(v => v.Position).First();
+                var max = g.OrderByDescending(v => v.Position).First();
+                var t = Type.GetType(min.TypeStr);
+                min.Dev.Protocol(t, this.World);
+                max.Dev.Protocol(t, this.World);
+            }
         }
 
         /// <summary>
@@ -54,6 +60,209 @@ namespace WCS.WorkEngineering.Systems
 
         public override void Do(SRM obj)
         {
+            var sw = new Stopwatch();
+            sw.Start();
+            var pack = new DeviceDataPack();
+            pack.Frame = DateTime.Now;
+            var sql = new StringBuilder();
+            sql.Append("INSERT INTO ");
+            var ps = pack.GetType().GetProperties().OrderBy(x => x.Name);
+            foreach (var p in ps)
+            {
+                if (!p.PropertyType.IsArray)
+                    continue;
+                var dev = p.PropertyType.GetElementType();
+                if (dev.GetInterfaces().Any(v => v.GetInterfaces().Any(d => d.Name == "IProtocol")))
+                {
+                    var t = p.PropertyType.GetElementType();
+                    var protType = GetProtocolType(t);
+                    var arr = Device.All.Where(v => v.HasProtocol(protType))
+                    .Select(v =>
+                    {
+                        try
+                        {
+                            var obj = Activator.CreateInstance(t);
+                            t.GetProperty("Code").SetValue(obj, v.Code);
+                            dynamic protObj = v.Protocol(protType, World);
+                            protObj.Copy(obj);
+                            var value = GetSql(t, obj);
+                            t.GetProperty("Frame").SetValue(obj, protObj.Frame);
+                            //var value = ServiceCenter.Extensions.TypeExtension.Copy(protObj, t);
+                            //t.GetProperty("Data").SetValue(obj, value);
+                            sql.Append(value);
+                            return obj;
+                        }
+                        catch (Exception ex)
+                        {
+                            return null;
+                        }
+                    }).Where(v => v != null).ToArray();
+
+                    var m = typeof(Enumerable).GetMethod("OfType", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+                    m = m.MakeGenericMethod(t);
+                    var arr2 = m.Invoke(null, new object[] { arr });
+
+                    m = typeof(Enumerable).GetMethod("ToArray", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+                    m = m.MakeGenericMethod(t);
+                    var arr3 = m.Invoke(null, new object[] { arr2 });
+                    p.SetValue(pack, arr3);
+                }
+            }
+
+            //Redis.RPush("Packs", pack);
+            //if (Redis.LLen("Packs") > 50000)
+            //{
+            //    Redis.LTrim("Packs", 5000, -1);
+            //}
+
+            sw.Stop();
+            //var sw = new Stopwatch();
+            //sw.Start();
+            //var pack = new DeviceDataPack();
+            //pack.Frame = DateTime.Now;
+            //var ps = pack.GetType().GetProperties();
+            //foreach (var p in ps)
+            //{
+            //    if (!p.PropertyType.IsClass) continue;
+
+            //    var packAct = Activator.CreateInstance(p.PropertyType);
+            //    var prs = p.PropertyType.GetProperties();
+            //    foreach (var pr in prs)
+            //    {
+            //        if (!pr.PropertyType.IsArray) continue;
+
+            //        var yt = pr.PropertyType.GetElementType();
+            //        if (yt.IsClass)
+            //        {
+            //            var pros = yt.GetProperties();
+            //            //var entType = yt.GetGenericArguments()[0];
+            //            //var protType = GetProtocolType(entType);
+            //            var dataAct = Activator.CreateInstance(yt);
+            //            Parallel.ForEach(pros, pro =>
+            //            {
+            //                try
+            //                {
+            //                    if (pro.PropertyType != typeof(DateTime))
+            //                    {
+            //                        if (pro.PropertyType != typeof(string))
+            //                        {
+            //                            var protType = GetProtocolType(pro.PropertyType);
+            //                            var dev = Device.All
+            //                                .Where(v => v.HasProtocol(protType)).Select(v =>
+            //                                {
+            //                                    try
+            //                                    {
+            //                                        var obj = Activator.CreateInstance(pro.PropertyType);
+            //                                        pro.PropertyType.GetProperty("Code").SetValue(obj, v.Code);
+            //                                        var a = v.Protocol(protType, World);
+            //                                        var value = v.Protocol(protType, World).Copy(pro.PropertyType);
+            //                                        pro.SetValue(obj, value);
+            //                                        return obj;
+            //                                    }
+            //                                    catch (Exception ex)
+            //                                    {
+            //                                        return null;
+            //                                    }
+            //                                }).FirstOrDefault(v => v != null);
+
+            //                            if (dev != null)
+            //                            {
+            //                                pro.SetValue(dataAct, dev);
+            //                            }
+            //                        }
+            //                        else
+            //                        {
+            //                        }
+            //                    }
+            //                }
+            //                catch (Exception e)
+            //                {
+            //                    Console.WriteLine(e);
+            //                }
+            //            });
+
+            //            var a = 1;
+
+            //            //var m = typeof(Enumerable).GetMethod("OfType", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //            //m = m.MakeGenericMethod(yt);
+            //            //var arr2 = m.Invoke(null, new object[] { datasAct });
+
+            //            //m = typeof(Enumerable).GetMethod("ToArray", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //            //m = m.MakeGenericMethod(yt);
+            //            //var arr3 = m.Invoke(null, new object[] { arr2 });
+            //            //p.SetValue(pack, arr3);
+
+            //            //var entType = yt.GetGenericArguments()[0];
+            //            //var protType = GetProtocolType(entType);
+            //            //var arr = Device.All.Where(v => v.HasProtocol(protType))
+            //            //    .Select(v =>
+            //            //    {
+            //            //        try
+            //            //        {
+            //            //            var obj = Activator.CreateInstance(yt);
+            //            //            yt.GetProperty("Code").SetValue(obj, v.Code);
+            //            //            //var value = v.Protocol(protType, World).Copy(entType);
+            //            //            //t.GetProperty("Data").SetValue(obj, value);
+            //            //            return obj;
+            //            //        }
+            //            //        catch (Exception ex)
+            //            //        {
+            //            //            return null;
+            //            //        }
+            //            //    }).Where(v => v != null).ToArray();
+
+            //            //var m = typeof(Enumerable).GetMethod("OfType", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //            //m = m.MakeGenericMethod(yt);
+            //            //var arr2 = m.Invoke(null, new object[] { arr });
+
+            //            //m = typeof(Enumerable).GetMethod("ToArray", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //            //m = m.MakeGenericMethod(yt);
+            //            //var arr3 = m.Invoke(null, new object[] { arr2 });
+            //            //p.SetValue(pack, arr3);
+            //        }
+            //    }
+
+            //    //var t = p.PropertyType.GetElementType();
+            //    //if (t.IsGenericType)
+            //    //{
+            //    //    var entType = t.GetGenericArguments()[0];
+            //    //    var protType = GetProtocolType(entType);
+            //    //    var arr = Device.All.Where(v => v.HasProtocol(protType))
+            //    //    .Select(v =>
+            //    //    {
+            //    //        try
+            //    //        {
+            //    //            var obj = Activator.CreateInstance(t);
+            //    //            t.GetProperty("Code").SetValue(obj, v.Code);
+            //    //            //var value = v.Protocol(protType, World).Copy(entType);
+            //    //            //t.GetProperty("Data").SetValue(obj, value);
+            //    //            return obj;
+            //    //        }
+            //    //        catch (Exception ex)
+            //    //        {
+            //    //            return null;
+            //    //        }
+            //    //    }).Where(v => v != null).ToArray();
+
+            //    //    var m = typeof(Enumerable).GetMethod("OfType", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //    //    m = m.MakeGenericMethod(t);
+            //    //    var arr2 = m.Invoke(null, new object[] { arr });
+
+            //    //    m = typeof(Enumerable).GetMethod("ToArray", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //    //    m = m.MakeGenericMethod(t);
+            //    //    var arr3 = m.Invoke(null, new object[] { arr2 });
+            //    //    p.SetValue(pack, arr3);
+            //    //}
+            //}
+
+            ////Redis.RPush("Packs", pack);
+            ////if (Redis.LLen("Packs") > 50000)
+            ////{
+            ////    Redis.LTrim("Packs", 5000, -1);
+            ////}
+
+            //sw.Stop();
+            //list.Add(new WorkTimes { Total = sw.ElapsedMilliseconds, Key = "采集数据" });
             return;
             //var sw = new Stopwatch();
             //sw.Start();
@@ -181,6 +390,160 @@ namespace WCS.WorkEngineering.Systems
                 sql.Append(cSql);
             }
         }
+
+        private Type GetProtocolType(Type source)
+        {
+            var t = source.GetInterfaces().FirstOrDefault(v => v.GetInterfaces().Any(d => d.Name == "IProtocol"));
+            return t;
+        }
+
+        public string GetSql(Type type, object entity)
+        {
+            string sql = string.Empty;
+            var db = new SqlSugarHelper().PLC;
+            var ty = entity.GetType().GetProperty("CreateSql");
+            switch (type.Name)
+            {
+                case nameof(WCS_SRM520):
+                    var item = entity as WCS_SRM520;
+                    sql = GetString(db.Insertable(item).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_SRM521):
+                    var item1 = entity as WCS_SRM521;
+                    sql = GetString(db.Insertable(item1).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_SRM537):
+                    var item2 = entity as WCS_SRM537;
+                    sql = GetString(db.Insertable(item2).ToSqlString());
+                    ty.SetValue(entity, GetString(db.Insertable(item2).ToSqlString()));
+                    break;
+
+                case nameof(WCS_RGV520):
+                    var item3 = entity as WCS_RGV520; sql = GetString(db.Insertable(item3).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_RGV521):
+                    var item4 = entity as WCS_RGV521; sql = GetString(db.Insertable(item4).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_BCR80):
+                    var item5 = entity as WCS_BCR80; sql = GetString(db.Insertable(item5).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_BCR81):
+                    var item6 = entity as WCS_BCR81; sql = GetString(db.Insertable(item6).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_BCR83):
+                    var item7 = entity as WCS_BCR83; sql = GetString(db.Insertable(item7).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station520):
+                    var item8 = entity as WCS_Station520; sql = GetString(db.Insertable(item8).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station521):
+                    var item9 = entity as WCS_Station521; sql = GetString(db.Insertable(item9).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station523):
+                    var item10 = entity as WCS_Station523; sql = GetString(db.Insertable(item10).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station524):
+                    var item11 = entity as WCS_Station524; sql = GetString(db.Insertable(item11).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station525):
+                    var item12 = entity as WCS_Station525; sql = GetString(db.Insertable(item12).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station90):
+                    var item13 = entity as WCS_Station90; sql = GetString(db.Insertable(item13).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Station91):
+                    var item14 = entity as WCS_Station91; sql = GetString(db.Insertable(item14).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Truss520):
+                    var item15 = entity as WCS_Truss520; sql = GetString(db.Insertable(item15).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Truss521):
+                    var item16 = entity as WCS_Truss521; sql = GetString(db.Insertable(item16).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Truss523):
+                    var item17 = entity as WCS_Truss523; sql = GetString(db.Insertable(item17).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Truss530):
+                    var item18 = entity as WCS_Truss530; sql = GetString(db.Insertable(item18).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Truss531):
+                    var item19 = entity as WCS_Truss531; sql = GetString(db.Insertable(item19).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Robot520):
+                    var item20 = entity as WCS_Robot520; sql = GetString(db.Insertable(item20).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Robot521):
+                    var item21 = entity as WCS_Robot521; sql = GetString(db.Insertable(item21).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Robot522):
+                    var item22 = entity as WCS_Robot522; sql = GetString(db.Insertable(item22).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Robot530):
+                    var item23 = entity as WCS_Robot530; sql = GetString(db.Insertable(item23).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+
+                case nameof(WCS_Robot531):
+                    var item24 = entity as WCS_Robot531; sql = GetString(db.Insertable(item24).ToSqlString());
+                    ty.SetValue(entity, sql);
+                    break;
+            }
+
+            return sql;
+        }
+
+        public string GetString(string value)
+        {
+            return value.Replace("INSERT INTO ", "")
+                .Replace(",N'", ",'")
+                .Replace("\0", "")
+                .Replace("wcs_", "")
+                .Replace("(N'", "('") + "\r";
+        }
     }
 
     /// <summary>

+ 4 - 6
业务工程/分拣库/WCS.WorkEngineering/Systems/RGVSystems.cs

@@ -1,4 +1,5 @@
-using ServiceCenter.Extensions;
+using System.Collections;
+using ServiceCenter.Extensions;
 using ServiceCenter.Logs;
 using ServiceCenter.SqlSugars;
 using System.ComponentModel;
@@ -189,11 +190,8 @@ namespace WCS.WorkEngineering.Systems
                                 });
                                 var pallLoc = pall.Layers.SelectMany(x => x.Rows).SelectMany(x => x.Locs).Select(x => new { XYNo = x.XYNo.ToShort(), x.Finish }).ToList();
 
-                                foreach (var loc in pallLoc)
-                                {
-                                    dev.Data3.GetType().GetProperty($"IsGoods{loc.XYNo - 1}").SetValue(obj.Data3, loc.Finish);
-                                }
-
+                                //var pallLoc1 = new BitArray(pallLoc.Where(x => x.XYNo is >= 1 and <= 16).OrderBy(x => x.XYNo).Select(x => x.Finish).ToArray());
+                                //var a = pallLoc1.;
                                 dev.Data3.MaxQuantity = pall.CountQty.ToShort();
                                 dev.Data3.Quantity = pallLoc.Count(x => x.Finish).ToShort();
                                 dev.Data3.Type = pall.ShortCode;

+ 3 - 3
业务工程/分拣库/WCS.WorkEngineering/Systems/UpLoadSystems.cs

@@ -57,12 +57,12 @@ namespace WCS.WorkEngineering.Systems
                 var taskIdList = new List<int>();
                 var nowTime = DateTime.Now;
                 var db = _db.Default;
-                var taskList = db.Queryable<WCS_TaskOld>().SplitTable(x => x.Take(2))
+                var taskList = db.Queryable<WCS_TaskOld>()
                     .Where(x =>
                                 ((x.Type == TaskType.SetPlate && x.WarehouseCode.Contains("R"))
                                  || ((x.Type == TaskType.EnterDepot || x.Type == TaskType.OutDepot) && !x.WarehouseCode.Contains("R")))
                                 && x.Status == TaskStatus.Finish
-                                && x.Uploaded != TaskStatus.Finish).ToList();
+                                && x.Uploaded != TaskStatus.Finish).SplitTable(x => x.Take(2)).ToList();
 
                 foreach (var task in taskList)
                 {
@@ -74,7 +74,7 @@ namespace WCS.WorkEngineering.Systems
                 //拆分防止锁表
                 foreach (var taskId in taskIdList)
                 {
-                    var task = db.Queryable<WCS_TaskOld>().SplitTable(x => x.Take(2)).First(x => x.Id == taskId);
+                    var task = db.Queryable<WCS_TaskOld>().Where(x => x.Id == taskId).SplitTable(x => x.Take(2)).First();
                     task.Uploaded = TaskStatus.Finish;
                     task.EditTime = nowTime;
                     db.Updateable(task).SplitTable(x => x.Take(2)).ExecuteCommand();

+ 18 - 18
业务工程/分拣库/WCS.WorkEngineering/Systems/分拣支线/桁架分流点.cs

@@ -127,24 +127,24 @@ namespace WCS.WorkEngineering.Systems
             if (devCode == 0)
             {
                 World.Log($"无可用线体:{taskInfo.ID}");
-                //var endTime = DateTime.Now.AddMinutes(-10);
-                ////找一个当前时间最早且已超过25分钟未码垛的码垛信息半托入库
-                ////未结束且包含当前物料编号的垛形,按时间排序,创建时间早的优先分配,当前任务的仓库号必须要等于码垛信息绑定的仓库号
-                //var palletizing = db.Queryable<WCS_Palletizing>()
-                //    .Includes(x => x.Layers, r => r.Rows, l => l.Locs)
-                //    .Where(x => !x.Finish && x.WarehouseCode == taskInfo.WarehouseCode && x.Layers.Any(l => l.Rows.Any(r => r.Finish)))
-                //    .Where(x => x.EditTime < endTime).ToList()
-                //    .MinBy(x => x.AddTime);
-                //cacheLineList = db.Queryable<WCS_CacheLine>().Where(x => x.WarehouseCode == taskInfo.WarehouseCode && x.IsTruss).ToList();
-
-                //if (palletizing != null && !cacheLineList.Any())
-                //{
-                //    var dev = Device.All.Where(x => x.Code == palletizing.PalletizingStation).Select(x => new Device<ITruss530>(x, World)).FirstOrDefault();
-                //    if (dev != null && !dev.Data.CmdType.HasFlag(TrussCmdType.Two))
-                //    {
-                //        dev.Data.CmdType = TrussCmdType.Two;
-                //    }
-                //}
+                var endTime = DateTime.Now.AddMinutes(-10);
+                //找一个当前时间最早且已超过25分钟未码垛的码垛信息半托入库
+                //未结束且包含当前物料编号的垛形,按时间排序,创建时间早的优先分配,当前任务的仓库号必须要等于码垛信息绑定的仓库号
+                var palletizing = db.Queryable<WCS_Palletizing>()
+                    .Includes(x => x.Layers, r => r.Rows, l => l.Locs)
+                    .Where(x => !x.Finish && x.WarehouseCode == taskInfo.WarehouseCode && x.Layers.Any(l => l.Rows.Any(r => r.Finish)))
+                    .Where(x => x.EditTime < endTime).ToList()
+                    .MinBy(x => x.AddTime);
+                cacheLineList = db.Queryable<WCS_CacheLine>().Where(x => x.WarehouseCode == taskInfo.WarehouseCode && x.IsTruss).ToList();
+
+                if (palletizing != null && !cacheLineList.Any())
+                {
+                    var dev = Device.All.Where(x => x.Code == palletizing.PalletizingStation).Select(x => new Device<ITruss530>(x, World)).FirstOrDefault();
+                    if (dev != null && !dev.Data.CmdType.HasFlag(TrussCmdType.Two))
+                    {
+                        dev.Data.CmdType = TrussCmdType.Two;
+                    }
+                }
                 return false;
             }
             var result = false;

+ 13 - 12
业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架.cs

@@ -159,8 +159,9 @@ namespace WCS.WorkEngineering.Systems
                 //筛选出目标位置有光电的码垛记录信息
                 var devCode = palletizingLsit.Select(x => x.PalletizingStation);
                 var taskCode = palletizingLsit.Select(x => x.Id);
-                var devList = Device.All.Where(x => devCode.Contains(x.Code)).Select(x => new Device<IStation521, IStation523>(x, World)).ToList();
-                devList = devList.Where(x => x.Data2.Status.HasFlag(StationStatus.PH_Status) && taskCode.Contains(x.Data.TaskNumber)).ToList();
+                var devList = Device.All.Where(x => devCode.Contains(x.Code)).Select(x => new Device<IStation521, IStation523, ITruss530>(x, World)).ToList();
+                devList = devList.Where(x => x.Data2.Status.HasFlag(StationStatus.PH_Status) && taskCode.Contains(x.Data.TaskNumber) && !x.Data3.CmdType.HasFlag(TrussCmdType.Two)).ToList();
+                devCode = devList.Select(x => x.Entity.Code);
                 if (!devCode.Any()) throw new KnownException($"无可用放货码垛位,请检查实际有货位置的光电是否正常", LogLevelEnum.Mid);
                 palletizingLsit = palletizingLsit.Where(x => devCode.Contains(x.PalletizingStation)).ToList(); //可以放货的目标托盘
                 //可以取货的码垛信息
@@ -363,16 +364,16 @@ namespace WCS.WorkEngineering.Systems
                         _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "559"), World), Device.All.Where(x => x.Code is "559" or "560" or "561" or "562" or "563").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
                         _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "573"), World), Device.All.Where(x => x.Code is "573" or "574" or "575" or "576" or "577").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
                         _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "586"), World), Device.All.Where(x => x.Code is "586" or "587" or "588" or "589" or "590").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "661"), World), Device.All.Where(x => x.Code is "661" or "662" or "663" or "664" or "665").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "675"), World), Device.All.Where(x => x.Code is "675" or "676" or "677" or "678" or "679").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "689"), World), Device.All.Where(x => x.Code is "690" or "691" or "692" or "693" or "689").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "703"), World), Device.All.Where(x => x.Code is "703" or "704" or "705" or "706" or "707").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "717"), World), Device.All.Where(x => x.Code is "717" or "718" or "719" or "720" or "721").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "731"), World), Device.All.Where(x => x.Code is "732" or "733" or "734" or "735" or "731").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "745"), World), Device.All.Where(x => x.Code is "746" or "747" or "748" or "749" or "745").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "759"), World), Device.All.Where(x => x.Code is "759" or "760" or "761" or "762" or "763").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "773"), World), Device.All.Where(x => x.Code is "773" or "774" or "775" or "776" or "777").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-                        //_pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "786"), World), Device.All.Where(x => x.Code is "786" or "787" or "788" or "789" or "790").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "661"), World), Device.All.Where(x => x.Code is "661" or "662" or "663" or "664" or "665").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "675"), World), Device.All.Where(x => x.Code is "675" or "676" or "677" or "678" or "679").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "689"), World), Device.All.Where(x => x.Code is "690" or "691" or "692" or "693" or "689").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "703"), World), Device.All.Where(x => x.Code is "703" or "704" or "705" or "706" or "707").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "717"), World), Device.All.Where(x => x.Code is "717" or "718" or "719" or "720" or "721").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "731"), World), Device.All.Where(x => x.Code is "732" or "733" or "734" or "735" or "731").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "745"), World), Device.All.Where(x => x.Code is "746" or "747" or "748" or "749" or "745").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "759"), World), Device.All.Where(x => x.Code is "759" or "760" or "761" or "762" or "763").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "773"), World), Device.All.Where(x => x.Code is "773" or "774" or "775" or "776" or "777").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+                        _pickUpDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "786"), World), Device.All.Where(x => x.Code is "786" or "787" or "788" or "789" or "790").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
                         break;
 
                     case "Truss2":

+ 10 - 10
业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架缓存放行点.cs

@@ -127,16 +127,16 @@ namespace WCS.WorkEngineering.Systems
             _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "578"), World), Device.All.Where(x => x.Code is "578" or "579" or "580" or "581" or "582").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
             _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "591"), World), Device.All.Where(x => x.Code is "591" or "592" or "593" or "594" or "595").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
             //库一南
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "666"), World), Device.All.Where(x => x.Code is "666" or "667" or "668" or "669" or "670").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "680"), World), Device.All.Where(x => x.Code is "680" or "681" or "682" or "683" or "684").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "694"), World), Device.All.Where(x => x.Code is "694" or "695" or "696" or "697" or "698").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "708"), World), Device.All.Where(x => x.Code is "708" or "709" or "710" or "711" or "712").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "722"), World), Device.All.Where(x => x.Code is "722" or "723" or "724" or "725" or "726").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "736"), World), Device.All.Where(x => x.Code is "736" or "737" or "738" or "739" or "740").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "750"), World), Device.All.Where(x => x.Code is "750" or "751" or "752" or "753" or "754").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "764"), World), Device.All.Where(x => x.Code is "764" or "765" or "766" or "767" or "768").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "778"), World), Device.All.Where(x => x.Code is "778" or "779" or "780" or "781" or "782").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
-            //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "791"), World), Device.All.Where(x => x.Code is "791" or "792" or "793" or "794" or "795").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "666"), World), Device.All.Where(x => x.Code is "666" or "667" or "668" or "669" or "670").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "680"), World), Device.All.Where(x => x.Code is "680" or "681" or "682" or "683" or "684").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "694"), World), Device.All.Where(x => x.Code is "694" or "695" or "696" or "697" or "698").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "708"), World), Device.All.Where(x => x.Code is "708" or "709" or "710" or "711" or "712").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "722"), World), Device.All.Where(x => x.Code is "722" or "723" or "724" or "725" or "726").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "736"), World), Device.All.Where(x => x.Code is "736" or "737" or "738" or "739" or "740").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "750"), World), Device.All.Where(x => x.Code is "750" or "751" or "752" or "753" or "754").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "764"), World), Device.All.Where(x => x.Code is "764" or "765" or "766" or "767" or "768").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "778"), World), Device.All.Where(x => x.Code is "778" or "779" or "780" or "781" or "782").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
+            _cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "791"), World), Device.All.Where(x => x.Code is "791" or "792" or "793" or "794" or "795").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
             ////库二北
             //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "866"), World), Device.All.Where(x => x.Code is "866" or "867" or "868" or "869" or "870").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());
             //_cacheDevices.Add(new Device<IStation524, IStation523>(Device.All.First(x => x.Code == "880"), World), Device.All.Where(x => x.Code is "880" or "881" or "882" or "883" or "884").Select(x => new Device<IStation524, IStation523>(x, World)).ToList());

+ 3 - 2
业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛结束.cs

@@ -55,13 +55,14 @@ namespace WCS.WorkEngineering.Systems.环形库
                     }
                     catch (Exception e)
                     {
+                        World.Log($"{e.Message}");
                         try
                         {
-                            WmsApi.BingPallet(cbrCode.BarCode, tasks.Select(x => x.BarCode).ToList(), task.WarehouseCode, task.AddrTo);
+                            WmsApi.BingPallet(cbrCode.BarCode, tasks.Select(x => x.BarCode).ToList(), obj.Entity.Code.GetWareCode(), obj.Entity.Code);
                         }
                         catch (Exception exception)
                         {
-                            throw new Exception($"{e.Message}");
+                            World.Log($"{exception.Message}");
                         }
                     }
                     return;

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/WebApi/Controllers/AgvApi.cs

@@ -79,7 +79,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
                     positionCode=EPosition,
                     type="00"
                 }
-            }, "1", taskCode, "LX01", "1");
+            }, "1", taskCode, "ZTGT35", "1");
         }
 
         /// <summary>

+ 326 - 124
业务工程/分拣库/WCS.WorkEngineering/WorkStart.cs

@@ -1,7 +1,6 @@
 using ServiceCenter;
 using ServiceCenter.SqlSugars;
 using WCS.Core;
-using WCS.Entity;
 using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.RGV;
 using WCS.Entity.Protocol.Robot;
@@ -34,6 +33,17 @@ namespace WCS.WorkEngineering
                 conv.AddProtocol<IStation520>(0, 520, "1");
             }
 
+            //var devs1 = new DevDbConfig<string>()
+            //{
+            //    IP = "1",
+            //    DevCodeList = new List<string>() { nameof(分线计算09), nameof(桁架码垛区补空托盘任务生成), "出库AGV", "入库AGV", nameof(NoInteractionSystems), nameof(UpLoadSystems), nameof(创建二次码垛出库任务) }
+            //};
+            //Parallel.ForEach(devs1.DevCodeList, convCode =>
+            //{
+            //    var conv = new Device(convCode);
+            //    conv.AddProtocol<IStation520>(0, 520, devs1.IP);
+            //});
+
             #endregion 无交互触发设备
 
             #region 设置设备IP集合
@@ -63,6 +73,23 @@ namespace WCS.WorkEngineering
                 //conv.AddProtocol<IStation523>(, 523, item.IP);
             }
 
+            //var rgvInfo = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.113",1),
+            //    new("10.30.37.118",2),
+            //    new("10.30.37.123",3),
+            //    new("10.30.37.128",4),
+            //    new("10.30.37.133",5),
+            //    new("10.30.37.138",6),
+            //};
+            //Parallel.ForEach(rgvInfo, dev =>
+            //{
+            //    var conv = new Device($"RGV{dev.Code}");
+            //    conv.AddFlag(DeviceFlags.RGV);
+            //    conv.AddProtocol<IRGV520>(0, 520, dev.IP);
+            //    conv.AddProtocol<IRGV521>(0, 521, dev.IP);
+            //});
+
             #endregion 初始化RGV相关信息
 
             #region 初始化输送机相关信息
@@ -81,22 +108,22 @@ namespace WCS.WorkEngineering
                     new(2701, 2740),
                     new(1661, 1690),
                 }),
-                ////分拣库二
-                //new("10.30.37.97",new List<Tuple<int, int>>()
-                //{
-                //    new(1621, 1640),
-                //    new(2901, 2940),
-                //    new(3101, 3140),
-                //    new(1691, 1720),
-                //}),
-                ////分拣库三
-                //new("10.30.37.105",new List<Tuple<int, int>>()
-                //{
-                //    new(1641, 1660),
-                //    new(3301, 3340),
-                //    new(3501, 3540),
-                //    new(1721, 1750)
-                //})
+                //分拣库二
+                new("10.30.37.97",new List<Tuple<int, int>>()
+                {
+                    new(1621, 1640),
+                    new(2901, 2940),
+                    new(3101, 3140),
+                    new(1691, 1720),
+                }),
+                //分拣库三
+                new("10.30.37.105",new List<Tuple<int, int>>()
+                {
+                    new(1641, 1660),
+                    new(3301, 3340),
+                    new(3501, 3540),
+                    new(1721, 1750)
+                })
             };
 
             foreach (var item in tuples)
@@ -122,6 +149,35 @@ namespace WCS.WorkEngineering
                 }
             }
 
+            //var devs2 = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.89",new List<DevInterval<int>>(){new (1601,1620),new (2501, 2540),new (2701, 2740),new (1661, 1690) }),
+            //    new("10.30.37.97",new List<DevInterval<int>>(){new (1621, 1640),new (2901, 2940),new (3101, 3140),new (1691, 1720) }),
+            //    new("10.30.37.105",new List<DevInterval<int>>(){new (1641, 1660),new (3301, 3340),new (3501, 3540),new (1721, 1750) })
+            //};
+            //Parallel.ForEach(devs2, dev =>
+            //{
+            //    var db520 = 0;
+            //    var db521 = 0;
+            //    var db523 = 0;
+            //    foreach (var devInterval in dev.DevIntervalList)
+            //    {
+            //        for (var i = devInterval.StartCode; i <= devInterval.EndCode; i++)
+            //        {
+            //            var conv = new Device(i.ToString());
+            //            conv.AddFlag(DeviceFlags.输送机);
+
+            //            conv.AddProtocol<IStation520>(db520, 520, dev.IP);
+            //            conv.AddProtocol<IStation521>(db521, 521, dev.IP);
+            //            conv.AddProtocol<IStation523>(db523, 523, dev.IP);
+
+            //            db520 += 14;
+            //            db521 += 16;
+            //            db523 += 12;
+            //        }
+            //    }
+            //});
+
             #endregion 托盘线输送线
 
             #region 满轮输送线
@@ -138,14 +194,14 @@ namespace WCS.WorkEngineering
                     new(801,999),
                     new(1201,1399),
                 }),
-                //new("10.30.37.198",new List<Tuple<int, int>>() //南侧满轮主线
-                //{
-                //    new(101, 210),
-                //    new(601, 799),
-                //    new(1001, 1199),
-                //    new(1401,1599),
-                //    new(341,379),
-                //})
+                new("10.30.37.198",new List<Tuple<int, int>>() //南侧满轮主线
+                {
+                    new(101, 210),
+                    new(601, 799),
+                    new(1001, 1199),
+                    new(1401,1599),
+                    new(341,379),
+                })
             };
 
             foreach (var item in mLtuples523)
@@ -167,6 +223,31 @@ namespace WCS.WorkEngineering
                 }
             }
 
+            //var devs3 = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.166",new List<DevInterval<int>>(){new (1, 100),new (9001, 9010),new (401, 599),new (801, 999),new (1201, 1399) }),
+            //    new("10.30.37.198",new List<DevInterval<int>>(){new (101, 210),new (601, 799),new (1001, 1199),new (1401, 1599),new (341, 379) })
+            //};
+
+            //Parallel.ForEach(devs3, dev =>
+            //{
+            //    var db523 = 0;
+            //    var db524 = 0;
+            //    foreach (var devInterval in dev.DevIntervalList)
+            //    {
+            //        for (var i = devInterval.StartCode; i <= devInterval.EndCode; i++)
+            //        {
+            //            var conv = new Device(i.ToString());
+            //            conv.AddFlag(DeviceFlags.输送机);
+            //            conv.AddProtocol<IStation523>(db523, 523, dev.IP);
+            //            conv.AddProtocol<IStation524>(db524, 524, dev.IP);
+
+            //            db523 += 12;
+            //            db524 += 16;
+            //        }
+            //    }
+            //});
+
             #endregion DB523,所有线体都会有DB523
 
             #region 520、521 交互线体会有520、521
@@ -176,8 +257,8 @@ namespace WCS.WorkEngineering
             {
                 //北侧
                 new("10.30.37.166",new List<int>() {1,22,41,61,418,426,435,444,455,466,480,494,508,522,536,550,564,578,591,818,826,835,844,855,866,880,894,908,922,936,950,964,978,991,1218,1226,1235,1244,1255,1266,1280,1294,1308,1322,1336,1350,1364,1378,1391}),
-                ////南侧
-                //new("10.30.37.198",new List<int>(){101,122,141,161,618,626,635,644,655,666,680,694,708,722,736,750,764,778,791,1018,1026,1035,1044,1055,1066,1080,1094,1108,1122,1136,1150,1164,1178,1191,1418,1426,1435,1444,1455,1466,1480,1494,1508,1522,1536,1550,1564,1578,1591})
+                //南侧
+                new("10.30.37.198",new List<int>(){101,122,141,161,618,626,635,644,655,666,680,694,708,722,736,750,764,778,791,1018,1026,1035,1044,1055,1066,1080,1094,1108,1122,1136,1150,1164,1178,1191,1418,1426,1435,1444,1455,1466,1480,1494,1508,1522,1536,1550,1564,1578,1591})
             };
 
             foreach (var item in mLTuples520)
@@ -198,6 +279,27 @@ namespace WCS.WorkEngineering
                 }
             }
 
+            //var devs4 = new List<DevDbConfig<int>>()
+            //{
+            //    new ("10.30.37.166",new List<int>(){1,22,41,61,418,426,435,444,455,466,480,494,508,522,536,550,564,578,591,818,826,835,844,855,866,880,894,908,922,936,950,964,978,991,1218,1226,1235,1244,1255,1266,1280,1294,1308,1322,1336,1350,1364,1378,1391}),
+            //    new ("10.30.37.198",new List<int>(){101,122,141,161,618,626,635,644,655,666,680,694,708,722,736,750,764,778,791,1018,1026,1035,1044,1055,1066,1080,1094,1108,1122,1136,1150,1164,1178,1191,1418,1426,1435,1444,1455,1466,1480,1494,1508,1522,1536,1550,1564,1578,1591})
+            //};
+
+            //Parallel.ForEach(devs4, dev =>
+            //{
+            //    var db520 = 0;
+            //    var db521 = 0;
+            //    foreach (var devCode in dev.DevCodeList)
+            //    {
+            //        var device = Device.All.FirstOrDefault(v => v.Code == devCode.ToString());
+            //        device.AddProtocol<IStation520>(db520, 520, dev.IP);
+            //        device.AddProtocol<IStation521>(db521, 521, dev.IP);
+
+            //        db520 += 14;
+            //        db521 += 16;
+            //    }
+            //});
+
             #endregion 520、521 交互线体会有520、521
 
             #region 满轮扫码器
@@ -206,7 +308,7 @@ namespace WCS.WorkEngineering
             var mLTuples83 = new List<Tuple<string, List<int>>>()
             {
                 new("10.30.37.166",new List<int>(){3,14,18,22,38,323,41,58,61}) ,
-                //new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
+                new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
             };
 
             foreach (var item in mLTuples83)
@@ -220,6 +322,23 @@ namespace WCS.WorkEngineering
                     db83 += 604;
                 }
             }
+            //var devs5 = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.166",new List<int>(){3,14,18,22,38,323,41,58,61}) ,
+            //    new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
+            //};
+
+            //Parallel.ForEach(devs5, dev =>
+            //{
+            //    var db83 = 0;
+            //    foreach (var devCode in dev.DevCodeList)
+            //    {
+            //        var device = Device.All.FirstOrDefault(v => v.Code == devCode.ToString());
+            //        device.AddProtocol<IBCR83>(db83, 83, dev.IP);
+
+            //        db83 += 604;
+            //    }
+            //});
 
             #endregion 满轮扫码器
 
@@ -229,7 +348,7 @@ namespace WCS.WorkEngineering
             var mLTuples525 = new List<Tuple<string, List<int>>>()
             {
                 new("10.30.37.166",new List<int>(){18,38,58}),
-                //new("10.30.37.198",new List<int>(){118,138,158}),
+                new("10.30.37.198",new List<int>(){118,138,158}),
             };
 
             foreach (var item in mLTuples525)
@@ -243,6 +362,23 @@ namespace WCS.WorkEngineering
                 }
             }
 
+            //var devs6 = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.166",new List<int>(){18,38,58}),
+            //    new("10.30.37.198",new List<int>(){118,138,158}),
+            //};
+
+            //Parallel.ForEach(devs6, dev =>
+            //{
+            //    var db525 = 0;
+            //    foreach (var devCode in dev.DevCodeList)
+            //    {
+            //        var device = Device.All.FirstOrDefault(v => v.Code == devCode.ToString());
+            //        device?.AddProtocol<IStation525>(db525, 525, dev.IP);
+            //        db525 += 3266;
+            //    }
+            //});
+
             #endregion 满轮线告诉分拣预分配
 
             #region 外检信息
@@ -251,7 +387,7 @@ namespace WCS.WorkEngineering
             var mLTuples91 = new List<Tuple<string, List<int>>>()
             {
                 new("10.30.37.166",new List<int>(){418,818,1218}),
-                //new("10.30.37.198",new List<int>(){618,1018,1418})
+                new("10.30.37.198",new List<int>(){618,1018,1418})
             };
 
             foreach (var item in mLTuples91)
@@ -265,6 +401,23 @@ namespace WCS.WorkEngineering
                 }
             }
 
+            //var devs7 = new List<DevDbConfig<int>>()
+            //{
+            //    new("10.30.37.166",new List<int>(){418,818,1218}),
+            //    new("10.30.37.198",new List<int>(){618,1018,1418})
+            //};
+
+            //Parallel.ForEach(devs7, dev =>
+            //{
+            //    var db91 = 0;
+            //    foreach (var devCode in dev.DevCodeList)
+            //    {
+            //        var device = Device.All.FirstOrDefault(v => v.Code == devCode.ToString());
+            //        device.AddProtocol<IStation91>(db91, 91, dev.IP);
+            //        db91 += 14;
+            //    }
+            //});
+
             #endregion 外检信息
 
             #endregion 满轮输送线
@@ -276,14 +429,14 @@ namespace WCS.WorkEngineering
             var bcrInfo = new List<BcrInfo>
             {
                 new(new [] { "2532", "2732" }, "10.30.37.89"),
-                //new(new [] { "2932", "3132" }, "10.30.37.97"),
+                new(new [] { "2932", "3132" }, "10.30.37.97"),
                 //new(new [] { "2532", "2732" }, "10.30.37.105"),
                 new(new [] {"RGV1"},"10.30.37.113"),
-                //new(new [] {"RGV2"},"10.30.37.118"),
-                //new(new [] {"RGV3"},"10.30.37.123"),
-                //new(new [] {"RGV4"},"10.30.37.128"),
-                //new(new [] {"RGV5"},"10.30.37.133"),
-                //new(new [] {"RGV6"},"10.30.37.138")
+                new(new [] {"RGV2"},"10.30.37.118"),
+                new(new [] {"RGV3"},"10.30.37.123"),
+                new(new [] {"RGV4"},"10.30.37.128"),
+                new(new [] {"RGV5"},"10.30.37.133"),
+                new(new [] {"RGV6"},"10.30.37.138")
             };
 
             foreach (var item in bcrInfo)
@@ -304,7 +457,7 @@ namespace WCS.WorkEngineering
             List<ShapeInfo> shapeInfo = new List<ShapeInfo>
             {
                 new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.89"),
-                //new ShapeInfo(new int[] { 2932, 3132 }, "10.30.37.97"),
+                new ShapeInfo(new int[] { 2932, 3132 }, "10.30.37.97"),
                 //new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.105")
             };
 
@@ -371,7 +524,7 @@ namespace WCS.WorkEngineering
             {
                 //机械臂
                 new("10.30.37.230",new  List<int>(){ 1666, 1661}), //库一北
-                //new("10.30.37.232",new  List<int>(){ 1681, 1676}), //库一南
+                new("10.30.37.232",new  List<int>(){ 1681, 1676}), //库一南
                 //new("10.30.37.234",new  List<int>(){ 1696, 1691}), //库二北
                 //new("10.30.37.236",new  List<int>(){ 1711, 1706}), //库二南
                 //new("10.30.37.238",new  List<int>(){ 1726, 1721}), //库三北
@@ -398,7 +551,7 @@ namespace WCS.WorkEngineering
             List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
             {
                 new( 1, "10.30.37.230"),
-                //new( 2, "10.30.37.232"),
+                new( 2, "10.30.37.232"),
                 //new( 3, "10.30.37.234"),
                 //new( 4, "10.30.37.236"),
                 //new( 5, "10.30.37.238"),
@@ -543,8 +696,8 @@ namespace WCS.WorkEngineering
                 //库一
                 new RouteInfo("Robot1", new string[] { "1666" }),
                 new RouteInfo("Robot1", new string[] { "1661" }),
-                //new RouteInfo("Robot2", new string[] { "1676" }),
-                //new RouteInfo("Robot2", new string[] { "1681" }),
+                new RouteInfo("Robot2", new string[] { "1676" }),
+                new RouteInfo("Robot2", new string[] { "1681" }),
                 ////库二
                 //new RouteInfo("Robot3", new string[] { "1691" }),
                 //new RouteInfo("Robot3", new string[] { "1696" }),
@@ -602,20 +755,20 @@ namespace WCS.WorkEngineering
                 new RouteInfo("41", new string[] { "58" }),
                 new RouteInfo("58", new string[] { "61" }),
                 ////南侧
-                //new RouteInfo("101", new string[] { "114" }),
-                //new RouteInfo("114", new string[] { "118" }),
-                //new RouteInfo("118", new string[] { "122" }),
-                //new RouteInfo("122", new string[] { "138" }),
-                //new RouteInfo("138", new string[] { "141" }),
-                //new RouteInfo("141", new string[] { "158" }),
-                //new RouteInfo("158", new string[] { "161" }),
+                new RouteInfo("101", new string[] { "114" }),
+                new RouteInfo("114", new string[] { "118" }),
+                new RouteInfo("118", new string[] { "122" }),
+                new RouteInfo("122", new string[] { "138" }),
+                new RouteInfo("138", new string[] { "141" }),
+                new RouteInfo("141", new string[] { "158" }),
+                new RouteInfo("158", new string[] { "161" }),
 
                 #endregion 主线
 
                 #region 主线分流点--环形库分流点
 
                 new RouteInfo("22", new string[] { "418" }), //分拣库一北
-                //new RouteInfo("122", new string[] { "618" }), //分拣库一南
+                new RouteInfo("122", new string[] { "618" }), //分拣库一南
                 //new RouteInfo("41", new string[] { "818" }), //分拣库一北
                 //new RouteInfo("141", new string[] { "1018" }), //分拣库一南
                 //new RouteInfo("61", new string[] { "1218" }), //分拣库一北
@@ -626,7 +779,7 @@ namespace WCS.WorkEngineering
                 #region 环形库分流点--环形库取货点
 
                 new RouteInfo("418", new string[] { "424","433","442" }),
-                //new RouteInfo("618", new string[] { "624", "633", "642" }),
+                new RouteInfo("618", new string[] { "624", "633", "642" }),
                 //new RouteInfo("818", new string[] { "824","833","842" }),
                 //new RouteInfo("1018", new string[] { "1024","1033","1042" }),
                 //new RouteInfo("1218", new string[] { "1224","1233","1242" }),
@@ -637,7 +790,7 @@ namespace WCS.WorkEngineering
                 #region 环形库分流点--桁架分流点
 
                 new RouteInfo("418", new string[] { "455" }), //分拣库一北
-                //new RouteInfo("618", new string[] { "655" }), //分拣库一南
+                new RouteInfo("618", new string[] { "655" }), //分拣库一南
                 //new RouteInfo("818", new string[] { "855" }), //分拣库二北
                 //new RouteInfo("1018", new string[] { "1055" }), //分拣库二南
                 //new RouteInfo("1218", new string[] { "1255" }), //分拣库三北
@@ -648,7 +801,7 @@ namespace WCS.WorkEngineering
                 #region 桁架分流点--桁架缓存放行点
 
                 new RouteInfo("455", new string[] { "466","480","494","508", "522","536","550","564","578","591"}), //分拣库一北
-                //new RouteInfo("655", new string[] { "666","680","694","708", "722","736","750","764","778","791"}), //分拣库一南
+                new RouteInfo("655", new string[] { "666","680","694","708", "722","736","750","764","778","791"}), //分拣库一南
                 //new RouteInfo("855", new string[] { "866","880","894","908", "922","936","950","964","978","991"}), //分拣库二北
                 //new RouteInfo("1055", new string[] { "1066","1080","1094","1108", "1122","1136","1150","1164","1178","1191"}), //分拣库二南
                 //new RouteInfo("1255", new string[] { "1266","1280","1294","1308", "1322","1336","1350","1364","1378", "1391"}), //分拣库三北
@@ -668,16 +821,16 @@ namespace WCS.WorkEngineering
                 new("564", new[] { "559" }),
                 new("578", new[] { "573" }),
                 new("591", new[] { "586" }),
-                //new("666", new[] { "661" }),//分拣一南侧
-                //new("680", new[] { "675" }),
-                //new("694", new[] { "689" }),
-                //new("708", new[] { "703" }),
-                //new("722", new[] { "717" }),
-                //new("736", new[] { "731" }),
-                //new("750", new[] { "745" }),
-                //new("764", new[] { "759" }),
-                //new("778", new[] { "773" }),
-                //new("791", new[] { "786" }),
+                new("666", new[] { "661" }),//分拣一南侧
+                new("680", new[] { "675" }),
+                new("694", new[] { "689" }),
+                new("708", new[] { "703" }),
+                new("722", new[] { "717" }),
+                new("736", new[] { "731" }),
+                new("750", new[] { "745" }),
+                new("764", new[] { "759" }),
+                new("778", new[] { "773" }),
+                new("791", new[] { "786" }),
                 //new("866", new[] { "861" }), //分拣二北侧
                 //new("880", new[] { "875" }),
                 //new("894", new[] { "889" }),
@@ -732,17 +885,17 @@ namespace WCS.WorkEngineering
                 new("545", new[] { "Truss1" }),
                 new("559", new[] { "Truss1" }),
                 new("573", new[] { "Truss1" }),
-                //new("586", new[] { "Truss1" }),//分拣一南侧
-                //new("661", new[] { "Truss1" }),
-                //new("675", new[] { "Truss1" }),
-                //new("689", new[] { "Truss1" }),
-                //new("703", new[] { "Truss1" }),
-                //new("717", new[] { "Truss1" }),
-                //new("731", new[] { "Truss1" }),
-                //new("745", new[] { "Truss1" }),
-                //new("759", new[] { "Truss1" }),
-                //new("773", new[] { "Truss1" }),
-                //new("786", new[] { "Truss1" }),
+                new("586", new[] { "Truss1" }),//分拣一南侧
+                new("661", new[] { "Truss1" }),
+                new("675", new[] { "Truss1" }),
+                new("689", new[] { "Truss1" }),
+                new("703", new[] { "Truss1" }),
+                new("717", new[] { "Truss1" }),
+                new("731", new[] { "Truss1" }),
+                new("745", new[] { "Truss1" }),
+                new("759", new[] { "Truss1" }),
+                new("773", new[] { "Truss1" }),
+                new("786", new[] { "Truss1" }),
                 //new("861", new[] { "Truss2" }), //分拣二北侧
                 //new("875", new[] { "Truss2" }),
                 //new("889", new[] { "Truss2" }),
@@ -798,16 +951,16 @@ namespace WCS.WorkEngineering
                 new("559", new[] {  "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
                 new("573", new[] {  "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
                 new("586", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675" }),
-                //new("661", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),//分拣一南侧
-                //new("675", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("689", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("703", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("717", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("731", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("745", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("759", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("773", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
-                //new("786", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("661", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),//分拣一南侧
+                new("675", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("689", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("703", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("717", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("731", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("745", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("759", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("773", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
+                new("786", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
                 //new("861", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), //分拣二北侧
                 //new("875", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705"  }),
                 //new("889", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705"  }),
@@ -875,18 +1028,18 @@ namespace WCS.WorkEngineering
                 new RouteInfo("1674", new string[] { "RGV1" }),
                 new RouteInfo("1675", new string[] { "RGV1" }),
                 ////分拣库一南
-                //new RouteInfo("1676", new string[] { "RGV2" }),//机械手码垛工位
-                //new RouteInfo("1681", new string[] { "RGV2" }),
-                //new RouteInfo("1677", new string[] { "RGV2" }),//绗架码垛工位
-                //new RouteInfo("1678", new string[] { "RGV2" }),
-                //new RouteInfo("1679", new string[] { "RGV2" }),
-                //new RouteInfo("1680", new string[] { "RGV2" }),
-                //new RouteInfo("1685", new string[] { "RGV2" }),
-                //new RouteInfo("1686", new string[] { "RGV2" }),
-                //new RouteInfo("1687", new string[] { "RGV2" }),
-                //new RouteInfo("1688", new string[] { "RGV2" }),
-                //new RouteInfo("1689", new string[] { "RGV2" }),
-                //new RouteInfo("1690", new string[] { "RGV2" }),
+                new RouteInfo("1676", new string[] { "RGV2" }),//机械手码垛工位
+                new RouteInfo("1681", new string[] { "RGV2" }),
+                new RouteInfo("1677", new string[] { "RGV2" }),//绗架码垛工位
+                new RouteInfo("1678", new string[] { "RGV2" }),
+                new RouteInfo("1679", new string[] { "RGV2" }),
+                new RouteInfo("1680", new string[] { "RGV2" }),
+                new RouteInfo("1685", new string[] { "RGV2" }),
+                new RouteInfo("1686", new string[] { "RGV2" }),
+                new RouteInfo("1687", new string[] { "RGV2" }),
+                new RouteInfo("1688", new string[] { "RGV2" }),
+                new RouteInfo("1689", new string[] { "RGV2" }),
+                new RouteInfo("1690", new string[] { "RGV2" }),
 
                 ////分拣库二北
                 //new RouteInfo("1691", new string[] { "RGV3" }),//机械手码垛工位
@@ -992,9 +1145,9 @@ namespace WCS.WorkEngineering
                 new RouteInfo("442", new string[] { "Robot1" }),
                 new RouteInfo("433", new string[] { "Robot1" }),
                 new RouteInfo("424", new string[] { "Robot1" }),
-                //new RouteInfo("624", new string[] { "Robot2" }),
-                //new RouteInfo("633", new string[] { "Robot2" }),
-                //new RouteInfo("642", new string[] { "Robot2" }),
+                new RouteInfo("624", new string[] { "Robot2" }),
+                new RouteInfo("633", new string[] { "Robot2" }),
+                new RouteInfo("642", new string[] { "Robot2" }),
                 //new RouteInfo("824", new string[] { "Robot3" }),
                 //new RouteInfo("833", new string[] { "Robot3" }),
                 //new RouteInfo("842", new string[] { "Robot3" }),
@@ -1029,7 +1182,6 @@ namespace WCS.WorkEngineering
             }
             //Parallel.ForEach(routeInfos, routeInfo =>
             //{
-
             //});
 
             #endregion 配置路径信息
@@ -1042,10 +1194,10 @@ namespace WCS.WorkEngineering
                 new("424",new List<string> {"424","425"}),
                 new("433",new List<string> {"433","434"}),
                 new("442",new List<string> {"442","443"}),
-                ////环形库一南侧侧机械手取货位
-                //new("642",new List<string> {"642","643"}),
-                //new("633",new List<string> {"633","634"}),
-                //new("624",new List<string> {"624","625"}),
+                //环形库一南侧侧机械手取货位
+                new("642",new List<string> {"642","643"}),
+                new("633",new List<string> {"633","634"}),
+                new("624",new List<string> {"624","625"}),
                 ////环形库二北侧机械手取货位
                 //new("824",new List<string> {"824","825"}),
                 //new("833",new List<string> {"833","834"}),
@@ -1082,20 +1234,20 @@ namespace WCS.WorkEngineering
                 { DeviceFlags.一楼叠盘机,new List<string>() { "2527", "2528", "2727", "2728"/*, "2927", "2928", "3127", "3128" , "3327", "3328", "3527", "3528"*/ } },
                 { DeviceFlags.主线分流点,new List<string>() { "22","41","61"} },
                 { DeviceFlags.满轮主线第一次扫码,new List<string>() { "1"} },
-                { DeviceFlags.环形库分流点,new List<string>(){ "418"/*, "618", "818","1018","1218","1418"*/ } },
-                { DeviceFlags.桁架分流点,new List<string>() { "455"/*, "655", "855","1055","1255","1455"*/ } },
-                { DeviceFlags.桁架缓存放行点, new List<string>(){ "466", "480", "494", "508", "522", "536", "550", "564", "578", "591"/*, "666", "680", "694", "708", "722", "736", "750", "764", "778", "791", "866", "880", "894", "908", "922", "936", "950", "964", "978", "991" , "1066", "1080", "1094", "1108", "1122", "1136", "1150", "1164", "1178", "1191" , "1266", "1280", "1294", "1308", "1322", "1336", "1350", "1364", "1378", "1391" , "1466", "1480", "1494", "1408", "1422", "1436", "1450", "1464", "1478", "1591"*/ } },
-                { DeviceFlags.桁架09缓存放行点, new List<string>(){ "466", "480", "494", "508", "522", "536"/*, "666", "680", "694", "708", "722", "736", "866", "880", "894", "908", "922", "936", "1066", "1080", "1094", "1108", "1122", "1136",  "1266", "1280", "1294", "1308", "1322", "1336",  "1466", "1480", "1494", "1408", "1422", "1436"*/ } },
-                { DeviceFlags.桁架09异常缓存放行点, new List<string>(){ "591"/*, "791", "991" , "1191" , "1391" , "1591"*/ } },
+                { DeviceFlags.环形库分流点,new List<string>(){ "418", "618"/*, "818","1018","1218","1418"*/ } },
+                { DeviceFlags.桁架分流点,new List<string>() { "455", "655"/*, "855","1055","1255","1455"*/ } },
+                { DeviceFlags.桁架缓存放行点, new List<string>(){ "466", "480", "494", "508", "522", "536", "550", "564", "578", "591", "666", "680", "694", "708", "722", "736", "750", "764", "778", "791"/*, "866", "880", "894", "908", "922", "936", "950", "964", "978", "991" , "1066", "1080", "1094", "1108", "1122", "1136", "1150", "1164", "1178", "1191" , "1266", "1280", "1294", "1308", "1322", "1336", "1350", "1364", "1378", "1391" , "1466", "1480", "1494", "1408", "1422", "1436", "1450", "1464", "1478", "1591"*/ } },
+                { DeviceFlags.桁架09缓存放行点, new List<string>(){ "466", "480", "494", "508", "522", "536", "666", "680", "694", "708", "722", "736"/*, "866", "880", "894", "908", "922", "936", "1066", "1080", "1094", "1108", "1122", "1136",  "1266", "1280", "1294", "1308", "1322", "1336",  "1466", "1480", "1494", "1408", "1422", "1436"*/ } },
+                { DeviceFlags.桁架09异常缓存放行点, new List<string>(){ "591", "791"/*, "991" , "1191" , "1391" , "1591"*/ } },
                 { DeviceFlags.桁架18缓存放行点, new List<string>(){ "550", "564", "578", "750", "764", "778"/*, "950", "964", "978" , "1150", "1164", "1178" , "1350", "1364", "1378" , "1450", "1464", "1478"*/ } },
-                { DeviceFlags.桁架取货点, new List<string>(){ "461", "475", "489", "503", "517", "531", "545", "559", "573", "586"/*, "661", "675", "689", "703", "717", "731", "745", "759", "773", "786", "861", "875", "889", "903", "917", "931", "945", "959", "973", "986", "1061", "1075", "1089", "1103", "1117", "1131", "1145", "1159", "1173", "1186", "1261", "1275", "1289", "1303", "1317", "1331", "1345", "1359", "1373", "1386" , "1461", "1475", "1489", "1503", "1517", "1531", "1545", "1559", "1573", "1586"*/ } },
+                { DeviceFlags.桁架取货点, new List<string>(){ "461", "475", "489", "503", "517", "531", "545", "559", "573", "586", "661", "675", "689", "703", "717", "731", "745", "759", "773", "786"/*, "861", "875", "889", "903", "917", "931", "945", "959", "973", "986", "1061", "1075", "1089", "1103", "1117", "1131", "1145", "1159", "1173", "1186", "1261", "1275", "1289", "1303", "1317", "1331", "1345", "1359", "1373", "1386" , "1461", "1475", "1489", "1503", "1517", "1531", "1545", "1559", "1573", "1586"*/ } },
                 //{ DeviceFlags.拆盘机09, new List<string>(){ /*"1606", "1616",*/"1626","1636","1646","1656" } },
                 { DeviceFlags.拆盘机, new List<string>(){ "1602", "1612"/*, "1622","1632","1642","1652"*/ } },
                 { DeviceFlags.桁架码垛位, new List<string>(){ "1670", "1671", "1672", "1673"/*, "1674", "1675"*/,"1664","1662","1663","1665","1677","1678","1679","1680","1685","1686","1687","1688","1689"/*,"1690", "1692", "1693", "1694", "1695", "1700", "1701", "1702", "1703", "1704", "1705", "1707", "1708", "1709", "1710", "1715", "1716", "1717", "1718", "1719", "1720", "1722", "1723", "1724", "1725", "1730", "1731", "1732", "1733", "1734", "1735", "1737", "1738", "1739", "1740", "1745", "1746", "1747", "1748", "1749", "1750"*/ } },
-                { DeviceFlags.环形库码垛工位, new List<string>(){ "1666", "1661"/*, "1676", "1681", "1691", "1696", "1706", "1711", "1721", "1726", "1736", "1741"*/ } },
-                { DeviceFlags.AGV取货站台口, new List<string>(){ "2533", "2534"/*, "2734","2733","2934","2933","3133","3134","3333","3334","3533","3534" */} },
-                { DeviceFlags.Robot, new List<string>(){ "Robot1"/*, "Robot2", "Robot3","Robot4" , "Robot5", "Robot6"*/ } },
-                {DeviceFlags.二次码垛RGV取货口, new List<string>(){ "1606"/*, "1616", "1626","1636","1646","1656"*/}}
+                { DeviceFlags.环形库码垛工位, new List<string>(){ "1666", "1661", "1676", "1681"/*, "1691", "1696", "1706", "1711", "1721", "1726", "1736", "1741"*/ } },
+                { DeviceFlags.AGV取货站台口, new List<string>(){ "2533", "2534", "2734", "2733"/*,"2934","2933","3133","3134","3333","3334","3533","3534" */} },
+                { DeviceFlags.Robot, new List<string>(){ "Robot1", "Robot2"/*, "Robot3","Robot4" , "Robot5", "Robot6"*/ } },
+                {DeviceFlags.二次码垛RGV取货口, new List<string>(){ "1606", "1616"/*, "1626","1636","1646","1656"*/}}
         };
 
             Parallel.ForEach(devices, device =>
@@ -1129,17 +1281,17 @@ namespace WCS.WorkEngineering
                     {
                         case "WCSDB"://WCS基本数据库
                             SqlSugarHelper.SetDefault(connectionString.Key);
-                            _db.CodeFirst.InitTables(typeof(WCS_PlcData));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskOld));
-                            _db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
-                            _db.CodeFirst.InitTables(typeof(WCS_Palletizing));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
-                            _db.CodeFirst.InitTables(typeof(WCS_CacheLine));
-                            _db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PlcData));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskOld));
+                            //_db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Palletizing));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
+                            //_db.CodeFirst.InitTables(typeof(WCS_CacheLine));
+                            //_db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
 
                             break;
 
@@ -1188,4 +1340,54 @@ namespace WCS.WorkEngineering
             });
         }
     }
+
+    public class DevDbConfig<T>
+    {
+        public DevDbConfig()
+        {
+        }
+
+        public DevDbConfig(string ip, T code)
+        {
+            IP = ip;
+            Code = code;
+        }
+
+        public DevDbConfig(string ip, List<DevInterval<T>> devIntervalList)
+        {
+            IP = ip;
+            DevIntervalList = devIntervalList;
+        }
+
+        public DevDbConfig(string ip, List<T> devCodeList)
+        {
+            IP = ip;
+            DevCodeList = devCodeList;
+        }
+
+        public string IP { get; set; }
+
+        public T Code { get; set; }
+
+        public T StartCode { get; set; }
+
+        public T EndCode { get; set; }
+
+        public List<T> DevCodeList { get; set; }
+
+        public List<DevInterval<T>> DevIntervalList { get; set; }
+    }
+
+    public class DevInterval<T>
+    {
+        public DevInterval(T s, T e)
+        {
+            StartCode = s;
+            EndCode = e;
+        }
+
+        public T StartCode { get; set; }
+
+        public T EndCode { get; set; }
+    }
 }

+ 20 - 11
业务工程/分拣库/WCS.WorkEngineering/数据采集.cs

@@ -3,12 +3,14 @@ using ServiceCenter.Extensions;
 using System.ComponentModel;
 using System.Diagnostics;
 using WCS.Core;
+using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.DataStructure;
+using WCS.Entity.Protocol.Station;
 using WCS.WorkEngineering.Worlds;
 
 namespace WCS.WorkEngineering.Systems
 {
-    //[BelongTo(typeof(DataCollectionWorld))]
+    //[BelongTo(typeof(MainWorld))]
     [Description("数据采集系统")]
     public class 数据采集 : SystemBase
     {
@@ -17,8 +19,8 @@ namespace WCS.WorkEngineering.Systems
         public 数据采集()
         {
             var gs = Device.All.SelectMany(v => v.Protocols.Select(d => new { DB = $"{d.Value.DBInfo.No}:{d.Value.DBInfo.PLCInfo.IP}", d.Value.Position, TypeStr = d.Key, Dev = v }))
-                 .GroupBy(v => v.DB);
-            foreach (var g in gs.Where(x => !x.Key.Contains("10.30.37.211")))
+                .GroupBy(v => v.DB);
+            foreach (var g in gs)
             {
                 var min = g.OrderBy(v => v.Position).First();
                 var max = g.OrderByDescending(v => v.Position).First();
@@ -39,10 +41,10 @@ namespace WCS.WorkEngineering.Systems
             sw.Start();
             var pack = new DeviceDataPack();
             pack.Frame = DateTime.Now;
-            var ps = pack.GetType().GetProperties();
+            var ps = pack.GetType().GetProperties().OrderBy(x => x.Name);
             foreach (var p in ps)
             {
-                if (!p.PropertyType.IsArray)
+                if (!p.PropertyType.IsArray&&p.PropertyType!= typeof(IBCR80[]))
                     continue;
                 var dev = p.PropertyType.GetElementType();
                 if (dev.GetInterfaces().Any(v => v.GetInterfaces().Any(d => d.Name == "IProtocol")))
@@ -56,7 +58,14 @@ namespace WCS.WorkEngineering.Systems
                         {
                             var obj = Activator.CreateInstance(t);
                             t.GetProperty("Code").SetValue(obj, v.Code);
-                            var value = v.Protocol(protType, World).Copy(t);
+                            dynamic protObj = v.Protocol(protType, World);
+                            if (protType == typeof(IBCR81))
+                            {
+                                var a = new Device<IBCR81>(v, World);
+                                var b = a.Data.Content;
+
+                            }
+                            var value = ServiceCenter.Extensions.TypeExtension.Copy(protObj, t);
                             //t.GetProperty("Data").SetValue(obj, value);
                             return obj;
                         }
@@ -77,11 +86,11 @@ namespace WCS.WorkEngineering.Systems
                 }
             }
 
-            Redis.RPush("Packs", pack);
-            if (Redis.LLen("Packs") > 50000)
-            {
-                Redis.LTrim("Packs", 5000, -1);
-            }
+            //Redis.RPush("Packs", pack);
+            //if (Redis.LLen("Packs") > 50000)
+            //{
+            //    Redis.LTrim("Packs", 5000, -1);
+            //}
 
             sw.Stop();
             list.Add(new WorkTimes { Total = sw.ElapsedMilliseconds, Key = "采集数据" });