WorkStart.cs 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320
  1. using PlcSiemens.Core.Extension;
  2. using ServiceCenter;
  3. using ServiceCenter.SqlSugars;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.Entity.Protocol;
  7. using WCS.Entity.Protocol.BCR;
  8. using WCS.Entity.Protocol.RGV;
  9. using WCS.Entity.Protocol.Robot;
  10. using WCS.Entity.Protocol.SRM;
  11. using WCS.Entity.Protocol.Station;
  12. using WCS.Entity.Protocol.Truss;
  13. using WCS.WorkEngineering.Extensions;
  14. using WCS.WorkEngineering.Systems;
  15. using WCS.WorkEngineering.Systems.桁架码垛;
  16. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  17. namespace WCS.WorkEngineering
  18. {
  19. /// <summary>
  20. /// 业务工程配置信息
  21. /// </summary>
  22. public static class WorkStart
  23. {
  24. /// <summary>
  25. /// 仓库
  26. /// </summary>
  27. public static string? WareHouses { get; set; }
  28. /// <summary>
  29. /// 初始化 设备信息
  30. /// </summary>
  31. public static void InitializeDeviceInfo()
  32. {
  33. if (WareHouses.IsNullOrEmpty())
  34. {
  35. throw new Exception("请配置当前程序所属的分拣中心");
  36. }
  37. #region 无交互触发设备,只在分拣1有
  38. if (WareHouses.Contains("FJ1"))
  39. {
  40. var devs = new List<string>() { nameof(PalletizCreateEmptyTray), "AGVIn", "AGVOut", nameof(NoInteractionSystems), nameof(UpLoadSystems), nameof(TrussCreateTwoOut) };
  41. foreach (var conv in devs.Select(code => new Device(code)))
  42. {
  43. conv.AddProtocol<IStation520>(0, 520, "1");
  44. conv.AddFlag(DeviceFlags.无交互触发设备);
  45. }
  46. }
  47. #endregion 无交互触发设备,只在分拣1有
  48. #region 设置设备IP集合
  49. ServiceHub.DeviceIPList = new List<string>() { };
  50. #endregion 设置设备IP集合
  51. if (WareHouses.Contains("FJ1"))
  52. {
  53. #region 初始化RGV相关信息
  54. List<RgvSegmentInfo> RgvInfo = new List<RgvSegmentInfo>
  55. {
  56. new RgvSegmentInfo( 1, "10.30.37.113"), //库一北
  57. new RgvSegmentInfo( 2, "10.30.37.118"), //库一南
  58. };
  59. foreach (var item in RgvInfo)
  60. {
  61. var conv = new Device($"RGV{item.Code}");
  62. conv.AddFlag(DeviceFlags.RGV);
  63. conv.AddProtocol<IRGV520>(0, 520, item.Ip);
  64. conv.AddProtocol<IRGV521>(0, 521, item.Ip);
  65. //conv.AddProtocol<IStation523>(, 523, item.IP);
  66. }
  67. #endregion 初始化RGV相关信息
  68. #region 初始化输送机相关信息
  69. #region 基本信息
  70. #region 托盘线输送线
  71. var tuples = new List<Tuple<string, List<Tuple<int, int>>>>
  72. {
  73. //分拣库一
  74. new("10.30.37.89",new List<Tuple<int, int>>()
  75. {
  76. new(1601, 1620),
  77. new(2501, 2540),
  78. new(2701, 2740),
  79. new(1661, 1690),
  80. }),
  81. };
  82. foreach (var item in tuples)
  83. {
  84. var db520 = 0;
  85. var db521 = 0;
  86. var db523 = 0;
  87. foreach (var item1 in item.Item2)
  88. {
  89. for (var i = item1.Item1; i <= item1.Item2; i++)
  90. {
  91. var conv = new Device(i.ToString());
  92. conv.AddFlag(DeviceFlags.输送机);
  93. conv.AddProtocol<IStation520>(db520, 520, item.Item1);
  94. conv.AddProtocol<IStation521>(db521, 521, item.Item1);
  95. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  96. db520 += 14;
  97. db521 += 16;
  98. db523 += 12;
  99. }
  100. }
  101. }
  102. #endregion 托盘线输送线
  103. #region 满轮输送线
  104. #region DB523,所有线体都会有DB523
  105. var mLtuples523 = new List<Tuple<string, List<Tuple<int, int>>>>()
  106. {
  107. new("10.30.37.166",new List<Tuple<int, int>>() //北侧满轮主线
  108. {
  109. new(1, 100),
  110. new(9001, 9010),//暂用,无意义
  111. new(401, 599),
  112. new(801,999),
  113. new(1201,1399),
  114. }),
  115. new("10.30.37.198",new List<Tuple<int, int>>() //南侧满轮主线
  116. {
  117. new(101, 210),
  118. new(601, 799),
  119. new(1001, 1199),
  120. new(1401,1599),
  121. new(341,379),
  122. })
  123. };
  124. foreach (var item in mLtuples523)
  125. {
  126. var db523 = 0;
  127. var db524 = 0;
  128. foreach (var item1 in item.Item2)
  129. {
  130. for (var i = item1.Item1; i <= item1.Item2; i++)
  131. {
  132. var conv = new Device(i.ToString());
  133. conv.AddFlag(DeviceFlags.输送机);
  134. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  135. conv.AddProtocol<IStation524>(db524, 524, item.Item1);
  136. db523 += 12;
  137. db524 += 16;
  138. }
  139. }
  140. }
  141. #endregion DB523,所有线体都会有DB523
  142. #region 520、521 交互线体会有520、521
  143. //Item2表示线体号集合,Item1表示IP
  144. var mLTuples520 = new List<Tuple<string, List<int>>>()
  145. {
  146. //北侧
  147. 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}),
  148. //南侧
  149. 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})
  150. };
  151. foreach (var item in mLTuples520)
  152. {
  153. var db520 = 0;
  154. var db521 = 0;
  155. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  156. {
  157. if (device != null)
  158. {
  159. device.AddProtocol<IStation520>(db520, 520, item.Item1);
  160. device.AddProtocol<IStation521>(db521, 521, item.Item1);
  161. }
  162. db520 += 14;
  163. db521 += 16;
  164. }
  165. }
  166. #endregion 520、521 交互线体会有520、521
  167. #region 满轮扫码器
  168. //Item2表示线体号集合,Item1表示IP
  169. var mLTuples83 = new List<Tuple<string, List<int>>>()
  170. {
  171. new("10.30.37.166",new List<int>(){3,14,18,22,38,323,41,58,61}) ,
  172. new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
  173. };
  174. foreach (var item in mLTuples83)
  175. {
  176. var db83 = 0;
  177. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  178. {
  179. device?.AddProtocol<IBCR83>(db83, 83, item.Item1);
  180. db83 += 604;
  181. }
  182. }
  183. #endregion 满轮扫码器
  184. #region 满轮线告诉分拣预分配
  185. //Item2表示线体号集合,Item1表示IP
  186. var mLTuples525 = new List<Tuple<string, List<int>>>()
  187. {
  188. new("10.30.37.166",new List<int>(){18,38,58}),
  189. new("10.30.37.198",new List<int>(){118,138,158}),
  190. };
  191. foreach (var item in mLTuples525)
  192. {
  193. var db525 = 0;
  194. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  195. {
  196. device?.AddProtocol<IStation525>(db525, 525, item.Item1);
  197. db525 += 3266;
  198. }
  199. }
  200. #endregion 满轮线告诉分拣预分配
  201. #region 外检信息
  202. //Item2表示线体号集合,Item1表示IP
  203. var mLTuples91 = new List<Tuple<string, List<int>>>()
  204. {
  205. new("10.30.37.166",new List<int>(){418,818,1218}),
  206. new("10.30.37.198",new List<int>(){618,1018,1418})
  207. };
  208. foreach (var item in mLTuples91)
  209. {
  210. var db91 = 0;
  211. foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString())))
  212. {
  213. device?.AddProtocol<IStation91>(db91, 91, item.Item1);
  214. db91 += 14;
  215. }
  216. }
  217. #endregion 外检信息
  218. #endregion 满轮输送线
  219. #endregion 基本信息
  220. #region 托盘线扫码器
  221. var bcrInfo = new List<BcrInfo>
  222. {
  223. new(new [] { "2532", "2732" }, "10.30.37.89"),
  224. new(new [] {"RGV1"},"10.30.37.113"),
  225. new(new [] {"RGV2"},"10.30.37.118"),
  226. };
  227. foreach (var item in bcrInfo)
  228. {
  229. for (var i = 0; i < item.DeviceNo.Length; i++)
  230. {
  231. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]);
  232. device.AddFlag(DeviceFlags.扫码);
  233. var pos = i * 130;
  234. device.AddProtocol<IBCR81>(pos, 81, item.Ip);
  235. }
  236. }
  237. #endregion 托盘线扫码器
  238. #region 外检信息
  239. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  240. {
  241. new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.89"),
  242. };
  243. foreach (var item in shapeInfo)
  244. {
  245. for (int i = 0; i < item.DeviceNo.Length; i++)
  246. {
  247. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  248. conv.AddFlag(DeviceFlags.外检);
  249. int pos = i * 14;
  250. conv.AddProtocol<IStation91>(pos, 91, item.Ip);
  251. }
  252. }
  253. #endregion 外检信息
  254. #endregion 初始化输送机相关信息
  255. #region 初始化桁架相关信息
  256. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  257. {
  258. new TrussSegmentInfo( 1, "10.30.37.211"),
  259. };
  260. foreach (var item in TrussInfo)
  261. {
  262. var conv = new Device($"Truss{item.Code}");
  263. conv.AddFlag(DeviceFlags.桁架);
  264. conv.AddProtocol<ITruss520>(0, 520, item.Ip);
  265. conv.AddProtocol<ITruss521>(0, 521, item.Ip);
  266. conv.AddProtocol<ITruss523>(0, 523, item.Ip);
  267. }
  268. var tuples1 = new List<Tuple<string, List<int>>>
  269. {
  270. //桁架
  271. new("10.30.37.211",new List<int>(){1685,1686,1687,1688,1689,1690,1675,1674,1673,1672,1671,1670,1677,1678,1679,1680,1665,1664,1663,1662,1616,1606}), //分拣库一
  272. };
  273. foreach (var item in tuples1)
  274. {
  275. var db530 = 0;
  276. var db531 = 0;
  277. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  278. {
  279. conv!.AddProtocol<ITruss530>(db530, 530, item.Item1);
  280. conv!.AddProtocol<ITruss531>(db531, 531, item.Item1);
  281. db530 += 18;
  282. db531 += 250;
  283. }
  284. }
  285. var tuples21 = new List<Tuple<string, List<int>>>
  286. {
  287. //机械臂
  288. new("10.30.37.230",new List<int>(){ 1666, 1661}), //库一北
  289. new("10.30.37.232",new List<int>(){ 1681, 1676}), //库一南
  290. };
  291. foreach (var item in tuples21)
  292. {
  293. var db530 = 0;
  294. var db531 = 0;
  295. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  296. {
  297. conv!.AddProtocol<IRobot530>(db530, 530, item.Item1);
  298. conv!.AddProtocol<IRobot531>(db531, 531, item.Item1);
  299. db530 += 8;
  300. db531 += 130;
  301. }
  302. }
  303. #endregion 初始化桁架相关信息
  304. #region 初始化机械臂相关信息
  305. List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
  306. {
  307. new( 1, "10.30.37.230"),
  308. new( 2, "10.30.37.232"),
  309. };
  310. foreach (var item in TrussInfo1)
  311. {
  312. var conv = new Device($"Robot{item.Code}");
  313. conv.AddFlag(DeviceFlags.Robot);
  314. conv.AddProtocol<IRobot520>(0, 520, item.Ip);
  315. conv.AddProtocol<IRobot521>(0, 521, item.Ip);
  316. conv.AddProtocol<IRobot522>(0, 522, item.Ip);
  317. }
  318. #endregion 初始化机械臂相关信息
  319. #region 初始化堆垛机相关信息
  320. int ip = 41;
  321. for (int i = 0; i <= 1; i++)
  322. {
  323. var srm = new Device($"SRM{i + 1}");
  324. srm.AddFlag(DeviceFlags.堆垛机);
  325. ip = i == 0 ? ip : ip + 8;
  326. //三台堆垛机IP主机位分别是 41、49、57、65、73、81
  327. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  328. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  329. srm.AddProtocol<ISRM523>(0, 537, $"10.30.37.{ip}");
  330. //增加巷道
  331. var tunnel = new Device($"TY{i + 1}");
  332. tunnel.AddFlag(DeviceFlags.巷道);
  333. }
  334. #endregion 初始化堆垛机相关信息
  335. #region 配置路径信息
  336. List<RouteInfo> routeInfos = new List<RouteInfo>();
  337. routeInfos.AddRange(new List<RouteInfo>() {
  338. #region 出库
  339. #region 堆垛机--巷道
  340. new RouteInfo("SRM1", new string[] { "TY1" }),
  341. new RouteInfo("SRM2", new string[] { "TY2" }),
  342. #endregion 堆垛机--巷道
  343. #region 巷道--一楼堆垛机放货口
  344. new RouteInfo("TY1", new string[] { "2532","2534","2533" }), //人工取货口
  345. new RouteInfo("TY2", new string[] { "2732","2734","2733" }),
  346. #endregion 巷道--一楼堆垛机放货口
  347. #region 巷道--二楼堆垛机放货口
  348. new RouteInfo("TY1", new string[] { "1601","1605" }),
  349. new RouteInfo("TY2", new string[] { "1611","1615" }),
  350. #endregion 巷道--二楼堆垛机放货口
  351. #region 二楼堆垛机放货口--二楼拆盘机
  352. //库一
  353. new RouteInfo("1601", new string[] { "1602" }),//非09拆盘机
  354. new RouteInfo("1611", new string[] { "1612"}),
  355. new RouteInfo("1605", new string[] { "1606" }),//09拆盘机
  356. new RouteInfo("1615", new string[] { "1616" }),
  357. #endregion 二楼堆垛机放货口--二楼拆盘机
  358. #region 二楼拆盘机--RGV
  359. //库一
  360. new RouteInfo("1602", new string[] { "RGV1" }),//非09拆盘机
  361. new RouteInfo("1612", new string[] { "RGV2"}),
  362. new RouteInfo("1606", new string[] { "RGV1" }),//09拆盘机
  363. new RouteInfo("1616", new string[] { "RGV2" }),
  364. #endregion 二楼拆盘机--RGV
  365. #region RGV--码垛区域
  366. //库一
  367. new RouteInfo("RGV1", new string[] { "1661","1666" }),//北区机械臂码垛区
  368. new RouteInfo("RGV1", new string[] { "1662","1663","1664","1665", "1670","1671","1672","1673","1674","1675"}),//桁架北区码垛站台
  369. new RouteInfo("RGV2", new string[] { "1676","1681" }),
  370. new RouteInfo("RGV2", new string[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  371. #endregion RGV--码垛区域
  372. #region Robot--码垛工位
  373. //库一
  374. new RouteInfo("Robot1", new string[] { "1666" }),
  375. new RouteInfo("Robot1", new string[] { "1661" }),
  376. new RouteInfo("Robot2", new string[] { "1676" }),
  377. new RouteInfo("Robot2", new string[] { "1681" }),
  378. #endregion Robot--码垛工位
  379. #endregion 出库
  380. #region 入库
  381. #region 一楼人工入库口-巷道
  382. new RouteInfo("2532", new string[] { "TY1" }), //分拣库一
  383. new RouteInfo("2732", new string[] { "TY2" }),
  384. #endregion 一楼人工入库口-巷道
  385. #region 一楼叠盘机(堆垛机入口)--巷道
  386. new RouteInfo("2527", new string[] { "TY1" }), //分拣库一
  387. new RouteInfo("2528", new string[] { "TY1" }),
  388. new RouteInfo("2727", new string[] { "TY2" }),
  389. new RouteInfo("2728", new string[] { "TY2" }),
  390. #endregion 一楼叠盘机(堆垛机入口)--巷道
  391. #region 主线
  392. //北侧
  393. new RouteInfo("3", new string[] { "14" }),
  394. new RouteInfo("14", new string[] { "18" }),
  395. new RouteInfo("18", new string[] { "22" }),
  396. new RouteInfo("22", new string[] { "38" }),
  397. new RouteInfo("38", new string[] { "41" }),
  398. new RouteInfo("41", new string[] { "58" }),
  399. new RouteInfo("58", new string[] { "61" }),
  400. //南侧
  401. new RouteInfo("101", new string[] { "114" }),
  402. new RouteInfo("114", new string[] { "118" }),
  403. new RouteInfo("118", new string[] { "122" }),
  404. new RouteInfo("122", new string[] { "138" }),
  405. new RouteInfo("138", new string[] { "141" }),
  406. new RouteInfo("141", new string[] { "158" }),
  407. new RouteInfo("158", new string[] { "161" }),
  408. #endregion 主线
  409. #region 主线分流点--环形库分流点
  410. new RouteInfo("22", new string[] { "418" }), //分拣库一北
  411. new RouteInfo("122", new string[] { "618" }), //分拣库一南
  412. new RouteInfo("41", new string[] { "818" }), //分拣库二北
  413. new RouteInfo("141", new string[] { "1018" }), //分拣库二南
  414. new RouteInfo("61", new string[] { "1218" }), //分拣库三北
  415. new RouteInfo("161", new string[] { "1418" }), //分拣库三南
  416. #endregion 主线分流点--环形库分流点
  417. #region 环形库分流点--环形库取货点
  418. new RouteInfo("418", new string[] { "424","433","442" }),
  419. new RouteInfo("618", new string[] { "624", "633", "642" }),
  420. #endregion 环形库分流点--环形库取货点
  421. #region 环形库分流点--桁架分流点
  422. new RouteInfo("418", new string[] { "455" }), //分拣库一北
  423. new RouteInfo("618", new string[] { "655" }), //分拣库一南
  424. #endregion 环形库分流点--桁架分流点
  425. #region 桁架分流点--桁架缓存放行点
  426. new RouteInfo("455", new string[] { "466","480","494","508", "522","536","550","564","578","591"}), //分拣库一北
  427. new RouteInfo("655", new string[] { "666","680","694","708", "722","736","750","764","778","791"}), //分拣库一南
  428. #endregion 桁架分流点--桁架缓存放行点
  429. #region 桁架缓存放行点--桁架取货点
  430. new("466", new[] { "461" }), //分拣一北侧
  431. new("480", new[] { "475" }),
  432. new("494", new[] { "489" }),
  433. new("508", new[] { "503" }),
  434. new("522", new[] { "517" }),
  435. new("536", new[] { "531" }),
  436. new("550", new[] { "545" }),
  437. new("564", new[] { "559" }),
  438. new("578", new[] { "573" }),
  439. new("591", new[] { "586" }),
  440. new("666", new[] { "661" }),//分拣一南侧
  441. new("680", new[] { "675" }),
  442. new("694", new[] { "689" }),
  443. new("708", new[] { "703" }),
  444. new("722", new[] { "717" }),
  445. new("736", new[] { "731" }),
  446. new("750", new[] { "745" }),
  447. new("764", new[] { "759" }),
  448. new("778", new[] { "773" }),
  449. new("791", new[] { "786" }),
  450. #endregion 桁架缓存放行点--桁架取货点
  451. #region 桁架取货点--桁架
  452. new("461", new[] { "Truss1" }),//分拣一北侧
  453. new("475", new[] { "Truss1" }),
  454. new("489", new[] { "Truss1" }),
  455. new("503", new[] { "Truss1" }),
  456. new("517", new[] { "Truss1" }),
  457. new("531", new[] { "Truss1" }),
  458. new("545", new[] { "Truss1" }),
  459. new("559", new[] { "Truss1" }),
  460. new("573", new[] { "Truss1" }),
  461. new("586", new[] { "Truss1" }),//分拣一南侧
  462. new("661", new[] { "Truss1" }),
  463. new("675", new[] { "Truss1" }),
  464. new("689", new[] { "Truss1" }),
  465. new("703", new[] { "Truss1" }),
  466. new("717", new[] { "Truss1" }),
  467. new("731", new[] { "Truss1" }),
  468. new("745", new[] { "Truss1" }),
  469. new("759", new[] { "Truss1" }),
  470. new("773", new[] { "Truss1" }),
  471. new("786", new[] { "Truss1" }),
  472. #endregion 桁架取货点--桁架
  473. #region 桁架取货点--码垛工位
  474. new("461", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675" }),//分拣一北侧
  475. new("475", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  476. new("489", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  477. new("503", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  478. new("517", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  479. new("531", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  480. new("545", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  481. new("559", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  482. new("573", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675"}),
  483. new("586", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675" }),
  484. new("661", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),//分拣一南侧
  485. new("675", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  486. new("689", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  487. new("703", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  488. new("717", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  489. new("731", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  490. new("745", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  491. new("759", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  492. new("773", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  493. new("786", new[] { "1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  494. #endregion 桁架取货点--码垛工位
  495. #region 桁架--码垛工位
  496. new("Truss1", new[] { "1662","1663","1664","1665","1670","1671","1672","1673", "1674","1675","1677","1678","1679","1680", "1685","1686","1687","1688","1689","1690" }),
  497. #endregion 桁架--码垛工位
  498. #region 码垛工位--RGV
  499. //分拣库一北
  500. new RouteInfo("1661", new string[] { "RGV1" }),//机械手码垛工位
  501. new RouteInfo("1666", new string[] { "RGV1" }),
  502. new RouteInfo("1662", new string[] { "RGV1" }),//绗架码垛工位
  503. new RouteInfo("1663", new string[] { "RGV1" }),
  504. new RouteInfo("1664", new string[] { "RGV1" }),
  505. new RouteInfo("1665", new string[] { "RGV1" }),
  506. new RouteInfo("1670", new string[] { "RGV1" }),
  507. new RouteInfo("1671", new string[] { "RGV1" }),
  508. new RouteInfo("1672", new string[] { "RGV1" }),
  509. new RouteInfo("1673", new string[] { "RGV1" }),
  510. new RouteInfo("1674", new string[] { "RGV1" }),
  511. new RouteInfo("1675", new string[] { "RGV1" }),
  512. //分拣库一南
  513. new RouteInfo("1676", new string[] { "RGV2" }),//机械手码垛工位
  514. new RouteInfo("1681", new string[] { "RGV2" }),
  515. new RouteInfo("1677", new string[] { "RGV2" }),//绗架码垛工位
  516. new RouteInfo("1678", new string[] { "RGV2" }),
  517. new RouteInfo("1679", new string[] { "RGV2" }),
  518. new RouteInfo("1680", new string[] { "RGV2" }),
  519. new RouteInfo("1685", new string[] { "RGV2" }),
  520. new RouteInfo("1686", new string[] { "RGV2" }),
  521. new RouteInfo("1687", new string[] { "RGV2" }),
  522. new RouteInfo("1688", new string[] { "RGV2" }),
  523. new RouteInfo("1689", new string[] { "RGV2" }),
  524. new RouteInfo("1690", new string[] { "RGV2" }),
  525. #endregion 码垛工位--RGV
  526. #region RGV--RGV放货点
  527. new RouteInfo("RGV1", new string[] { "1604" }),
  528. new RouteInfo("RGV2", new string[] { "1614" }),
  529. #endregion RGV--RGV放货点
  530. #region RGV放货点--堆垛机取货口
  531. new RouteInfo("1604", new string[] { "1603" }),//北侧
  532. new RouteInfo("1614", new string[] { "1613" }),//南侧
  533. #endregion RGV放货点--堆垛机取货口
  534. #region 二楼堆垛机入库--巷道
  535. new RouteInfo("1603", new string[] { "TY1" }),//北侧
  536. new RouteInfo("1613", new string[] { "TY2" }),//南侧
  537. #endregion 二楼堆垛机入库--巷道
  538. #region 巷道--堆垛机
  539. new RouteInfo("TY1", new string[] { "SRM1" }),
  540. new RouteInfo("TY2", new string[] { "SRM2" }),
  541. #endregion 巷道--堆垛机
  542. #region 线体取货位--Robot
  543. new RouteInfo("442", new string[] { "Robot1" }),
  544. new RouteInfo("433", new string[] { "Robot1" }),
  545. new RouteInfo("424", new string[] { "Robot1" }),
  546. new RouteInfo("624", new string[] { "Robot2" }),
  547. new RouteInfo("633", new string[] { "Robot2" }),
  548. new RouteInfo("642", new string[] { "Robot2" }),
  549. #endregion 线体取货位--Robot
  550. #endregion 入库
  551. });
  552. foreach (var routeInfo in routeInfos)
  553. {
  554. if (routeInfo != null)
  555. {
  556. var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode);
  557. device.AddTarget(routeInfo.NextList);
  558. Parallel.ForEach(routeInfo.NextList, next =>
  559. {
  560. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  561. dev.Parent = device;
  562. });
  563. }
  564. }
  565. //Parallel.ForEach(routeInfos, routeInfo =>
  566. //{
  567. //});
  568. #endregion 配置路径信息
  569. #region 添加设备组
  570. var tuples2 = new List<Tuple<string, List<string>>>()
  571. {
  572. //环形库一北侧机械手取货位
  573. new("424",new List<string> {"424","425"}),
  574. new("433",new List<string> {"433","434"}),
  575. new("442",new List<string> {"442","443"}),
  576. //环形库一南侧侧机械手取货位
  577. new("642",new List<string> {"642","643"}),
  578. new("633",new List<string> {"633","634"}),
  579. new("624",new List<string> {"624","625"}),
  580. };
  581. Parallel.ForEach(tuples2, tuple =>
  582. {
  583. var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1);
  584. device.AddDeviceGroup(tuple.Item2.ToArray());
  585. });
  586. #endregion 添加设备组
  587. }
  588. if (WareHouses.Contains("FJ2"))
  589. {
  590. #region 初始化RGV相关信息
  591. List<RgvSegmentInfo> RgvInfo = new List<RgvSegmentInfo>
  592. {
  593. new RgvSegmentInfo( 3, "10.30.37.123"), //库二北
  594. new RgvSegmentInfo( 4, "10.30.37.128"), //库二南
  595. };
  596. foreach (var item in RgvInfo)
  597. {
  598. var conv = new Device($"RGV{item.Code}");
  599. conv.AddFlag(DeviceFlags.RGV);
  600. conv.AddProtocol<IRGV520>(0, 520, item.Ip);
  601. conv.AddProtocol<IRGV521>(0, 521, item.Ip);
  602. //conv.AddProtocol<IStation523>(, 523, item.IP);
  603. }
  604. #endregion 初始化RGV相关信息
  605. #region 初始化输送机相关信息
  606. #region 基本信息
  607. #region 托盘线输送线
  608. var tuples = new List<Tuple<string, List<Tuple<int, int>>>>
  609. {
  610. //分拣库二
  611. new("10.30.37.97",new List<Tuple<int, int>>()
  612. {
  613. new(1621, 1640),
  614. new(2901, 2940),
  615. new(3101, 3140),
  616. new(1691, 1720),
  617. }),
  618. };
  619. foreach (var item in tuples)
  620. {
  621. var db520 = 0;
  622. var db521 = 0;
  623. var db523 = 0;
  624. foreach (var item1 in item.Item2)
  625. {
  626. for (var i = item1.Item1; i <= item1.Item2; i++)
  627. {
  628. var conv = new Device(i.ToString());
  629. conv.AddFlag(DeviceFlags.输送机);
  630. conv.AddProtocol<IStation520>(db520, 520, item.Item1);
  631. conv.AddProtocol<IStation521>(db521, 521, item.Item1);
  632. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  633. db520 += 14;
  634. db521 += 16;
  635. db523 += 12;
  636. }
  637. }
  638. }
  639. #endregion 托盘线输送线
  640. #region 满轮输送线
  641. #region DB523,所有线体都会有DB523
  642. var mLtuples523 = new List<Tuple<string, List<Tuple<int, int>>>>()
  643. {
  644. new("10.30.37.166",new List<Tuple<int, int>>() //北侧满轮主线
  645. {
  646. new(1, 100),
  647. new(9001, 9010),//暂用,无意义
  648. new(401, 599),
  649. new(801,999),
  650. new(1201,1399),
  651. }),
  652. new("10.30.37.198",new List<Tuple<int, int>>() //南侧满轮主线
  653. {
  654. new(101, 210),
  655. new(601, 799),
  656. new(1001, 1199),
  657. new(1401,1599),
  658. new(341,379),
  659. })
  660. };
  661. foreach (var item in mLtuples523)
  662. {
  663. var db523 = 0;
  664. var db524 = 0;
  665. foreach (var item1 in item.Item2)
  666. {
  667. for (var i = item1.Item1; i <= item1.Item2; i++)
  668. {
  669. var conv = new Device(i.ToString());
  670. conv.AddFlag(DeviceFlags.输送机);
  671. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  672. conv.AddProtocol<IStation524>(db524, 524, item.Item1);
  673. db523 += 12;
  674. db524 += 16;
  675. }
  676. }
  677. }
  678. #endregion DB523,所有线体都会有DB523
  679. #region 520、521 交互线体会有520、521
  680. //Item2表示线体号集合,Item1表示IP
  681. var mLTuples520 = new List<Tuple<string, List<int>>>()
  682. {
  683. //北侧
  684. 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}),
  685. //南侧
  686. 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})
  687. };
  688. foreach (var item in mLTuples520)
  689. {
  690. var db520 = 0;
  691. var db521 = 0;
  692. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  693. {
  694. if (device != null)
  695. {
  696. device.AddProtocol<IStation520>(db520, 520, item.Item1);
  697. device.AddProtocol<IStation521>(db521, 521, item.Item1);
  698. }
  699. db520 += 14;
  700. db521 += 16;
  701. }
  702. }
  703. #endregion 520、521 交互线体会有520、521
  704. #region 满轮扫码器
  705. //Item2表示线体号集合,Item1表示IP
  706. var mLTuples83 = new List<Tuple<string, List<int>>>()
  707. {
  708. new("10.30.37.166",new List<int>(){3,14,18,22,38,323,41,58,61}) ,
  709. new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
  710. };
  711. foreach (var item in mLTuples83)
  712. {
  713. var db83 = 0;
  714. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  715. {
  716. device?.AddProtocol<IBCR83>(db83, 83, item.Item1);
  717. db83 += 604;
  718. }
  719. }
  720. #endregion 满轮扫码器
  721. #region 满轮线告诉分拣预分配
  722. //Item2表示线体号集合,Item1表示IP
  723. var mLTuples525 = new List<Tuple<string, List<int>>>()
  724. {
  725. new("10.30.37.166",new List<int>(){18,38,58}),
  726. new("10.30.37.198",new List<int>(){118,138,158}),
  727. };
  728. foreach (var item in mLTuples525)
  729. {
  730. var db525 = 0;
  731. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  732. {
  733. device?.AddProtocol<IStation525>(db525, 525, item.Item1);
  734. db525 += 3266;
  735. }
  736. }
  737. #endregion 满轮线告诉分拣预分配
  738. #region 外检信息
  739. //Item2表示线体号集合,Item1表示IP
  740. var mLTuples91 = new List<Tuple<string, List<int>>>()
  741. {
  742. new("10.30.37.166",new List<int>(){418,818,1218}),
  743. new("10.30.37.198",new List<int>(){618,1018,1418})
  744. };
  745. foreach (var item in mLTuples91)
  746. {
  747. var db91 = 0;
  748. foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString())))
  749. {
  750. device?.AddProtocol<IStation91>(db91, 91, item.Item1);
  751. db91 += 14;
  752. }
  753. }
  754. #endregion 外检信息
  755. #endregion 满轮输送线
  756. #endregion 基本信息
  757. #region 托盘线扫码器
  758. var bcrInfo = new List<BcrInfo>
  759. {
  760. new(new [] { "2932", "3132" }, "10.30.37.97"),
  761. new(new [] {"RGV3"},"10.30.37.123"),
  762. new(new [] {"RGV4"},"10.30.37.128"),
  763. };
  764. foreach (var item in bcrInfo)
  765. {
  766. for (var i = 0; i < item.DeviceNo.Length; i++)
  767. {
  768. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]);
  769. device.AddFlag(DeviceFlags.扫码);
  770. var pos = i * 130;
  771. device.AddProtocol<IBCR81>(pos, 81, item.Ip);
  772. }
  773. }
  774. #endregion 托盘线扫码器
  775. #region 外检信息
  776. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  777. {
  778. new ShapeInfo(new int[] { 2932,3132 }, "10.30.37.97"),
  779. };
  780. foreach (var item in shapeInfo)
  781. {
  782. for (int i = 0; i < item.DeviceNo.Length; i++)
  783. {
  784. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  785. conv.AddFlag(DeviceFlags.外检);
  786. int pos = i * 14;
  787. conv.AddProtocol<IStation91>(pos, 91, item.Ip);
  788. }
  789. }
  790. #endregion 外检信息
  791. #endregion 初始化输送机相关信息
  792. #region 初始化桁架相关信息
  793. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  794. {
  795. new TrussSegmentInfo( 2, "10.30.37.217"),
  796. };
  797. foreach (var item in TrussInfo)
  798. {
  799. var conv = new Device($"Truss{item.Code}");
  800. conv.AddFlag(DeviceFlags.桁架);
  801. conv.AddProtocol<ITruss520>(0, 520, item.Ip);
  802. conv.AddProtocol<ITruss521>(0, 521, item.Ip);
  803. conv.AddProtocol<ITruss523>(0, 523, item.Ip);
  804. }
  805. var tuples1 = new List<Tuple<string, List<int>>>
  806. {
  807. //桁架
  808. new("10.30.37.217",new List<int>(){1715,1716,1717,1718,1719,1720,1705,1704,1703,1702,1701,1700,1707,1708,1709,1710,1695,1694,1693,1692,1636,1626}), //分拣库二
  809. };
  810. foreach (var item in tuples1)
  811. {
  812. var db530 = 0;
  813. var db531 = 0;
  814. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  815. {
  816. conv!.AddProtocol<ITruss530>(db530, 530, item.Item1);
  817. conv!.AddProtocol<ITruss531>(db531, 531, item.Item1);
  818. db530 += 18;
  819. db531 += 250;
  820. if (conv.Code == "1662")
  821. {
  822. var a = 0;
  823. }
  824. }
  825. }
  826. var tuples21 = new List<Tuple<string, List<int>>>
  827. {
  828. //机械臂
  829. new("10.30.37.234",new List<int>(){ 1696, 1691}), //库二北
  830. new("10.30.37.236",new List<int>(){ 1711, 1706}), //库二南
  831. };
  832. foreach (var item in tuples21)
  833. {
  834. var db530 = 0;
  835. var db531 = 0;
  836. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  837. {
  838. conv!.AddProtocol<IRobot530>(db530, 530, item.Item1);
  839. conv!.AddProtocol<IRobot531>(db531, 531, item.Item1);
  840. db530 += 8;
  841. db531 += 130;
  842. }
  843. }
  844. #endregion 初始化桁架相关信息
  845. #region 初始化机械臂相关信息
  846. List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
  847. {
  848. new( 3, "10.30.37.234"),
  849. new( 4, "10.30.37.236"),
  850. };
  851. foreach (var item in TrussInfo1)
  852. {
  853. var conv = new Device($"Robot{item.Code}");
  854. conv.AddFlag(DeviceFlags.Robot);
  855. conv.AddProtocol<IRobot520>(0, 520, item.Ip);
  856. conv.AddProtocol<IRobot521>(0, 521, item.Ip);
  857. conv.AddProtocol<IRobot522>(0, 522, item.Ip);
  858. }
  859. #endregion 初始化机械臂相关信息
  860. #region 初始化堆垛机相关信息
  861. int ip = 57;
  862. for (int i = 0; i <= 1; i++)
  863. {
  864. var srm = new Device($"SRM{i + 1}");
  865. srm.AddFlag(DeviceFlags.堆垛机);
  866. ip = i == 0 ? ip : ip + 8;
  867. //三台堆垛机IP主机位分别是 41、49、57、65、73、81
  868. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  869. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  870. srm.AddProtocol<ISRM523>(0, 537, $"10.30.37.{ip}");
  871. //增加巷道
  872. var tunnel = new Device($"TY{i + 1}");
  873. tunnel.AddFlag(DeviceFlags.巷道);
  874. }
  875. #endregion 初始化堆垛机相关信息
  876. #region 配置路径信息
  877. List<RouteInfo> routeInfos = new List<RouteInfo>();
  878. routeInfos.AddRange(new List<RouteInfo>() {
  879. #region 出库
  880. #region 堆垛机--巷道
  881. new RouteInfo("SRM3", new string[] { "TY3" }),
  882. new RouteInfo("SRM4", new string[] { "TY4" }),
  883. #endregion 堆垛机--巷道
  884. #region 巷道--一楼堆垛机放货口
  885. new RouteInfo("TY3", new string[] { "2932","2934","2933" }), //人工取货口
  886. new RouteInfo("TY4", new string[] { "3132","3134","3133" }),
  887. #endregion 巷道--一楼堆垛机放货口
  888. #region 巷道--二楼堆垛机放货口
  889. new RouteInfo("TY3", new string[] { "1621","1625" }),
  890. new RouteInfo("TY4", new string[] { "1631","1635" }),
  891. #endregion 巷道--二楼堆垛机放货口
  892. #region 二楼堆垛机放货口--二楼拆盘机
  893. //库二
  894. new RouteInfo("1621", new string[] { "1622" }),//非09拆盘机
  895. new RouteInfo("1631", new string[] { "1632"}),
  896. new RouteInfo("1625", new string[] { "1626" }),//09拆盘机
  897. new RouteInfo("1635", new string[] { "1636" }),
  898. #endregion 二楼堆垛机放货口--二楼拆盘机
  899. #region 二楼拆盘机--RGV
  900. //库二
  901. new RouteInfo("1622", new string[] { "RGV3" }),//非09拆盘机
  902. new RouteInfo("1632", new string[] { "RGV4"}),
  903. new RouteInfo("1626", new string[] { "RGV3" }),//09拆盘机
  904. new RouteInfo("1636", new string[] { "RGV4" }),
  905. #endregion 二楼拆盘机--RGV
  906. #region RGV--码垛区域
  907. //库二
  908. new RouteInfo("RGV3", new string[] { "1691","1696" }),//北区机械臂码垛区
  909. new RouteInfo("RGV3", new string[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705"}),//桁架北区码垛站台
  910. new RouteInfo("RGV4", new string[] { "1706","1711" }),
  911. new RouteInfo("RGV4", new string[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  912. #endregion RGV--码垛区域
  913. #region Robot--码垛工位
  914. //库二
  915. new RouteInfo("Robot3", new string[] { "1691" }),
  916. new RouteInfo("Robot3", new string[] { "1696" }),
  917. new RouteInfo("Robot4", new string[] { "1706" }),
  918. new RouteInfo("Robot4", new string[] { "1711" }),
  919. #endregion Robot--码垛工位
  920. #endregion 出库
  921. #region 入库
  922. #region 一楼人工入库口-巷道
  923. new RouteInfo("2932", new string[] { "TY3" }), //分拣库二
  924. new RouteInfo("3132", new string[] { "TY4" }),
  925. #endregion 一楼人工入库口-巷道
  926. #region 一楼叠盘机(堆垛机入口)--巷道
  927. new RouteInfo("2927", new string[] { "TY3" }), //分拣库二
  928. new RouteInfo("2928", new string[] { "TY3" }),
  929. new RouteInfo("3127", new string[] { "TY4" }),
  930. new RouteInfo("3128", new string[] { "TY4" }),
  931. #endregion 一楼叠盘机(堆垛机入口)--巷道
  932. #region 主线
  933. //北侧
  934. new RouteInfo("38", new string[] { "41" }),
  935. new RouteInfo("41", new string[] { "58" }),
  936. new RouteInfo("58", new string[] { "61" }),
  937. //南侧
  938. new RouteInfo("138", new string[] { "141" }),
  939. new RouteInfo("141", new string[] { "158" }),
  940. new RouteInfo("158", new string[] { "161" }),
  941. #endregion 主线
  942. #region 主线分流点--环形库分流点
  943. new RouteInfo("41", new string[] { "818" }), //分拣库二北
  944. new RouteInfo("141", new string[] { "1018" }), //分拣库二南
  945. new RouteInfo("61", new string[] { "1218" }), //分拣库三北
  946. new RouteInfo("161", new string[] { "1418" }), //分拣库三南
  947. #endregion 主线分流点--环形库分流点
  948. #region 环形库分流点--环形库取货点
  949. new RouteInfo("818", new string[] { "824","833","842" }),
  950. new RouteInfo("1018", new string[] { "1024","1033","1042" }),
  951. #endregion 环形库分流点--环形库取货点
  952. #region 环形库分流点--桁架分流点
  953. new RouteInfo("818", new string[] { "855" }), //分拣库二北
  954. new RouteInfo("1018", new string[] { "1055" }), //分拣库二南
  955. #endregion 环形库分流点--桁架分流点
  956. #region 桁架分流点--桁架缓存放行点
  957. new RouteInfo("855", new string[] { "866","880","894","908", "922","936","950","964","978","991"}), //分拣库二北
  958. new RouteInfo("1055", new string[] { "1066","1080","1094","1108", "1122","1136","1150","1164","1178","1191"}), //分拣库二南
  959. #endregion 桁架分流点--桁架缓存放行点
  960. #region 桁架缓存放行点--桁架取货点
  961. new("866", new[] { "861" }), //分拣二北侧
  962. new("880", new[] { "875" }),
  963. new("894", new[] { "889" }),
  964. new("908", new[] { "903" }),
  965. new("922", new[] { "917" }),
  966. new("936", new[] { "931" }),
  967. new("950", new[] { "945" }),
  968. new("964", new[] { "959" }),
  969. new("978", new[] { "973" }),
  970. new("991", new[] { "986" }),
  971. new("1066", new[] { "1061" }),//分拣二南侧
  972. new("1080", new[] { "1075" }),
  973. new("1094", new[] { "1089" }),
  974. new("1108", new[] { "1103" }),
  975. new("1122", new[] { "1117" }),
  976. new("1136", new[] { "1131" }),
  977. new("1150", new[] { "1145" }),
  978. new("1164", new[] { "1159" }),
  979. new("1178", new[] { "1173" }),
  980. new("1191", new[] { "1186" }),
  981. #endregion 桁架缓存放行点--桁架取货点
  982. #region 桁架取货点--桁架
  983. new("861", new[] { "Truss2" }), //分拣二北侧
  984. new("875", new[] { "Truss2" }),
  985. new("889", new[] { "Truss2" }),
  986. new("903", new[] { "Truss2" }),
  987. new("917", new[] { "Truss2" }),
  988. new("931", new[] { "Truss2" }),
  989. new("945", new[] { "Truss2" }),
  990. new("959", new[] { "Truss2" }),
  991. new("973", new[] { "Truss2" }),
  992. new("986", new[] { "Truss2" }),
  993. new("1061", new[] { "Truss2" }),//分拣二南侧
  994. new("1075", new[] { "Truss2" }),
  995. new("1089", new[] { "Truss2" }),
  996. new("1103", new[] { "Truss2" }),
  997. new("1117", new[] { "Truss2" }),
  998. new("1131", new[] { "Truss2" }),
  999. new("1145", new[] { "Truss2" }),
  1000. new("1159", new[] { "Truss2" }),
  1001. new("1173", new[] { "Truss2" }),
  1002. new("1186", new[] { "Truss2" }),
  1003. #endregion 桁架取货点--桁架
  1004. #region 桁架取货点--码垛工位
  1005. new("861", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }), //分拣二北侧
  1006. new("875", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1007. new("889", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1008. new("903", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1009. new("917", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1010. new("931", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1011. new("945", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1012. new("959", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1013. new("973", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1014. new("986", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705" }),
  1015. new("1061", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),//分拣二南侧
  1016. new("1075", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1017. new("1089", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1018. new("1103", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1019. new("1117", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1020. new("1131", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1021. new("1145", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1022. new("1159", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1023. new("1173", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1024. new("1186", new[] { "1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1025. #endregion 桁架取货点--码垛工位
  1026. #region 桁架--码垛工位
  1027. new("Truss2", new[] { "1692","1693","1694","1695", "1700","1701","1702","1703","1704","1705","1707","1708","1709","1710", "1715","1716","1717","1718","1719","1720" }),
  1028. #endregion 桁架--码垛工位
  1029. #region 码垛工位--RGV
  1030. //分拣库二北
  1031. new RouteInfo("1691", new string[] { "RGV3" }),//机械手码垛工位
  1032. new RouteInfo("1696", new string[] { "RGV3" }),
  1033. new RouteInfo("1692", new string[] { "RGV3" }),//绗架码垛工位
  1034. new RouteInfo("1693", new string[] { "RGV3" }),
  1035. new RouteInfo("1694", new string[] { "RGV3" }),
  1036. new RouteInfo("1695", new string[] { "RGV3" }),
  1037. new RouteInfo("1700", new string[] { "RGV3" }),
  1038. new RouteInfo("1701", new string[] { "RGV3" }),
  1039. new RouteInfo("1702", new string[] { "RGV3" }),
  1040. new RouteInfo("1703", new string[] { "RGV3" }),
  1041. new RouteInfo("1704", new string[] { "RGV3" }),
  1042. new RouteInfo("1705", new string[] { "RGV3" }),
  1043. //分拣库二南
  1044. new RouteInfo("1706", new string[] { "RGV4" }),//机械手码垛工位
  1045. new RouteInfo("1711", new string[] { "RGV4" }),
  1046. new RouteInfo("1707", new string[] { "RGV4" }),//绗架码垛工位
  1047. new RouteInfo("1708", new string[] { "RGV4" }),
  1048. new RouteInfo("1709", new string[] { "RGV4" }),
  1049. new RouteInfo("1710", new string[] { "RGV4" }),
  1050. new RouteInfo("1715", new string[] { "RGV4" }),
  1051. new RouteInfo("1716", new string[] { "RGV4" }),
  1052. new RouteInfo("1717", new string[] { "RGV4" }),
  1053. new RouteInfo("1718", new string[] { "RGV4" }),
  1054. new RouteInfo("1719", new string[] { "RGV4" }),
  1055. new RouteInfo("1720", new string[] { "RGV4" }),
  1056. #endregion 码垛工位--RGV
  1057. #region RGV--RGV放货点
  1058. new RouteInfo("RGV3", new string[] { "1624" }),
  1059. new RouteInfo("RGV4", new string[] { "1634" }),
  1060. #endregion RGV--RGV放货点
  1061. #region RGV放货点--堆垛机取货口
  1062. new RouteInfo("1624", new string[] { "1623" }),//北侧
  1063. new RouteInfo("1634", new string[] { "1633" }),//南侧
  1064. #endregion RGV放货点--堆垛机取货口
  1065. #region 二楼堆垛机入库--巷道
  1066. new RouteInfo("1623", new string[] { "TY3" }),//北侧
  1067. new RouteInfo("1633", new string[] { "TY4" }),//南侧
  1068. #endregion 二楼堆垛机入库--巷道
  1069. #region 巷道--堆垛机
  1070. new RouteInfo("TY3", new string[] { "SRM3" }),
  1071. new RouteInfo("TY4", new string[] { "SRM4" }),
  1072. #endregion 巷道--堆垛机
  1073. #region 线体取货位--Robot
  1074. new RouteInfo("824", new string[] { "Robot3" }),
  1075. new RouteInfo("833", new string[] { "Robot3" }),
  1076. new RouteInfo("842", new string[] { "Robot3" }),
  1077. new RouteInfo("1024", new string[] { "Robot4" }),
  1078. new RouteInfo("1033", new string[] { "Robot4" }),
  1079. new RouteInfo("1042", new string[] { "Robot4" }),
  1080. #endregion 线体取货位--Robot
  1081. #endregion 入库
  1082. });
  1083. foreach (var routeInfo in routeInfos)
  1084. {
  1085. if (routeInfo != null)
  1086. {
  1087. var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode);
  1088. device.AddTarget(routeInfo.NextList);
  1089. Parallel.ForEach(routeInfo.NextList, next =>
  1090. {
  1091. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  1092. dev.Parent = device;
  1093. });
  1094. }
  1095. }
  1096. #endregion 配置路径信息
  1097. #region 添加设备组
  1098. var tuples2 = new List<Tuple<string, List<string>>>()
  1099. {
  1100. //环形库二北侧机械手取货位
  1101. new("824",new List<string> {"824","825"}),
  1102. new("833",new List<string> {"833","834"}),
  1103. new("842",new List<string> {"842","843"}),
  1104. //环形库二南侧侧机械手取货位
  1105. new("1042",new List<string> {"1042","1043"}),
  1106. new("1033",new List<string> {"1033","1034"}),
  1107. new("1024",new List<string> {"1024","1025"}),
  1108. };
  1109. Parallel.ForEach(tuples2, tuple =>
  1110. {
  1111. var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1);
  1112. device.AddDeviceGroup(tuple.Item2.ToArray());
  1113. });
  1114. #endregion 添加设备组
  1115. }
  1116. if (WareHouses.Contains("FJ3"))
  1117. {
  1118. #region 初始化RGV相关信息
  1119. List<RgvSegmentInfo> RgvInfo = new List<RgvSegmentInfo>
  1120. {
  1121. new RgvSegmentInfo( 5, "10.30.37.133"), //库三北
  1122. new RgvSegmentInfo( 6, "10.30.37.138"), //库三南
  1123. };
  1124. foreach (var item in RgvInfo)
  1125. {
  1126. var conv = new Device($"RGV{item.Code}");
  1127. conv.AddFlag(DeviceFlags.RGV);
  1128. conv.AddProtocol<IRGV520>(0, 520, item.Ip);
  1129. conv.AddProtocol<IRGV521>(0, 521, item.Ip);
  1130. //conv.AddProtocol<IStation523>(, 523, item.IP);
  1131. }
  1132. #endregion 初始化RGV相关信息
  1133. #region 初始化输送机相关信息
  1134. #region 基本信息
  1135. #region 托盘线输送线
  1136. var tuples = new List<Tuple<string, List<Tuple<int, int>>>>
  1137. {
  1138. //分拣库三
  1139. new("10.30.37.105",new List<Tuple<int, int>>()
  1140. {
  1141. new(1641, 1660),
  1142. new(3301, 3340),
  1143. new(3501, 3540),
  1144. new(1721, 1750)
  1145. })
  1146. };
  1147. foreach (var item in tuples)
  1148. {
  1149. var db520 = 0;
  1150. var db521 = 0;
  1151. var db523 = 0;
  1152. foreach (var item1 in item.Item2)
  1153. {
  1154. for (var i = item1.Item1; i <= item1.Item2; i++)
  1155. {
  1156. var conv = new Device(i.ToString());
  1157. conv.AddFlag(DeviceFlags.输送机);
  1158. conv.AddProtocol<IStation520>(db520, 520, item.Item1);
  1159. conv.AddProtocol<IStation521>(db521, 521, item.Item1);
  1160. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  1161. db520 += 14;
  1162. db521 += 16;
  1163. db523 += 12;
  1164. }
  1165. }
  1166. }
  1167. #endregion 托盘线输送线
  1168. #region 满轮输送线
  1169. #region DB523,所有线体都会有DB523
  1170. var mLtuples523 = new List<Tuple<string, List<Tuple<int, int>>>>()
  1171. {
  1172. new("10.30.37.166",new List<Tuple<int, int>>() //北侧满轮主线
  1173. {
  1174. new(1, 100),
  1175. new(9001, 9010),//暂用,无意义
  1176. new(401, 599),
  1177. new(801,999),
  1178. new(1201,1399),
  1179. }),
  1180. new("10.30.37.198",new List<Tuple<int, int>>() //南侧满轮主线
  1181. {
  1182. new(101, 210),
  1183. new(601, 799),
  1184. new(1001, 1199),
  1185. new(1401,1599),
  1186. new(341,379),
  1187. })
  1188. };
  1189. foreach (var item in mLtuples523)
  1190. {
  1191. var db523 = 0;
  1192. var db524 = 0;
  1193. foreach (var item1 in item.Item2)
  1194. {
  1195. for (var i = item1.Item1; i <= item1.Item2; i++)
  1196. {
  1197. var conv = new Device(i.ToString());
  1198. conv.AddFlag(DeviceFlags.输送机);
  1199. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  1200. conv.AddProtocol<IStation524>(db524, 524, item.Item1);
  1201. db523 += 12;
  1202. db524 += 16;
  1203. }
  1204. }
  1205. }
  1206. #endregion DB523,所有线体都会有DB523
  1207. #region 520、521 交互线体会有520、521
  1208. //Item2表示线体号集合,Item1表示IP
  1209. var mLTuples520 = new List<Tuple<string, List<int>>>()
  1210. {
  1211. //北侧
  1212. 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}),
  1213. //南侧
  1214. 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})
  1215. };
  1216. foreach (var item in mLTuples520)
  1217. {
  1218. var db520 = 0;
  1219. var db521 = 0;
  1220. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  1221. {
  1222. if (device != null)
  1223. {
  1224. device.AddProtocol<IStation520>(db520, 520, item.Item1);
  1225. device.AddProtocol<IStation521>(db521, 521, item.Item1);
  1226. }
  1227. db520 += 14;
  1228. db521 += 16;
  1229. }
  1230. }
  1231. #endregion 520、521 交互线体会有520、521
  1232. #region 满轮扫码器
  1233. //Item2表示线体号集合,Item1表示IP
  1234. var mLTuples83 = new List<Tuple<string, List<int>>>()
  1235. {
  1236. new("10.30.37.166",new List<int>(){3,14,18,22,38,323,41,58,61}) ,
  1237. new("10.30.37.198",new List<int>(){101,114,118,122,138,363,141,158,161})
  1238. };
  1239. foreach (var item in mLTuples83)
  1240. {
  1241. var db83 = 0;
  1242. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  1243. {
  1244. device?.AddProtocol<IBCR83>(db83, 83, item.Item1);
  1245. db83 += 604;
  1246. }
  1247. }
  1248. #endregion 满轮扫码器
  1249. #region 满轮线告诉分拣预分配
  1250. //Item2表示线体号集合,Item1表示IP
  1251. var mLTuples525 = new List<Tuple<string, List<int>>>()
  1252. {
  1253. new("10.30.37.166",new List<int>(){18,38,58}),
  1254. new("10.30.37.198",new List<int>(){118,138,158}),
  1255. };
  1256. foreach (var item in mLTuples525)
  1257. {
  1258. var db525 = 0;
  1259. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  1260. {
  1261. device?.AddProtocol<IStation525>(db525, 525, item.Item1);
  1262. db525 += 3266;
  1263. }
  1264. }
  1265. #endregion 满轮线告诉分拣预分配
  1266. #region 外检信息
  1267. //Item2表示线体号集合,Item1表示IP
  1268. var mLTuples91 = new List<Tuple<string, List<int>>>()
  1269. {
  1270. new("10.30.37.166",new List<int>(){418,818,1218}),
  1271. new("10.30.37.198",new List<int>(){618,1018,1418})
  1272. };
  1273. foreach (var item in mLTuples91)
  1274. {
  1275. var db91 = 0;
  1276. foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString())))
  1277. {
  1278. device?.AddProtocol<IStation91>(db91, 91, item.Item1);
  1279. db91 += 14;
  1280. }
  1281. }
  1282. #endregion 外检信息
  1283. #endregion 满轮输送线
  1284. #endregion 基本信息
  1285. #region 托盘线扫码器
  1286. var bcrInfo = new List<BcrInfo>
  1287. {
  1288. new(new [] { "3332", "3532" }, "10.30.37.105"),
  1289. new(new [] {"RGV5"},"10.30.37.133"),
  1290. new(new [] {"RGV6"},"10.30.37.138")
  1291. };
  1292. foreach (var item in bcrInfo)
  1293. {
  1294. for (var i = 0; i < item.DeviceNo.Length; i++)
  1295. {
  1296. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]);
  1297. device.AddFlag(DeviceFlags.扫码);
  1298. var pos = i * 130;
  1299. device.AddProtocol<IBCR81>(pos, 81, item.Ip);
  1300. }
  1301. }
  1302. #endregion 托盘线扫码器
  1303. #region 外检信息
  1304. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  1305. {
  1306. new ShapeInfo(new int[] { 3332,3532 }, "10.30.37.105")
  1307. };
  1308. foreach (var item in shapeInfo)
  1309. {
  1310. for (int i = 0; i < item.DeviceNo.Length; i++)
  1311. {
  1312. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  1313. conv.AddFlag(DeviceFlags.外检);
  1314. int pos = i * 14;
  1315. conv.AddProtocol<IStation91>(pos, 91, item.Ip);
  1316. }
  1317. }
  1318. #endregion 外检信息
  1319. #endregion 初始化输送机相关信息
  1320. #region 初始化桁架相关信息
  1321. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  1322. {
  1323. new TrussSegmentInfo( 3, "10.30.37.223")
  1324. };
  1325. foreach (var item in TrussInfo)
  1326. {
  1327. var conv = new Device($"Truss{item.Code}");
  1328. conv.AddFlag(DeviceFlags.桁架);
  1329. conv.AddProtocol<ITruss520>(0, 520, item.Ip);
  1330. conv.AddProtocol<ITruss521>(0, 521, item.Ip);
  1331. conv.AddProtocol<ITruss523>(0, 523, item.Ip);
  1332. }
  1333. var tuples1 = new List<Tuple<string, List<int>>>
  1334. {
  1335. //桁架
  1336. new("10.30.37.223",new List<int>(){1745,1746,1747,1748,1749,1750,1735,1734,1733,1732,1731,1730,1737,1738,1739,1740,1725,1724,1723,1722,1656,1646}), //分拣库三
  1337. };
  1338. foreach (var item in tuples1)
  1339. {
  1340. var db530 = 0;
  1341. var db531 = 0;
  1342. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  1343. {
  1344. conv!.AddProtocol<ITruss530>(db530, 530, item.Item1);
  1345. conv!.AddProtocol<ITruss531>(db531, 531, item.Item1);
  1346. db530 += 18;
  1347. db531 += 250;
  1348. if (conv.Code == "1662")
  1349. {
  1350. var a = 0;
  1351. }
  1352. }
  1353. }
  1354. var tuples21 = new List<Tuple<string, List<int>>>
  1355. {
  1356. //机械臂
  1357. new("10.30.37.238",new List<int>(){ 1726, 1721}), //库三北
  1358. new("10.30.37.240",new List<int>(){ 1741, 1736}), //库三南
  1359. };
  1360. foreach (var item in tuples21)
  1361. {
  1362. var db530 = 0;
  1363. var db531 = 0;
  1364. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  1365. {
  1366. conv!.AddProtocol<IRobot530>(db530, 530, item.Item1);
  1367. conv!.AddProtocol<IRobot531>(db531, 531, item.Item1);
  1368. db530 += 8;
  1369. db531 += 130;
  1370. }
  1371. }
  1372. #endregion 初始化桁架相关信息
  1373. #region 初始化机械臂相关信息
  1374. List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
  1375. {
  1376. new( 5, "10.30.37.238"),
  1377. new( 6, "10.30.37.240"),
  1378. };
  1379. foreach (var item in TrussInfo1)
  1380. {
  1381. var conv = new Device($"Robot{item.Code}");
  1382. conv.AddFlag(DeviceFlags.Robot);
  1383. conv.AddProtocol<IRobot520>(0, 520, item.Ip);
  1384. conv.AddProtocol<IRobot521>(0, 521, item.Ip);
  1385. conv.AddProtocol<IRobot522>(0, 522, item.Ip);
  1386. }
  1387. #endregion 初始化机械臂相关信息
  1388. #region 初始化堆垛机相关信息
  1389. int ip = 7;
  1390. for (int i = 73; i <= 1; i++)
  1391. {
  1392. var srm = new Device($"SRM{i + 1}");
  1393. srm.AddFlag(DeviceFlags.堆垛机);
  1394. ip = i == 0 ? ip : ip + 8;
  1395. //三台堆垛机IP主机位分别是 41、49、57、65、73、8
  1396. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  1397. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  1398. srm.AddProtocol<ISRM523>(0, 537, $"10.30.37.{ip}");
  1399. //增加巷道
  1400. var tunnel = new Device($"TY{i + 1}");
  1401. tunnel.AddFlag(DeviceFlags.巷道);
  1402. }
  1403. #endregion 初始化堆垛机相关信息
  1404. #region 配置路径信息
  1405. List<RouteInfo> routeInfos = new List<RouteInfo>();
  1406. routeInfos.AddRange(new List<RouteInfo>() {
  1407. #region 出库
  1408. #region 堆垛机--巷道
  1409. new RouteInfo("SRM5", new string[] { "TY5" }),
  1410. new RouteInfo("SRM6", new string[] { "TY6" }),
  1411. #endregion 堆垛机--巷道
  1412. #region 巷道--一楼堆垛机放货口
  1413. new RouteInfo("TY5", new string[] { "3332","3334","3333" }), //人工取货口
  1414. new RouteInfo("TY6", new string[]{ "3532","3534","3533" }),
  1415. #endregion 巷道--一楼堆垛机放货口
  1416. #region 巷道--二楼堆垛机放货口
  1417. new RouteInfo("TY5", new string[] { "1641","1645" }),
  1418. new RouteInfo("TY6", new string[] { "1651","1655" }),
  1419. #endregion 巷道--二楼堆垛机放货口
  1420. #region 二楼堆垛机放货口--二楼拆盘机
  1421. //库三
  1422. new RouteInfo("1641", new string[] { "1642" }),//非09拆盘机
  1423. new RouteInfo("1651", new string[] { "1652"}),
  1424. new RouteInfo("1645", new string[] { "1646" }),//09拆盘机
  1425. new RouteInfo("1655", new string[] { "1656" }),
  1426. #endregion 二楼堆垛机放货口--二楼拆盘机
  1427. #region 二楼拆盘机--RGV
  1428. //库三
  1429. new RouteInfo("1642", new string[] { "RGV5" }),//非09拆盘机
  1430. new RouteInfo("1652", new string[] { "RGV6"}),
  1431. new RouteInfo("1646", new string[] { "RGV5" }),//09拆盘机
  1432. new RouteInfo("1656", new string[] { "RGV6" }),
  1433. #endregion 二楼拆盘机--RGV
  1434. #region RGV--码垛区域
  1435. //库三
  1436. new RouteInfo("RGV5", new string[] { "1721","1726" }),//北区机械臂码垛区
  1437. new RouteInfo("RGV5", new string[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735"}),//桁架北区码垛站台
  1438. new RouteInfo("RGV6", new string[] { "1736","1741" }),
  1439. new RouteInfo("RGV6", new string[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1440. #endregion RGV--码垛区域
  1441. #region Robot--码垛工位
  1442. //库三
  1443. new RouteInfo("Robot5", new string[] { "1721" }),
  1444. new RouteInfo("Robot5", new string[] { "1726" }),
  1445. new RouteInfo("Robot6", new string[] { "1736" }),
  1446. new RouteInfo("Robot6", new string[] { "1741" }),
  1447. #endregion Robot--码垛工位
  1448. #endregion 出库
  1449. #region 入库
  1450. #region 一楼人工入库口-巷道
  1451. new RouteInfo("3332", new string[] { "TY5" }), //分拣库三
  1452. new RouteInfo("3532", new string[] { "TY6" }),
  1453. #endregion 一楼人工入库口-巷道
  1454. #region 一楼叠盘机(堆垛机入口)--巷道
  1455. new RouteInfo("3327", new string[] { "TY5" }), //分拣库三
  1456. new RouteInfo("3328", new string[] { "TY5" }),
  1457. new RouteInfo("3527", new string[] { "TY6" }),
  1458. new RouteInfo("3528", new string[] { "TY6" }),
  1459. #endregion 一楼叠盘机(堆垛机入口)--巷道
  1460. #region 环形库分流点--环形库取货点
  1461. new RouteInfo("1218", new string[] { "1224","1233","1242" }),
  1462. new RouteInfo("1418", new string[] { "1424","1433","1442" }),
  1463. #endregion 环形库分流点--环形库取货点
  1464. #region 主线
  1465. //北侧
  1466. new RouteInfo("58", new string[] { "61" }),
  1467. //南侧
  1468. new RouteInfo("158", new string[] { "161" }),
  1469. #endregion 主线
  1470. #region 主线分流点--环形库分流点
  1471. new RouteInfo("61", new string[] { "1218" }), //分拣库三北
  1472. new RouteInfo("161", new string[] { "1418" }), //分拣库三南
  1473. #endregion 主线分流点--环形库分流点
  1474. #region 环形库分流点--桁架分流点
  1475. new RouteInfo("1218", new string[] { "1255" }), //分拣库三北
  1476. new RouteInfo("1418", new string[] { "1455" }), //分拣库三南
  1477. #endregion 环形库分流点--桁架分流点
  1478. #region 桁架分流点--桁架缓存放行点
  1479. new RouteInfo("1255", new string[] { "1266","1280","1294","1308", "1322","1336","1350","1364","1378", "1391"}), //分拣库三北
  1480. new RouteInfo("1455", new string[] { "1466","1480","1494","1508", "1522","1536","1550","1564","1578","1591"}), //分拣库三南
  1481. #endregion 桁架分流点--桁架缓存放行点
  1482. #region 桁架缓存放行点--桁架取货点
  1483. new("1266", new[] { "1261" }), //分拣三北侧
  1484. new("1280", new[] { "1275" }),
  1485. new("1294", new[] { "1289" }),
  1486. new("1308", new[] { "1303" }),
  1487. new("1322", new[] { "1317" }),
  1488. new("1336", new[] { "1331" }),
  1489. new("1350", new[] { "1345" }),
  1490. new("1364", new[] { "1359" }),
  1491. new("1378", new[] { "1373" }),
  1492. new("1391", new[] { "1386" }),
  1493. new("1466", new[] { "1461" }),//分拣三南侧
  1494. new("1480", new[] { "1475" }),
  1495. new("1494", new[] { "1489" }),
  1496. new("1508", new[] { "1503" }),
  1497. new("1522", new[] { "1517" }),
  1498. new("1536", new[] { "1531" }),
  1499. new("1550", new[] { "1545" }),
  1500. new("1564", new[] { "1559" }),
  1501. new("1578", new[] { "1573" }),
  1502. new("1591", new[] { "1586" }),
  1503. #endregion 桁架缓存放行点--桁架取货点
  1504. #region 桁架取货点--桁架
  1505. new("1261", new[] { "Truss3" }), //分拣三北侧
  1506. new("1275", new[] { "Truss3" }),
  1507. new("1289", new[] { "Truss3" }),
  1508. new("1303", new[] { "Truss3" }),
  1509. new("1317", new[] { "Truss3" }),
  1510. new("1331", new[] { "Truss3" }),
  1511. new("1345", new[] { "Truss3" }),
  1512. new("1359", new[] { "Truss3" }),
  1513. new("1373", new[] { "Truss3" }),
  1514. new("1386", new[] { "Truss3" }),
  1515. new("1461", new[] { "Truss3" }),//分拣三南侧
  1516. new("1475", new[] { "Truss3" }),
  1517. new("1489", new[] { "Truss3" }),
  1518. new("1503", new[] { "Truss3" }),
  1519. new("1517", new[] { "Truss3" }),
  1520. new("1531", new[] { "Truss3" }),
  1521. new("1545", new[] { "Truss3" }),
  1522. new("1559", new[] { "Truss3" }),
  1523. new("1573", new[] { "Truss3" }),
  1524. new("1586", new[] { "Truss3" }),
  1525. #endregion 桁架取货点--桁架
  1526. #region 桁架取货点--码垛工位
  1527. new("1261", new[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }), //分拣三北侧
  1528. new("1275", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1529. new("1289", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1530. new("1303", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1531. new("1317", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1532. new("1331", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1533. new("1345", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1534. new("1359", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1535. new("1373", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1536. new("1386", new[] {"1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735" }),
  1537. new("1461", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),//分拣三南侧
  1538. new("1475", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1539. new("1489", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1540. new("1503", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1541. new("1517", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1542. new("1531", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1543. new("1545", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1544. new("1559", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1545. new("1573", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1546. new("1586", new[] { "1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750" }),
  1547. #endregion 桁架取货点--码垛工位
  1548. #region 桁架--码垛工位
  1549. new("Truss3", new[] { "1722","1723","1724","1725", "1730","1731","1732","1733","1734","1735","1737","1738","1739","1740", "1745","1746","1747","1748","1749","1750"}),
  1550. #endregion 桁架--码垛工位
  1551. #region 码垛工位--RGV
  1552. //分拣库三北
  1553. new RouteInfo("1721", new string[] { "RGV5" }),//机械手码垛工位
  1554. new RouteInfo("1726", new string[] { "RGV5" }),
  1555. new RouteInfo("1722", new string[] { "RGV5" }),//绗架码垛工位
  1556. new RouteInfo("1723", new string[] { "RGV5" }),
  1557. new RouteInfo("1724", new string[] { "RGV5" }),
  1558. new RouteInfo("1725", new string[] { "RGV5" }),
  1559. new RouteInfo("1730", new string[] { "RGV5" }),
  1560. new RouteInfo("1731", new string[] { "RGV5" }),
  1561. new RouteInfo("1732", new string[] { "RGV5" }),
  1562. new RouteInfo("1733", new string[] { "RGV5" }),
  1563. new RouteInfo("1734", new string[] { "RGV5" }),
  1564. new RouteInfo("1735", new string[] { "RGV5" }),
  1565. //分拣库三南
  1566. new RouteInfo("1736", new string[] { "RGV6" }),//机械手码垛工位
  1567. new RouteInfo("1741", new string[] { "RGV6" }),
  1568. new RouteInfo("1737", new string[] { "RGV6" }),//绗架码垛工位
  1569. new RouteInfo("1738", new string[] { "RGV6" }),
  1570. new RouteInfo("1739", new string[] { "RGV6" }),
  1571. new RouteInfo("1740", new string[] { "RGV6" }),
  1572. new RouteInfo("1745", new string[] { "RGV6" }),
  1573. new RouteInfo("1746", new string[] { "RGV6" }),
  1574. new RouteInfo("1747", new string[] { "RGV6" }),
  1575. new RouteInfo("1748", new string[] { "RGV6" }),
  1576. new RouteInfo("1749", new string[] { "RGV6" }),
  1577. new RouteInfo("1750", new string[] { "RGV6" }),
  1578. #endregion 码垛工位--RGV
  1579. #region RGV--RGV放货点
  1580. new RouteInfo("RGV5", new string[] { "1644" }),
  1581. new RouteInfo("RGV6", new string[] { "1654" }),
  1582. #endregion RGV--RGV放货点
  1583. #region RGV放货点--堆垛机取货口
  1584. new RouteInfo("1644", new string[] { "1643" }),//北侧
  1585. new RouteInfo("1654", new string[] { "1653" }),//南侧
  1586. #endregion RGV放货点--堆垛机取货口
  1587. #region 二楼堆垛机入库--巷道
  1588. new RouteInfo("1643", new string[] { "TY5" }),//北侧
  1589. new RouteInfo("1653", new string[] { "TY6" }),//南侧
  1590. #endregion 二楼堆垛机入库--巷道
  1591. #region 巷道--堆垛机
  1592. new RouteInfo("TY5", new string[] { "SRM5" }),
  1593. new RouteInfo("TY6", new string[] { "SRM6" }),
  1594. #endregion 巷道--堆垛机
  1595. #region 线体取货位--Robot
  1596. new RouteInfo("1224", new string[] { "Robot5" }),
  1597. new RouteInfo("1233", new string[] { "Robot5" }),
  1598. new RouteInfo("1242", new string[] { "Robot5" }),
  1599. new RouteInfo("1424", new string[] { "Robot6" }),
  1600. new RouteInfo("1433", new string[] { "Robot6" }),
  1601. new RouteInfo("1442", new string[] { "Robot6" })
  1602. #endregion 线体取货位--Robot
  1603. #endregion 入库
  1604. });
  1605. foreach (var routeInfo in routeInfos)
  1606. {
  1607. if (routeInfo != null)
  1608. {
  1609. var device = Device.All.FirstOrDefault(x => x.Code == routeInfo.DeviceCode);
  1610. device.AddTarget(routeInfo.NextList);
  1611. Parallel.ForEach(routeInfo.NextList, next =>
  1612. {
  1613. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  1614. dev.Parent = device;
  1615. });
  1616. }
  1617. }
  1618. //Parallel.ForEach(routeInfos, routeInfo =>
  1619. //{
  1620. //});
  1621. #endregion 配置路径信息
  1622. #region 添加设备组
  1623. var tuples2 = new List<Tuple<string, List<string>>>()
  1624. {
  1625. ////环形库三北侧机械手取货位
  1626. new("1224",new List<string> {"1224","1225"}),
  1627. new("1233",new List<string> {"1233","1234"}),
  1628. new("1242",new List<string> {"1242","1243"}),
  1629. ////环形库三南侧侧机械手取货位
  1630. new("1442",new List<string> {"1442","1443"}),
  1631. new("1433",new List<string> {"1433","1434"}),
  1632. new("1424",new List<string> {"1424","1425"}),
  1633. };
  1634. Parallel.ForEach(tuples2, tuple =>
  1635. {
  1636. var device = Device.All.FirstOrDefault(x => x.Code == tuple.Item1);
  1637. device.AddDeviceGroup(tuple.Item2.ToArray());
  1638. });
  1639. #endregion 添加设备组
  1640. }
  1641. #region 标签配置
  1642. Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>();
  1643. if (WareHouses.Contains("FJ1"))
  1644. {
  1645. devices = new Dictionary<DeviceFlags, List<string>>
  1646. {
  1647. { DeviceFlags.一楼叠盘机,new List<string>() { "2527", "2528", "2727", "2728" } },
  1648. { DeviceFlags.桁架分流点,new List<string>() { "455", "655" } },
  1649. { DeviceFlags.桁架缓存放行点, new List<string>(){ "466", "480", "494", "508", "522", "536", "550", "564", "578", "591", "666", "680", "694", "708", "722", "736", "750", "764", "778", "791",} },
  1650. { DeviceFlags.桁架09缓存放行点, new List<string>(){"1266", "1280", "1294", "1308", "1322", "1336", "1466", "1480", "1494", "1508", "1522", "1536" } },
  1651. { DeviceFlags.桁架09异常缓存放行点, new List<string>(){ "591", "791" } },
  1652. { DeviceFlags.桁架18缓存放行点, new List<string>(){ "550", "564", "578", "750", "764", "778" } },
  1653. { DeviceFlags.桁架取货点, new List<string>(){ "461", "475", "489", "503", "517", "531", "545", "559", "573", "586", "661", "675", "689", "703", "717", "731", "745", "759", "773", "786"} },
  1654. { DeviceFlags.桁架18取货点, new List<string>(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } },
  1655. { DeviceFlags.拆盘机, new List<string>(){ "1602", "1612" } },
  1656. { DeviceFlags.桁架码垛位, new List<string>(){ "1670","1671","1672","1673","1674","1675","1664","1662","1663","1665","1677","1678","1679","1680","1685","1686","1687","1688","1689","1690","1606","1616"} },
  1657. { DeviceFlags.环形库码垛工位, new List<string>(){ "1666", "1661", "1676", "1681" } },
  1658. { DeviceFlags.AGV取货站台口, new List<string>(){ "2533", "2534", "2734", "2733"} },
  1659. { DeviceFlags.Robot, new List<string>(){ "Robot1", "Robot2" } },
  1660. {DeviceFlags.二次码垛RGV取货口, new List<string>(){ "1606", "1616"}}
  1661. };
  1662. }
  1663. if (WareHouses.Contains("FJ2"))
  1664. {
  1665. devices = new Dictionary<DeviceFlags, List<string>>
  1666. {
  1667. { DeviceFlags.一楼叠盘机,new List<string>() { "2927", "2928", "3127", "3128", } },
  1668. { DeviceFlags.桁架分流点,new List<string>() { "855", "1055" } },
  1669. { DeviceFlags.桁架缓存放行点, new List<string>(){ "866", "880", "894", "908", "922", "936", "950", "964", "978", "991", "1066", "1080", "1094", "1108", "1122", "1136", "1150", "1164", "1178", "1191",} },
  1670. { DeviceFlags.桁架09缓存放行点, new List<string>(){ "866", "880", "894", "908", "922", "936", "1066", "1080", "1094", "1108", "1122", "1136"} },
  1671. { DeviceFlags.桁架09异常缓存放行点, new List<string>(){ "991" , "1191" } },
  1672. { DeviceFlags.桁架18缓存放行点, new List<string>(){ "950", "964", "978" , "1150", "1164", "1178"} },
  1673. { DeviceFlags.桁架取货点, new List<string>(){ "861", "875", "889", "903", "917", "931", "945", "959", "973", "986", "1061", "1075", "1089", "1103", "1117", "1131", "1145", "1159", "1173", "1186"} },
  1674. { DeviceFlags.桁架18取货点, new List<string>(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } },
  1675. { DeviceFlags.拆盘机, new List<string>(){ "1622", "1632" } },
  1676. { DeviceFlags.桁架码垛位, new List<string>(){"1692","1693","1694","1695","1700","1701","1702","1703","1704","1705","1707","1708","1709","1710","1715","1716","1717","1718","1719","1720","1626","1636" } },
  1677. { DeviceFlags.环形库码垛工位, new List<string>(){"1691", "1696", "1706", "1711" } },
  1678. { DeviceFlags.AGV取货站台口, new List<string>(){"2934","2933","3133", "3134"} },
  1679. { DeviceFlags.Robot, new List<string>(){ "Robot3", "Robot4" } },
  1680. {DeviceFlags.二次码垛RGV取货口, new List<string>(){ "1626","1636"}}
  1681. };
  1682. }
  1683. if (WareHouses.Contains("FJ3"))
  1684. {
  1685. devices = new Dictionary<DeviceFlags, List<string>>
  1686. {
  1687. { DeviceFlags.一楼叠盘机,new List<string>() { "3327", "3328", "3527", "3528" } },
  1688. { DeviceFlags.桁架分流点,new List<string>() { "1255", "1455" } },
  1689. { DeviceFlags.桁架缓存放行点, new List<string>(){ "1266", "1280", "1294", "1308", "1322", "1336", "1350", "1364", "1378", "1391", "1466", "1480", "1494", "1508", "1522", "1536", "1550", "1564", "1578", "1591"} },
  1690. { DeviceFlags.桁架09缓存放行点, new List<string>(){ "1266", "1280", "1294", "1308", "1322", "1336", "1466", "1480", "1494", "1508", "1522", "1536" } },
  1691. { DeviceFlags.桁架09异常缓存放行点, new List<string>(){ "1391" , "1591" } },
  1692. { DeviceFlags.桁架18缓存放行点, new List<string>(){ "1350", "1364", "1378", "1550", "1564", "1578" } },
  1693. { DeviceFlags.桁架取货点, new List<string>(){"1261", "1275", "1289", "1303", "1317", "1331", "1345", "1359", "1373", "1386" , "1461", "1475", "1489", "1503", "1517", "1531", "1545", "1559", "1573", "1586" } },
  1694. { DeviceFlags.桁架18取货点, new List<string>(){ "545", "559", "573", "945", "959", "973", "1345", "1359", "1373", "745", "759", "773", "1145", "1159", "1173", "1545", "1559", "1573" } },
  1695. { DeviceFlags.拆盘机, new List<string>(){ "1642", "1652" } },
  1696. { DeviceFlags.桁架码垛位, new List<string>(){"1722","1723","1724","1725","1730","1731","1732","1733","1734","1735","1737","1738","1739","1740","1745","1746","1747","1748","1749","1750","1646","1656"} },
  1697. { DeviceFlags.环形库码垛工位, new List<string>(){"1721", "1726", "1736", "1741" } },
  1698. { DeviceFlags.AGV取货站台口, new List<string>(){"3333","3334","3533","3534"} },
  1699. { DeviceFlags.Robot, new List<string>(){ "Robot5", "Robot6" } },
  1700. {DeviceFlags.二次码垛RGV取货口, new List<string>(){ "1646","1656"}}
  1701. };
  1702. }
  1703. Parallel.ForEach(devices, device =>
  1704. {
  1705. Parallel.ForEach(device.Value, value =>
  1706. {
  1707. var dev = Device.All.FirstOrDefault(v => v.Code == value);
  1708. if (dev != null)
  1709. {
  1710. dev.AddFlag(device.Key);
  1711. }
  1712. });
  1713. });
  1714. #endregion 标签配置
  1715. }
  1716. /// <summary>
  1717. /// 初始化数据库连接
  1718. /// </summary>
  1719. /// <param name="datas"></param>
  1720. public static void InitDB(this List<DataBaseConnectionString> datas)
  1721. {
  1722. //初始化数据库
  1723. SqlSugarHelper.Do(db =>
  1724. {
  1725. foreach (var connectionString in datas!)
  1726. {
  1727. var _db = db.Connect.GetConnectionScope(connectionString.Key);
  1728. switch (connectionString.Key)
  1729. {
  1730. case "WCSDB"://WCS基本数据库
  1731. SqlSugarHelper.SetDefault(connectionString.Key);
  1732. //_db.CodeFirst.InitTables(typeof(WCS_PlcData));
  1733. //_db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
  1734. //_db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
  1735. //_db.CodeFirst.InitTables(typeof(WCS_TaskOld));
  1736. //_db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
  1737. //_db.CodeFirst.InitTables(typeof(WCS_Palletizing));
  1738. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
  1739. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
  1740. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
  1741. //_db.CodeFirst.InitTables(typeof(WCS_CacheLine));
  1742. //_db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
  1743. break;
  1744. case "WCSDlog"://WCS日志数据库
  1745. break;
  1746. case "PLC"://PLC
  1747. SqlSugarHelper.SetPLC(connectionString.Key);
  1748. //_db.DbMaintenance.CreateDatabase();
  1749. //_db.CodeFirst.InitTables<WCS_Log>();
  1750. //_db.CodeFirst.InitTables<WCS_SRM520>();
  1751. //_db.CodeFirst.InitTables<WCS_SRM521>();
  1752. //_db.CodeFirst.InitTables<WCS_SRM537>();
  1753. //_db.CodeFirst.InitTables<WCS_RGV520>();
  1754. //_db.CodeFirst.InitTables<WCS_RGV521>();
  1755. //_db.CodeFirst.InitTables<WCS_BCR80>();
  1756. //_db.CodeFirst.InitTables<WCS_BCR81>();
  1757. //_db.CodeFirst.InitTables<WCS_BCR83>();
  1758. //_db.CodeFirst.InitTables<WCS_Station520>();
  1759. //_db.CodeFirst.InitTables<WCS_Station521>();
  1760. //_db.CodeFirst.InitTables<WCS_Station523>();
  1761. //_db.CodeFirst.InitTables<WCS_Station524>();
  1762. //_db.CodeFirst.InitTables<WCS_Station525>();
  1763. //_db.CodeFirst.InitTables<WCS_Station90>();
  1764. //_db.CodeFirst.InitTables<WCS_Station91>();
  1765. //_db.CodeFirst.InitTables<WCS_Truss520>();
  1766. //_db.CodeFirst.InitTables<WCS_Truss521>();
  1767. //_db.CodeFirst.InitTables<WCS_Truss523>();
  1768. //_db.CodeFirst.InitTables<WCS_Truss530>();
  1769. //_db.CodeFirst.InitTables<WCS_Truss531>();
  1770. //_db.CodeFirst.InitTables<WCS_Robot520>();
  1771. //_db.CodeFirst.InitTables<WCS_Robot521>();
  1772. //_db.CodeFirst.InitTables<WCS_Robot522>();
  1773. //_db.CodeFirst.InitTables<WCS_Robot530>();
  1774. //_db.CodeFirst.InitTables<WCS_Robot531>();
  1775. //var a = false;
  1776. break;
  1777. default: //其他库
  1778. break;
  1779. };
  1780. };
  1781. });
  1782. }
  1783. }
  1784. public class DevDbConfig<T>
  1785. {
  1786. public DevDbConfig()
  1787. {
  1788. }
  1789. public DevDbConfig(string ip, T code)
  1790. {
  1791. IP = ip;
  1792. Code = code;
  1793. }
  1794. public DevDbConfig(string ip, List<DevInterval<T>> devIntervalList)
  1795. {
  1796. IP = ip;
  1797. DevIntervalList = devIntervalList;
  1798. }
  1799. public DevDbConfig(string ip, List<T> devCodeList)
  1800. {
  1801. IP = ip;
  1802. DevCodeList = devCodeList;
  1803. }
  1804. public string IP { get; set; }
  1805. public T Code { get; set; }
  1806. public T StartCode { get; set; }
  1807. public T EndCode { get; set; }
  1808. public List<T> DevCodeList { get; set; }
  1809. public List<DevInterval<T>> DevIntervalList { get; set; }
  1810. }
  1811. public class DevInterval<T>
  1812. {
  1813. public DevInterval(T s, T e)
  1814. {
  1815. StartCode = s;
  1816. EndCode = e;
  1817. }
  1818. public T StartCode { get; set; }
  1819. public T EndCode { get; set; }
  1820. }
  1821. }