using PlcSiemens.Core.Extension; using ServiceCenter; using ServiceCenter.SqlSugars; using WCS.Core; using WCS.Entity; using WCS.Entity.Protocol; using WCS.Entity.Protocol.BCR; 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.Systems; using WCS.WorkEngineering.Systems.桁架码垛; using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags; namespace WCS.WorkEngineering { /// /// 业务工程配置信息 /// public static class WorkStart { /// /// 仓库 /// public static string? WareHouses { get; set; } /// /// 初始化 设备信息 /// public static void InitializeDeviceInfo() { if (WareHouses.IsNullOrEmpty()) { throw new Exception("请配置当前程序所属的分拣中心"); } #region 无交互触发设备,只在分拣1有 if (WareHouses.Contains("FJ1")) { var devs = new List() { nameof(PalletizCreateEmptyTray), "AGVIn", "AGVOut", nameof(NoInteractionSystems), nameof(UpLoadSystems), nameof(TrussCreateTwoOut) }; foreach (var conv in devs.Select(code => new Device(code))) { conv.AddProtocol(0, 520, "1"); conv.AddFlag(DeviceFlags.无交互触发设备); } } #endregion 无交互触发设备,只在分拣1有 #region 设置设备IP集合 ServiceHub.DeviceIPList = new List() { }; #endregion 设置设备IP集合 #region 满轮输送线 #region DB523,所有线体都会有DB523 var mLtuples523 = new List>>>() { new("10.30.37.166",new List>() //北侧满轮主线 { new(1, 100), new(9001, 9010),//暂用,无意义 new(401, 599), new(801,999), new(1201,1399), }), new("10.30.37.198",new List>() //南侧满轮主线 { new(101, 210), new(601, 799), new(1001, 1199), new(1401,1599), new(341,379), }) }; foreach (var item in mLtuples523) { var db523 = 0; var db524 = 0; foreach (var item1 in item.Item2) { for (var i = item1.Item1; i <= item1.Item2; i++) { var conv = new Device(i.ToString()); conv.AddFlag(DeviceFlags.输送机); conv.AddProtocol(db523, 523, item.Item1); conv.AddProtocol(db524, 524, item.Item1); db523 += 12; db524 += 16; } } } #endregion DB523,所有线体都会有DB523 #region 520、521 交互线体会有520、521 //Item2表示线体号集合,Item1表示IP var mLTuples520 = new List>>() { //北侧 new("10.30.37.166",new List() {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(){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) { var db520 = 0; var db521 = 0; foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString()))) { if (device != null) { device.AddProtocol(db520, 520, item.Item1); device.AddProtocol(db521, 521, item.Item1); } db520 += 14; db521 += 16; } } #endregion 520、521 交互线体会有520、521 #region 满轮扫码器 //Item2表示线体号集合,Item1表示IP var mLTuples83 = new List>>() { new("10.30.37.166",new List(){3,14,18,22,38,323,41,58,61}) , new("10.30.37.198",new List(){101,114,118,122,138,363,141,158,161}) }; foreach (var item in mLTuples83) { var db83 = 0; foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString()))) { device?.AddProtocol(db83, 83, item.Item1); db83 += 604; } } #endregion 满轮扫码器 #region 满轮线告诉分拣预分配 //Item2表示线体号集合,Item1表示IP var mLTuples525 = new List>>() { new("10.30.37.166",new List(){18,38,58}), new("10.30.37.198",new List(){118,138,158}), }; foreach (var item in mLTuples525) { var db525 = 0; foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString()))) { device?.AddProtocol(db525, 525, item.Item1); db525 += 3266; } } #endregion 满轮线告诉分拣预分配 #region 外检信息 //Item2表示线体号集合,Item1表示IP var mLTuples91 = new List>>() { new("10.30.37.166",new List(){418,818,1218}), new("10.30.37.198",new List(){618,1018,1418}) }; foreach (var item in mLTuples91) { var db91 = 0; foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString()))) { device?.AddProtocol(db91, 91, item.Item1); db91 += 14; } } #endregion 外检信息 #endregion 满轮输送线 List routeInfos1 = new List(); routeInfos1.AddRange(new List() { #region 主线 //北侧 new RouteInfo("3", new string[] { "14" }), new RouteInfo("14", new string[] { "18" }), new RouteInfo("18", new string[] { "22" }), new RouteInfo("22", new string[] { "38" }), new RouteInfo("38", new string[] { "41" }), 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" }), #endregion 主线 #region 主线分流点--环形库分流点 new RouteInfo("22", new string[] { "418" }), //分拣库一北 new RouteInfo("122", new string[] { "618" }), //分拣库一南 new RouteInfo("41", new string[] { "818" }), //分拣库二北 new RouteInfo("141", new string[] { "1018" }), //分拣库二南 new RouteInfo("61", new string[] { "1218" }), //分拣库三北 new RouteInfo("161", new string[] { "1418" }), //分拣库三南 #endregion 主线分流点--环形库分流点 }); foreach (var routeInfo in routeInfos1) { if (routeInfo != null) { var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode); device.AddTarget(routeInfo.NextList); Parallel.ForEach(routeInfo.NextList, next => { var dev = Device.All.FirstOrDefault(x => x.Code == next); dev.Parent = device; }); } } if (WareHouses.Contains("FJ1")) { #region 初始化RGV相关信息 List RgvInfo = new List { new RgvSegmentInfo( 1, "10.30.37.113"), //库一北 new RgvSegmentInfo( 2, "10.30.37.118"), //库一南 }; foreach (var item in RgvInfo) { var conv = new Device($"RGV{item.Code}"); conv.AddFlag(DeviceFlags.RGV); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); //conv.AddProtocol(, 523, item.IP); } #endregion 初始化RGV相关信息 #region 初始化输送机相关信息 #region 基本信息 #region 托盘线输送线 var tuples = new List>>> { //分拣库一 new("10.30.37.89",new List>() { new(1601, 1620), new(2501, 2540), new(2701, 2740), new(1661, 1690), }), }; foreach (var item in tuples) { var db520 = 0; var db521 = 0; var db523 = 0; foreach (var item1 in item.Item2) { for (var i = item1.Item1; i <= item1.Item2; i++) { var conv = new Device(i.ToString()); conv.AddFlag(DeviceFlags.输送机); conv.AddProtocol(db520, 520, item.Item1); conv.AddProtocol(db521, 521, item.Item1); conv.AddProtocol(db523, 523, item.Item1); db520 += 14; db521 += 16; db523 += 12; } } } #endregion 托盘线输送线 #endregion 基本信息 #region 托盘线扫码器 var bcrInfo = new List { new(new [] { "2532", "2732" }, "10.30.37.89"), new(new [] {"RGV1"},"10.30.37.113"), new(new [] {"RGV2"},"10.30.37.118"), }; foreach (var item in bcrInfo) { for (var i = 0; i < item.DeviceNo.Length; i++) { var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]); device.AddFlag(DeviceFlags.扫码); var pos = i * 130; device.AddProtocol(pos, 81, item.Ip); } } #endregion 托盘线扫码器 #region 外检信息 // List shapeInfo = new List //{ // new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.89"), //}; //foreach (var item in shapeInfo) //{ // for (int i = 0; i < item.DeviceNo.Length; i++) // { // var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString()); // conv.AddFlag(DeviceFlags.外检); // int pos = i * 14; // conv.AddProtocol(pos, 91, item.Ip); // } //} var conv1 = Device.All.FirstOrDefault(x => x.Code == "2532"); conv1.AddFlag(DeviceFlags.外检); conv1.AddProtocol(714, 91, "10.30.37.89"); var conv2 = Device.All.FirstOrDefault(x => x.Code == "2732"); conv2.AddFlag(DeviceFlags.外检); conv2.AddProtocol(1274, 91, "10.30.37.89"); #endregion 外检信息 #endregion 初始化输送机相关信息 #region 初始化桁架相关信息 List TrussInfo = new List { new TrussSegmentInfo( 1, "10.30.37.211"), }; foreach (var item in TrussInfo) { var conv = new Device($"Truss{item.Code}"); conv.AddFlag(DeviceFlags.桁架); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 523, item.Ip); } var tuples1 = new List>> { //桁架 new("10.30.37.211",new List(){1685,1686,1687,1688,1689,1690,1675,1674,1673,1672,1671,1670,1677,1678,1679,1680,1665,1664,1663,1662,1616,1606}), //分拣库一 }; foreach (var item in tuples1) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 18; db531 += 250; } } var tuples21 = new List>> { //机械臂 new("10.30.37.230",new List(){ 1666, 1661}), //库一北 new("10.30.37.232",new List(){ 1681, 1676}), //库一南 }; foreach (var item in tuples21) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 8; db531 += 130; } } #endregion 初始化桁架相关信息 #region 初始化机械臂相关信息 List TrussInfo1 = new List { new( 1, "10.30.37.230"), new( 2, "10.30.37.232"), }; foreach (var item in TrussInfo1) { var conv = new Device($"Robot{item.Code}"); conv.AddFlag(DeviceFlags.Robot); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 522, item.Ip); } #endregion 初始化机械臂相关信息 #region 初始化堆垛机相关信息 int ip = 41; for (int i = 0; i <= 1; i++) { var srm = new Device($"SRM{i + 1}"); srm.AddFlag(DeviceFlags.堆垛机); ip = i == 0 ? ip : ip + 8; //三台堆垛机IP主机位分别是 41、49、57、65、73、81 srm.AddProtocol(0, 520, $"10.30.37.{ip}"); srm.AddProtocol(0, 521, $"10.30.37.{ip}"); srm.AddProtocol(0, 537, $"10.30.37.{ip}"); //增加巷道 var tunnel = new Device($"TY{i + 1}"); tunnel.AddFlag(DeviceFlags.巷道); } #endregion 初始化堆垛机相关信息 #region 配置路径信息 List routeInfos = new List(); routeInfos.AddRange(new List() { #region 出库 #region 堆垛机--巷道 new RouteInfo("SRM1", new string[] { "TY1" }), new RouteInfo("SRM2", new string[] { "TY2" }), #endregion 堆垛机--巷道 #region 巷道--一楼堆垛机放货口 new RouteInfo("TY1", new string[] { "2532","2534",/*"2533"*/ }), //人工取货口 new RouteInfo("TY2", new string[] { "2732","2734","2733" }), #endregion 巷道--一楼堆垛机放货口 #region 巷道--二楼堆垛机放货口 new RouteInfo("TY1", new string[] { "1601","1605" }), new RouteInfo("TY2", new string[] { "1611","1615" }), #endregion 巷道--二楼堆垛机放货口 #region 二楼堆垛机放货口--二楼拆盘机 //库一 new RouteInfo("1601", new string[] { "1602" }),//非09拆盘机 new RouteInfo("1611", new string[] { "1612"}), new RouteInfo("1605", new string[] { "1606" }),//09拆盘机 new RouteInfo("1615", new string[] { "1616" }), #endregion 二楼堆垛机放货口--二楼拆盘机 #region 二楼拆盘机--RGV //库一 new RouteInfo("1602", new string[] { "RGV1" }),//非09拆盘机 new RouteInfo("1612", new string[] { "RGV2"}), new RouteInfo("1606", new string[] { "RGV1" }),//09拆盘机 new RouteInfo("1616", new string[] { "RGV2" }), #endregion 二楼拆盘机--RGV #region RGV--码垛区域 //库一 new RouteInfo("RGV1", new string[] { "1661","1666" }),//北区机械臂码垛区 new RouteInfo("RGV1", new string[] { "1662","1663","1664","1665", "1670","1671","1672","1673","1674","1675"}),//桁架北区码垛站台 new RouteInfo("RGV2", new string[] { "1676","1681" }), new RouteInfo("RGV2", new string[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }), #endregion RGV--码垛区域 #region Robot--码垛工位 //库一 new RouteInfo("Robot1", new string[] { "1666" }), new RouteInfo("Robot1", new string[] { "1661" }), new RouteInfo("Robot2", new string[] { "1676" }), new RouteInfo("Robot2", new string[] { "1681" }), #endregion Robot--码垛工位 #endregion 出库 #region 入库 #region 一楼人工入库口-巷道 new RouteInfo("2532", new string[] { "TY1" }), new RouteInfo("2533", new string[] { "TY1" }),//分拣库一 new RouteInfo("2732", new string[] { "TY2" }), #endregion 一楼人工入库口-巷道 #region 一楼叠盘机(堆垛机入口)--巷道 new RouteInfo("2527", new string[] { "TY1" }), //分拣库一 new RouteInfo("2528", new string[] { "TY1" }), new RouteInfo("2727", new string[] { "TY2" }), new RouteInfo("2728", new string[] { "TY2" }), #endregion 一楼叠盘机(堆垛机入口)--巷道 #region 环形库分流点--环形库取货点 new RouteInfo("418", new string[] { "424","433","442" }), new RouteInfo("618", new string[] { "624", "633", "642" }), #endregion 环形库分流点--环形库取货点 #region 环形库分流点--桁架分流点 new RouteInfo("418", new string[] { "455" }), //分拣库一北 new RouteInfo("618", new string[] { "655" }), //分拣库一南 #endregion 环形库分流点--桁架分流点 #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"}), //分拣库一南 #endregion 桁架分流点--桁架缓存放行点 #region 桁架缓存放行点--桁架取货点 new("466", new[] { "461" }), //分拣一北侧 new("480", new[] { "475" }), new("494", new[] { "489" }), new("508", new[] { "503" }), new("522", new[] { "517" }), new("536", new[] { "531" }), new("550", new[] { "545" }), 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" }), #endregion 桁架缓存放行点--桁架取货点 #region 桁架取货点--桁架 new("461", new[] { "Truss1" }),//分拣一北侧 new("475", new[] { "Truss1" }), new("489", new[] { "Truss1" }), new("503", new[] { "Truss1" }), new("517", new[] { "Truss1" }), new("531", new[] { "Truss1" }), 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" }), #endregion 桁架取货点--桁架 #region 桁架取货点--码垛工位 new("461", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675" }),//分拣一北侧 new("475", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), new("489", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), new("503", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), new("517", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), new("531", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), new("545", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}), 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" }), #endregion 桁架取货点--码垛工位 #region 桁架--码垛工位 new("Truss1", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675","1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }), #endregion 桁架--码垛工位 #region 码垛工位--RGV //分拣库一北 new RouteInfo("1661", new string[] { "RGV1" }),//机械手码垛工位 new RouteInfo("1666", new string[] { "RGV1" }), new RouteInfo("1662", new string[] { "RGV1" }),//绗架码垛工位 new RouteInfo("1663", new string[] { "RGV1" }), new RouteInfo("1664", new string[] { "RGV1" }), new RouteInfo("1665", new string[] { "RGV1" }), new RouteInfo("1670", new string[] { "RGV1" }), new RouteInfo("1671", new string[] { "RGV1" }), new RouteInfo("1672", new string[] { "RGV1" }), new RouteInfo("1673", new string[] { "RGV1" }), 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" }), #endregion 码垛工位--RGV #region RGV--RGV放货点 new RouteInfo("RGV1", new string[] { "1604" }), new RouteInfo("RGV2", new string[] { "1614" }), #endregion RGV--RGV放货点 #region RGV放货点--堆垛机取货口 new RouteInfo("1604", new string[] { "1603" }),//北侧 new RouteInfo("1614", new string[] { "1613" }),//南侧 #endregion RGV放货点--堆垛机取货口 #region 二楼堆垛机入库--巷道 new RouteInfo("1603", new string[] { "TY1" }),//北侧 new RouteInfo("1613", new string[] { "TY2" }),//南侧 #endregion 二楼堆垛机入库--巷道 #region 巷道--堆垛机 new RouteInfo("TY1", new string[] { "SRM1" }), new RouteInfo("TY2", new string[] { "SRM2" }), #endregion 巷道--堆垛机 #region 线体取货位--Robot 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" }), #endregion 线体取货位--Robot #endregion 入库 }); foreach (var routeInfo in routeInfos) { if (routeInfo != null) { var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode); device.AddTarget(routeInfo.NextList); Parallel.ForEach(routeInfo.NextList, next => { var dev = Device.All.FirstOrDefault(x => x.Code == next); dev.Parent = device; }); } } //Parallel.ForEach(routeInfos, routeInfo => //{ //}); #endregion 配置路径信息 #region 添加设备组 var tuples2 = new List>>() { //环形库一北侧机械手取货位 new("424",new List {"424","425"}), new("433",new List {"433","434"}), new("442",new List {"442","443"}), //环形库一南侧侧机械手取货位 new("642",new List {"642","643"}), new("633",new List {"633","634"}), new("624",new List {"624","625"}), }; Parallel.ForEach(tuples2, tuple => { var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1); device.AddDeviceGroup(tuple.Item2.ToArray()); }); #endregion 添加设备组 } if (WareHouses.Contains("FJ2")) { #region 初始化RGV相关信息 List RgvInfo = new List { new RgvSegmentInfo( 3, "10.30.37.123"), //库二北 new RgvSegmentInfo( 4, "10.30.37.128"), //库二南 }; foreach (var item in RgvInfo) { var conv = new Device($"RGV{item.Code}"); conv.AddFlag(DeviceFlags.RGV); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); //conv.AddProtocol(, 523, item.IP); } #endregion 初始化RGV相关信息 #region 初始化输送机相关信息 #region 基本信息 #region 托盘线输送线 var tuples = new List>>> { //分拣库二 new("10.30.37.97",new List>() { new(1621, 1640), new(2901, 2940), new(3101, 3140), new(1691, 1720), }), }; foreach (var item in tuples) { var db520 = 0; var db521 = 0; var db523 = 0; foreach (var item1 in item.Item2) { for (var i = item1.Item1; i <= item1.Item2; i++) { var conv = new Device(i.ToString()); conv.AddFlag(DeviceFlags.输送机); conv.AddProtocol(db520, 520, item.Item1); conv.AddProtocol(db521, 521, item.Item1); conv.AddProtocol(db523, 523, item.Item1); db520 += 14; db521 += 16; db523 += 12; } } } #endregion 托盘线输送线 #endregion 基本信息 #region 托盘线扫码器 var bcrInfo = new List { new(new [] { "2932", "3132" }, "10.30.37.97"), new(new [] {"RGV3"},"10.30.37.123"), new(new [] {"RGV4"},"10.30.37.128"), }; foreach (var item in bcrInfo) { for (var i = 0; i < item.DeviceNo.Length; i++) { var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]); device.AddFlag(DeviceFlags.扫码); var pos = i * 130; device.AddProtocol(pos, 81, item.Ip); } } #endregion 托盘线扫码器 #region 外检信息 //List shapeInfo = new List //{ // new ShapeInfo(new int[] { 2932,3132 }, "10.30.37.97"), //}; //foreach (var item in shapeInfo) //{ // for (int i = 0; i < item.DeviceNo.Length; i++) // { // var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString()); // conv.AddFlag(DeviceFlags.外检); // int pos = i * 14; // conv.AddProtocol(pos, 91, item.Ip); // } //} var conv1 = Device.All.FirstOrDefault(x => x.Code == "2932"); conv1.AddFlag(DeviceFlags.外检); conv1.AddProtocol(714, 91, "10.30.37.97"); var conv2 = Device.All.FirstOrDefault(x => x.Code == "3132"); conv2.AddFlag(DeviceFlags.外检); conv2.AddProtocol(1274, 91, "10.30.37.97"); #endregion 外检信息 #endregion 初始化输送机相关信息 #region 初始化桁架相关信息 List TrussInfo = new List { new TrussSegmentInfo( 2, "10.30.37.217"), }; foreach (var item in TrussInfo) { var conv = new Device($"Truss{item.Code}"); conv.AddFlag(DeviceFlags.桁架); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 523, item.Ip); } var tuples1 = new List>> { //桁架 new("10.30.37.217",new List(){1715,1716,1717,1718,1719,1720,1705,1704,1703,1702,1701,1700,1707,1708,1709,1710,1695,1694,1693,1692,1636,1626}), //分拣库二 }; foreach (var item in tuples1) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 18; db531 += 250; if (conv.Code == "1662") { var a = 0; } } } var tuples21 = new List>> { //机械臂 new("10.30.37.234",new List(){ 1696, 1691}), //库二北 new("10.30.37.236",new List(){ 1711, 1706}), //库二南 }; foreach (var item in tuples21) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 8; db531 += 130; } } #endregion 初始化桁架相关信息 #region 初始化机械臂相关信息 List TrussInfo1 = new List { new( 3, "10.30.37.234"), new( 4, "10.30.37.236"), }; foreach (var item in TrussInfo1) { var conv = new Device($"Robot{item.Code}"); conv.AddFlag(DeviceFlags.Robot); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 522, item.Ip); } #endregion 初始化机械臂相关信息 #region 初始化堆垛机相关信息 int ip = 57; for (int i = 2; i <= 3; i++) { var srm = new Device($"SRM{i + 1}"); srm.AddFlag(DeviceFlags.堆垛机); ip = i == 2 ? ip : ip + 8; //三台堆垛机IP主机位分别是 41、49、57、65、73、81 srm.AddProtocol(0, 520, $"10.30.37.{ip}"); srm.AddProtocol(0, 521, $"10.30.37.{ip}"); srm.AddProtocol(0, 537, $"10.30.37.{ip}"); //增加巷道 var tunnel = new Device($"TY{i + 1}"); tunnel.AddFlag(DeviceFlags.巷道); } #endregion 初始化堆垛机相关信息 #region 配置路径信息 List routeInfos = new List(); routeInfos.AddRange(new List() { #region 出库 #region 堆垛机--巷道 new RouteInfo("SRM3", new string[] { "TY3" }), new RouteInfo("SRM4", new string[] { "TY4" }), #endregion 堆垛机--巷道 #region 巷道--一楼堆垛机放货口 new RouteInfo("TY3", new string[] { "2932","2934","2933" }), //人工取货口 new RouteInfo("TY4", new string[] { "3132","3134","3133" }), #endregion 巷道--一楼堆垛机放货口 #region 巷道--二楼堆垛机放货口 new RouteInfo("TY3", new string[] { "1621","1625" }), new RouteInfo("TY4", new string[] { "1631","1635" }), #endregion 巷道--二楼堆垛机放货口 #region 二楼堆垛机放货口--二楼拆盘机 //库二 new RouteInfo("1621", new string[] { "1622" }),//非09拆盘机 new RouteInfo("1631", new string[] { "1632"}), new RouteInfo("1625", new string[] { "1626" }),//09拆盘机 new RouteInfo("1635", new string[] { "1636" }), #endregion 二楼堆垛机放货口--二楼拆盘机 #region 二楼拆盘机--RGV //库二 new RouteInfo("1622", new string[] { "RGV3" }),//非09拆盘机 new RouteInfo("1632", new string[] { "RGV4"}), new RouteInfo("1626", new string[] { "RGV3" }),//09拆盘机 new RouteInfo("1636", new string[] { "RGV4" }), #endregion 二楼拆盘机--RGV #region RGV--码垛区域 //库二 new RouteInfo("RGV3", new string[] { "1691","1696" }),//北区机械臂码垛区 new RouteInfo("RGV3", new string[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705"}),//桁架北区码垛站台 new RouteInfo("RGV4", new string[] { "1706","1711" }), new RouteInfo("RGV4", new string[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), #endregion RGV--码垛区域 #region Robot--码垛工位 //库二 new RouteInfo("Robot3", new string[] { "1691" }), new RouteInfo("Robot3", new string[] { "1696" }), new RouteInfo("Robot4", new string[] { "1706" }), new RouteInfo("Robot4", new string[] { "1711" }), #endregion Robot--码垛工位 #endregion 出库 #region 入库 #region 一楼人工入库口-巷道 new RouteInfo("2932", new string[] { "TY3" }), //分拣库二 new RouteInfo("3132", new string[] { "TY4" }), #endregion 一楼人工入库口-巷道 #region 一楼叠盘机(堆垛机入口)--巷道 new RouteInfo("2927", new string[] { "TY3" }), //分拣库二 new RouteInfo("2928", new string[] { "TY3" }), new RouteInfo("3127", new string[] { "TY4" }), new RouteInfo("3128", new string[] { "TY4" }), #endregion 一楼叠盘机(堆垛机入口)--巷道 #region 环形库分流点--环形库取货点 new RouteInfo("818", new string[] { "824","833","842" }), new RouteInfo("1018", new string[] { "1024","1033","1042" }), #endregion 环形库分流点--环形库取货点 #region 环形库分流点--桁架分流点 new RouteInfo("818", new string[] { "855" }), //分拣库二北 new RouteInfo("1018", new string[] { "1055" }), //分拣库二南 #endregion 环形库分流点--桁架分流点 #region 桁架分流点--桁架缓存放行点 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"}), //分拣库二南 #endregion 桁架分流点--桁架缓存放行点 #region 桁架缓存放行点--桁架取货点 new("866", new[] { "861" }), //分拣二北侧 new("880", new[] { "875" }), new("894", new[] { "889" }), new("908", new[] { "903" }), new("922", new[] { "917" }), new("936", new[] { "931" }), new("950", new[] { "945" }), new("964", new[] { "959" }), new("978", new[] { "973" }), new("991", new[] { "986" }), new("1066", new[] { "1061" }),//分拣二南侧 new("1080", new[] { "1075" }), new("1094", new[] { "1089" }), new("1108", new[] { "1103" }), new("1122", new[] { "1117" }), new("1136", new[] { "1131" }), new("1150", new[] { "1145" }), new("1164", new[] { "1159" }), new("1178", new[] { "1173" }), new("1191", new[] { "1186" }), #endregion 桁架缓存放行点--桁架取货点 #region 桁架取货点--桁架 new("861", new[] { "Truss2" }), //分拣二北侧 new("875", new[] { "Truss2" }), new("889", new[] { "Truss2" }), new("903", new[] { "Truss2" }), new("917", new[] { "Truss2" }), new("931", new[] { "Truss2" }), new("945", new[] { "Truss2" }), new("959", new[] { "Truss2" }), new("973", new[] { "Truss2" }), new("986", new[] { "Truss2" }), new("1061", new[] { "Truss2" }),//分拣二南侧 new("1075", new[] { "Truss2" }), new("1089", new[] { "Truss2" }), new("1103", new[] { "Truss2" }), new("1117", new[] { "Truss2" }), new("1131", new[] { "Truss2" }), new("1145", new[] { "Truss2" }), new("1159", new[] { "Truss2" }), new("1173", new[] { "Truss2" }), new("1186", new[] { "Truss2" }), #endregion 桁架取货点--桁架 #region 桁架取货点--码垛工位 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" }), new("903", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("917", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("931", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("945", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("959", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("973", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("986", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), new("1061", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),//分拣二南侧 new("1075", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1089", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1103", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1117", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1131", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1145", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1159", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1173", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), new("1186", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), #endregion 桁架取货点--码垛工位 #region 桁架--码垛工位 new("Truss2", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705","1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }), #endregion 桁架--码垛工位 #region 码垛工位--RGV //分拣库二北 new RouteInfo("1691", new string[] { "RGV3" }),//机械手码垛工位 new RouteInfo("1696", new string[] { "RGV3" }), new RouteInfo("1692", new string[] { "RGV3" }),//绗架码垛工位 new RouteInfo("1693", new string[] { "RGV3" }), new RouteInfo("1694", new string[] { "RGV3" }), new RouteInfo("1695", new string[] { "RGV3" }), new RouteInfo("1700", new string[] { "RGV3" }), new RouteInfo("1701", new string[] { "RGV3" }), new RouteInfo("1702", new string[] { "RGV3" }), new RouteInfo("1703", new string[] { "RGV3" }), new RouteInfo("1704", new string[] { "RGV3" }), new RouteInfo("1705", new string[] { "RGV3" }), //分拣库二南 new RouteInfo("1706", new string[] { "RGV4" }),//机械手码垛工位 new RouteInfo("1711", new string[] { "RGV4" }), new RouteInfo("1707", new string[] { "RGV4" }),//绗架码垛工位 new RouteInfo("1708", new string[] { "RGV4" }), new RouteInfo("1709", new string[] { "RGV4" }), new RouteInfo("1710", new string[] { "RGV4" }), new RouteInfo("1715", new string[] { "RGV4" }), new RouteInfo("1716", new string[] { "RGV4" }), new RouteInfo("1717", new string[] { "RGV4" }), new RouteInfo("1718", new string[] { "RGV4" }), new RouteInfo("1719", new string[] { "RGV4" }), new RouteInfo("1720", new string[] { "RGV4" }), #endregion 码垛工位--RGV #region RGV--RGV放货点 new RouteInfo("RGV3", new string[] { "1624" }), new RouteInfo("RGV4", new string[] { "1634" }), #endregion RGV--RGV放货点 #region RGV放货点--堆垛机取货口 new RouteInfo("1624", new string[] { "1623" }),//北侧 new RouteInfo("1634", new string[] { "1633" }),//南侧 #endregion RGV放货点--堆垛机取货口 #region 二楼堆垛机入库--巷道 new RouteInfo("1623", new string[] { "TY3" }),//北侧 new RouteInfo("1633", new string[] { "TY4" }),//南侧 #endregion 二楼堆垛机入库--巷道 #region 巷道--堆垛机 new RouteInfo("TY3", new string[] { "SRM3" }), new RouteInfo("TY4", new string[] { "SRM4" }), #endregion 巷道--堆垛机 #region 线体取货位--Robot new RouteInfo("824", new string[] { "Robot3" }), new RouteInfo("833", new string[] { "Robot3" }), new RouteInfo("842", new string[] { "Robot3" }), new RouteInfo("1024", new string[] { "Robot4" }), new RouteInfo("1033", new string[] { "Robot4" }), new RouteInfo("1042", new string[] { "Robot4" }), #endregion 线体取货位--Robot #endregion 入库 }); foreach (var routeInfo in routeInfos) { if (routeInfo != null) { var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode); device.AddTarget(routeInfo.NextList); Parallel.ForEach(routeInfo.NextList, next => { var dev = Device.All.FirstOrDefault(x => x.Code == next); dev.Parent = device; }); } } #endregion 配置路径信息 #region 添加设备组 var tuples2 = new List>>() { //环形库二北侧机械手取货位 new("824",new List {"824","825"}), new("833",new List {"833","834"}), new("842",new List {"842","843"}), //环形库二南侧侧机械手取货位 new("1042",new List {"1042","1043"}), new("1033",new List {"1033","1034"}), new("1024",new List {"1024","1025"}), }; Parallel.ForEach(tuples2, tuple => { var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1); device.AddDeviceGroup(tuple.Item2.ToArray()); }); #endregion 添加设备组 } if (WareHouses.Contains("FJ3")) { #region 初始化RGV相关信息 List RgvInfo = new List { new RgvSegmentInfo( 5, "10.30.37.133"), //库三北 new RgvSegmentInfo( 6, "10.30.37.138"), //库三南 }; foreach (var item in RgvInfo) { var conv = new Device($"RGV{item.Code}"); conv.AddFlag(DeviceFlags.RGV); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); //conv.AddProtocol(, 523, item.IP); } #endregion 初始化RGV相关信息 #region 初始化输送机相关信息 #region 基本信息 #region 托盘线输送线 var tuples = new List>>> { //分拣库三 new("10.30.37.105",new List>() { new(1641, 1660), new(3301, 3340), new(3501, 3540), new(1721, 1750) }) }; foreach (var item in tuples) { var db520 = 0; var db521 = 0; var db523 = 0; foreach (var item1 in item.Item2) { for (var i = item1.Item1; i <= item1.Item2; i++) { var conv = new Device(i.ToString()); conv.AddFlag(DeviceFlags.输送机); conv.AddProtocol(db520, 520, item.Item1); conv.AddProtocol(db521, 521, item.Item1); conv.AddProtocol(db523, 523, item.Item1); db520 += 14; db521 += 16; db523 += 12; } } } #endregion 托盘线输送线 #endregion 基本信息 #region 托盘线扫码器 var bcrInfo = new List { new(new [] { "3332", "3532" }, "10.30.37.105"), new(new [] {"RGV5"},"10.30.37.133"), new(new [] {"RGV6"},"10.30.37.138") }; foreach (var item in bcrInfo) { for (var i = 0; i < item.DeviceNo.Length; i++) { var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]); device.AddFlag(DeviceFlags.扫码); var pos = i * 130; device.AddProtocol(pos, 81, item.Ip); } } #endregion 托盘线扫码器 #region 外检信息 // List shapeInfo = new List //{ // new ShapeInfo(new int[] { 3332,3532 }, "10.30.37.105") //}; //foreach (var item in shapeInfo) //{ // for (int i = 0; i < item.DeviceNo.Length; i++) // { // var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString()); // conv.AddFlag(DeviceFlags.外检); // int pos = i * 14; // conv.AddProtocol(pos, 91, item.Ip); // } //} var conv1 = Device.All.FirstOrDefault(x => x.Code == "3332"); conv1.AddFlag(DeviceFlags.外检); conv1.AddProtocol(714, 91, "10.30.37.105"); var conv2 = Device.All.FirstOrDefault(x => x.Code == "3532"); conv2.AddFlag(DeviceFlags.外检); conv2.AddProtocol(1274, 91, "10.30.37.105"); #endregion 外检信息 #endregion 初始化输送机相关信息 #region 初始化桁架相关信息 List TrussInfo = new List { new TrussSegmentInfo( 3, "10.30.37.223") }; foreach (var item in TrussInfo) { var conv = new Device($"Truss{item.Code}"); conv.AddFlag(DeviceFlags.桁架); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 523, item.Ip); } var tuples1 = new List>> { //桁架 new("10.30.37.223",new List(){1745,1746,1747,1748,1749,1750,1735,1734,1733,1732,1731,1730,1737,1738,1739,1740,1725,1724,1723,1722,1656,1646}), //分拣库三 }; foreach (var item in tuples1) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 18; db531 += 250; if (conv.Code == "1662") { var a = 0; } } } var tuples21 = new List>> { //机械臂 new("10.30.37.238",new List(){ 1726, 1721}), //库三北 new("10.30.37.240",new List(){ 1741, 1736}), //库三南 }; foreach (var item in tuples21) { var db530 = 0; var db531 = 0; foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString()))) { conv!.AddProtocol(db530, 530, item.Item1); conv!.AddProtocol(db531, 531, item.Item1); db530 += 8; db531 += 130; } } #endregion 初始化桁架相关信息 #region 初始化机械臂相关信息 List TrussInfo1 = new List { new( 5, "10.30.37.238"), new( 6, "10.30.37.240"), }; foreach (var item in TrussInfo1) { var conv = new Device($"Robot{item.Code}"); conv.AddFlag(DeviceFlags.Robot); conv.AddProtocol(0, 520, item.Ip); conv.AddProtocol(0, 521, item.Ip); conv.AddProtocol(0, 522, item.Ip); } #endregion 初始化机械臂相关信息 #region 初始化堆垛机相关信息 int ip = 73; for (int i = 4; i <= 5; i++) { var srm = new Device($"SRM{i + 1}"); srm.AddFlag(DeviceFlags.堆垛机); ip = i == 4 ? ip : ip + 8; //三台堆垛机IP主机位分别是 41、49、57、65、73、81 srm.AddProtocol(0, 520, $"10.30.37.{ip}"); srm.AddProtocol(0, 521, $"10.30.37.{ip}"); srm.AddProtocol(0, 537, $"10.30.37.{ip}"); //增加巷道 var tunnel = new Device($"TY{i + 1}"); tunnel.AddFlag(DeviceFlags.巷道); } #endregion 初始化堆垛机相关信息 #region 配置路径信息 List routeInfos = new List(); routeInfos.AddRange(new List() { #region 出库 #region 堆垛机--巷道 new RouteInfo("SRM5", new string[] { "TY5" }), new RouteInfo("SRM6", new string[] { "TY6" }), #endregion 堆垛机--巷道 #region 巷道--一楼堆垛机放货口 new RouteInfo("TY5", new string[] { "3332","3334","3333" }), //人工取货口 new RouteInfo("TY6", new string[]{ "3532","3534","3533" }), #endregion 巷道--一楼堆垛机放货口 #region 巷道--二楼堆垛机放货口 new RouteInfo("TY5", new string[] { "1641","1645" }), new RouteInfo("TY6", new string[] { "1651","1655" }), #endregion 巷道--二楼堆垛机放货口 #region 二楼堆垛机放货口--二楼拆盘机 //库三 new RouteInfo("1641", new string[] { "1642" }),//非09拆盘机 new RouteInfo("1651", new string[] { "1652"}), new RouteInfo("1645", new string[] { "1646" }),//09拆盘机 new RouteInfo("1655", new string[] { "1656" }), #endregion 二楼堆垛机放货口--二楼拆盘机 #region 二楼拆盘机--RGV //库三 new RouteInfo("1642", new string[] { "RGV5" }),//非09拆盘机 new RouteInfo("1652", new string[] { "RGV6"}), new RouteInfo("1646", new string[] { "RGV5" }),//09拆盘机 new RouteInfo("1656", new string[] { "RGV6" }), #endregion 二楼拆盘机--RGV #region RGV--码垛区域 //库三 new RouteInfo("RGV5", new string[] { "1721","1726" }),//北区机械臂码垛区 new RouteInfo("RGV5", new string[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735"}),//桁架北区码垛站台 new RouteInfo("RGV6", new string[] { "1736","1741" }), new RouteInfo("RGV6", new string[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), #endregion RGV--码垛区域 #region Robot--码垛工位 //库三 new RouteInfo("Robot5", new string[] { "1721" }), new RouteInfo("Robot5", new string[] { "1726" }), new RouteInfo("Robot6", new string[] { "1736" }), new RouteInfo("Robot6", new string[] { "1741" }), #endregion Robot--码垛工位 #endregion 出库 #region 入库 #region 一楼人工入库口-巷道 new RouteInfo("3332", new string[] { "TY5" }), //分拣库三 new RouteInfo("3532", new string[] { "TY6" }), #endregion 一楼人工入库口-巷道 #region 一楼叠盘机(堆垛机入口)--巷道 new RouteInfo("3327", new string[] { "TY5" }), //分拣库三 new RouteInfo("3328", new string[] { "TY5" }), new RouteInfo("3527", new string[] { "TY6" }), new RouteInfo("3528", new string[] { "TY6" }), #endregion 一楼叠盘机(堆垛机入口)--巷道 #region 环形库分流点--环形库取货点 new RouteInfo("1218", new string[] { "1224","1233","1242" }), new RouteInfo("1418", new string[] { "1424","1433","1442" }), #endregion 环形库分流点--环形库取货点 #region 环形库分流点--桁架分流点 new RouteInfo("1218", new string[] { "1255" }), //分拣库三北 new RouteInfo("1418", new string[] { "1455" }), //分拣库三南 #endregion 环形库分流点--桁架分流点 #region 桁架分流点--桁架缓存放行点 new RouteInfo("1255", new string[] { "1266","1280","1294","1308", "1322","1336","1350","1364","1378", "1391"}), //分拣库三北 new RouteInfo("1455", new string[] { "1466","1480","1494","1508", "1522","1536","1550","1564","1578","1591"}), //分拣库三南 #endregion 桁架分流点--桁架缓存放行点 #region 桁架缓存放行点--桁架取货点 new("1266", new[] { "1261" }), //分拣三北侧 new("1280", new[] { "1275" }), new("1294", new[] { "1289" }), new("1308", new[] { "1303" }), new("1322", new[] { "1317" }), new("1336", new[] { "1331" }), new("1350", new[] { "1345" }), new("1364", new[] { "1359" }), new("1378", new[] { "1373" }), new("1391", new[] { "1386" }), new("1466", new[] { "1461" }),//分拣三南侧 new("1480", new[] { "1475" }), new("1494", new[] { "1489" }), new("1508", new[] { "1503" }), new("1522", new[] { "1517" }), new("1536", new[] { "1531" }), new("1550", new[] { "1545" }), new("1564", new[] { "1559" }), new("1578", new[] { "1573" }), new("1591", new[] { "1586" }), #endregion 桁架缓存放行点--桁架取货点 #region 桁架取货点--桁架 new("1261", new[] { "Truss3" }), //分拣三北侧 new("1275", new[] { "Truss3" }), new("1289", new[] { "Truss3" }), new("1303", new[] { "Truss3" }), new("1317", new[] { "Truss3" }), new("1331", new[] { "Truss3" }), new("1345", new[] { "Truss3" }), new("1359", new[] { "Truss3" }), new("1373", new[] { "Truss3" }), new("1386", new[] { "Truss3" }), new("1461", new[] { "Truss3" }),//分拣三南侧 new("1475", new[] { "Truss3" }), new("1489", new[] { "Truss3" }), new("1503", new[] { "Truss3" }), new("1517", new[] { "Truss3" }), new("1531", new[] { "Truss3" }), new("1545", new[] { "Truss3" }), new("1559", new[] { "Truss3" }), new("1573", new[] { "Truss3" }), new("1586", new[] { "Truss3" }), #endregion 桁架取货点--桁架 #region 桁架取货点--码垛工位 new("1261", new[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), //分拣三北侧 new("1275", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1289", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1303", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1317", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1331", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1345", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1359", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1373", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1386", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), new("1461", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),//分拣三南侧 new("1475", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1489", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1503", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1517", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1531", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1545", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1559", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1573", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), new("1586", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }), #endregion 桁架取货点--码垛工位 #region 桁架--码垛工位 new("Truss3", new[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735","1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750"}), #endregion 桁架--码垛工位 #region 码垛工位--RGV //分拣库三北 new RouteInfo("1721", new string[] { "RGV5" }),//机械手码垛工位 new RouteInfo("1726", new string[] { "RGV5" }), new RouteInfo("1722", new string[] { "RGV5" }),//绗架码垛工位 new RouteInfo("1723", new string[] { "RGV5" }), new RouteInfo("1724", new string[] { "RGV5" }), new RouteInfo("1725", new string[] { "RGV5" }), new RouteInfo("1730", new string[] { "RGV5" }), new RouteInfo("1731", new string[] { "RGV5" }), new RouteInfo("1732", new string[] { "RGV5" }), new RouteInfo("1733", new string[] { "RGV5" }), new RouteInfo("1734", new string[] { "RGV5" }), new RouteInfo("1735", new string[] { "RGV5" }), //分拣库三南 new RouteInfo("1736", new string[] { "RGV6" }),//机械手码垛工位 new RouteInfo("1741", new string[] { "RGV6" }), new RouteInfo("1737", new string[] { "RGV6" }),//绗架码垛工位 new RouteInfo("1738", new string[] { "RGV6" }), new RouteInfo("1739", new string[] { "RGV6" }), new RouteInfo("1740", new string[] { "RGV6" }), new RouteInfo("1745", new string[] { "RGV6" }), new RouteInfo("1746", new string[] { "RGV6" }), new RouteInfo("1747", new string[] { "RGV6" }), new RouteInfo("1748", new string[] { "RGV6" }), new RouteInfo("1749", new string[] { "RGV6" }), new RouteInfo("1750", new string[] { "RGV6" }), #endregion 码垛工位--RGV #region RGV--RGV放货点 new RouteInfo("RGV5", new string[] { "1644" }), new RouteInfo("RGV6", new string[] { "1654" }), #endregion RGV--RGV放货点 #region RGV放货点--堆垛机取货口 new RouteInfo("1644", new string[] { "1643" }),//北侧 new RouteInfo("1654", new string[] { "1653" }),//南侧 #endregion RGV放货点--堆垛机取货口 #region 二楼堆垛机入库--巷道 new RouteInfo("1643", new string[] { "TY5" }),//北侧 new RouteInfo("1653", new string[] { "TY6" }),//南侧 #endregion 二楼堆垛机入库--巷道 #region 巷道--堆垛机 new RouteInfo("TY5", new string[] { "SRM5" }), new RouteInfo("TY6", new string[] { "SRM6" }), #endregion 巷道--堆垛机 #region 线体取货位--Robot new RouteInfo("1224", new string[] { "Robot5" }), new RouteInfo("1233", new string[] { "Robot5" }), new RouteInfo("1242", new string[] { "Robot5" }), new RouteInfo("1424", new string[] { "Robot6" }), new RouteInfo("1433", new string[] { "Robot6" }), new RouteInfo("1442", new string[] { "Robot6" }) #endregion 线体取货位--Robot #endregion 入库 }); foreach (var routeInfo in routeInfos) { if (routeInfo != null) { var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode); device.AddTarget(routeInfo.NextList); Parallel.ForEach(routeInfo.NextList, next => { var dev = Device.All.FirstOrDefault(x => x.Code == next); dev.Parent = device; }); } } //Parallel.ForEach(routeInfos, routeInfo => //{ //}); #endregion 配置路径信息 #region 添加设备组 var tuples2 = new List>>() { ////环形库三北侧机械手取货位 new("1224",new List {"1224","1225"}), new("1233",new List {"1233","1234"}), new("1242",new List {"1242","1243"}), ////环形库三南侧侧机械手取货位 new("1442",new List {"1442","1443"}), new("1433",new List {"1433","1434"}), new("1424",new List {"1424","1425"}), }; Parallel.ForEach(tuples2, tuple => { var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1); device.AddDeviceGroup(tuple.Item2.ToArray()); }); #endregion 添加设备组 } #region 标签配置 Dictionary> devices = new Dictionary>(); if (WareHouses.Contains("FJ1")) { devices = new Dictionary> { { DeviceFlags.一楼叠盘机,new List() { "2527", "2528", "2727", "2728" } }, { DeviceFlags.环形库分流点,new List() { "418", "618" } }, { DeviceFlags.桁架分流点,new List() { "455", "655" } }, { DeviceFlags.桁架缓存放行点, new List(){ "466", "480", "494", "508", "522", "536", "550", "564", "578", "591", "666", "680", "694", "708", "722", "736", "750", "764", "778", "791",} }, { DeviceFlags.桁架09缓存放行点, new List(){ "666", "680", "694", "708", "722", "736", "466", "480", "494", "508", "522", "536" } }, { DeviceFlags.桁架09异常缓存放行点, new List(){ "591", "791" } }, { DeviceFlags.桁架18缓存放行点, new List(){ "550", "564", "578", "750", "764", "778" } }, { DeviceFlags.桁架取货点, new List(){ "461", "475", "489", "503", "517", "531", "545", "559", "573", "586", "661", "675", "689", "703", "717", "731", "745", "759", "773", "786"} }, { DeviceFlags.桁架18取货点, new List(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } }, { DeviceFlags.拆盘机, new List(){ "1602", "1612" } }, { DeviceFlags.桁架码垛位, new List(){ "1670","1671","1672","1673","1674","1675","1664","1662","1663","1665","1677","1678","1679","1680","1685","1686","1687","1688","1689","1690","1606","1616"} }, { DeviceFlags.环形库码垛工位, new List(){ "1666", "1661", "1676", "1681" } }, { DeviceFlags.AGV取货站台口, new List(){ "2533", "2534", "2734", "2733"} }, { DeviceFlags.Robot, new List(){ "Robot1", "Robot2" } }, {DeviceFlags.二次码垛RGV取货口, new List(){ "1606", "1616"}} }; Parallel.ForEach(devices, device => { Parallel.ForEach(device.Value, value => { var dev = Device.All.FirstOrDefault(v => v.Code == value); if (dev != null) { dev.AddFlag(device.Key); } }); }); } if (WareHouses.Contains("FJ2")) { devices = new Dictionary> { { DeviceFlags.一楼叠盘机,new List() { "2927", "2928", "3127", "3128", } }, { DeviceFlags.环形库分流点,new List() { "818", "1018" } }, { DeviceFlags.桁架分流点,new List() { "855", "1055" } }, { DeviceFlags.桁架缓存放行点, new List(){ "866", "880", "894", "908", "922", "936", "950", "964", "978", "991", "1066", "1080", "1094", "1108", "1122", "1136", "1150", "1164", "1178", "1191",} }, { DeviceFlags.桁架09缓存放行点, new List(){ "866", "880", "894", "908", "922", "936", "1066", "1080", "1094", "1108", "1122", "1136"} }, { DeviceFlags.桁架09异常缓存放行点, new List(){ "991" , "1191" } }, { DeviceFlags.桁架18缓存放行点, new List(){ "950", "964", "978" , "1150", "1164", "1178"} }, { DeviceFlags.桁架取货点, new List(){ "861", "875", "889", "903", "917", "931", "945", "959", "973", "986", "1061", "1075", "1089", "1103", "1117", "1131", "1145", "1159", "1173", "1186"} }, { DeviceFlags.桁架18取货点, new List(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } }, { DeviceFlags.拆盘机, new List(){ "1622", "1632" } }, { DeviceFlags.桁架码垛位, new List(){"1692","1693","1694","1695","1700","1701","1702","1703","1704","1705","1707","1708","1709","1710","1715","1716","1717","1718","1719","1720","1626","1636" } }, { DeviceFlags.环形库码垛工位, new List(){"1691", "1696", "1706", "1711" } }, { DeviceFlags.AGV取货站台口, new List(){"2934","2933","3133", "3134"} }, { DeviceFlags.Robot, new List(){ "Robot3", "Robot4" } }, { DeviceFlags.二次码垛RGV取货口, new List(){ "1626","1636"}} }; Parallel.ForEach(devices, device => { Parallel.ForEach(device.Value, value => { var dev = Device.All.FirstOrDefault(v => v.Code == value); if (dev != null) { dev.AddFlag(device.Key); } }); }); } if (WareHouses.Contains("FJ3")) { devices = new Dictionary> { { DeviceFlags.一楼叠盘机,new List() { "3327", "3328", "3527", "3528" } }, { DeviceFlags.环形库分流点,new List() { "1218", "1418" } }, { DeviceFlags.桁架分流点,new List() { "1255", "1455" } }, { DeviceFlags.桁架缓存放行点, new List(){ "1266", "1280", "1294", "1308", "1322", "1336", "1350", "1364", "1378", "1391", "1466", "1480", "1494", "1508", "1522", "1536", "1550", "1564", "1578", "1591"} }, { DeviceFlags.桁架09缓存放行点, new List(){ "1266", "1280", "1294", "1308", "1322", "1336", "1466", "1480", "1494", "1508", "1522", "1536" } }, { DeviceFlags.桁架09异常缓存放行点, new List(){ "1391" , "1591" } }, { DeviceFlags.桁架18缓存放行点, new List(){ "1350", "1364", "1378", "1550", "1564", "1578" } }, { DeviceFlags.桁架取货点, new List(){"1261", "1275", "1289", "1303", "1317", "1331", "1345", "1359", "1373", "1386" , "1461", "1475", "1489", "1503", "1517", "1531", "1545", "1559", "1573", "1586" } }, { DeviceFlags.桁架18取货点, new List(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } }, { DeviceFlags.拆盘机, new List(){ "1642", "1652" } }, { DeviceFlags.桁架码垛位, new List(){"1722","1723","1724","1725","1730","1731","1732","1733","1734","1735","1737","1738","1739","1740","1745","1746","1747","1748","1749","1750","1646","1656"} }, { DeviceFlags.环形库码垛工位, new List(){"1721", "1726", "1736", "1741" } }, { DeviceFlags.AGV取货站台口, new List(){"3333","3334","3533","3534"} }, { DeviceFlags.Robot, new List(){ "Robot5", "Robot6" } }, {DeviceFlags.二次码垛RGV取货口, new List(){ "1646","1656"}} }; Parallel.ForEach(devices, device => { Parallel.ForEach(device.Value, value => { var dev = Device.All.FirstOrDefault(v => v.Code == value); if (dev != null) { dev.AddFlag(device.Key); } }); }); } #endregion 标签配置 } /// /// 初始化数据库连接 /// /// public static void InitDB(this List datas) { //初始化数据库 SqlSugarHelper.Do(db => { foreach (var connectionString in datas!) { var _db = db.Connect.GetConnectionScope(connectionString.Key); switch (connectionString.Key) { 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)); break; case "WCSDlog"://WCS日志数据库 break; case "PLC"://PLC SqlSugarHelper.SetPLC(connectionString.Key); //_db.DbMaintenance.CreateDatabase(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //_db.CodeFirst.InitTables(); //var a = false; break; default: //其他库 break; }; }; }); } } public class DevDbConfig { public DevDbConfig() { } public DevDbConfig(string ip, T code) { IP = ip; Code = code; } public DevDbConfig(string ip, List> devIntervalList) { IP = ip; DevIntervalList = devIntervalList; } public DevDbConfig(string ip, List 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 DevCodeList { get; set; } public List> DevIntervalList { get; set; } } public class DevInterval { public DevInterval(T s, T e) { StartCode = s; EndCode = e; } public T StartCode { get; set; } public T EndCode { get; set; } } }