WorkStart.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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.BCR;
  7. using WCS.Entity.Protocol.RGV;
  8. using WCS.Entity.Protocol.Robot;
  9. using WCS.Entity.Protocol.SRM;
  10. using WCS.Entity.Protocol.Station;
  11. using WCS.Entity.Protocol.Truss;
  12. using WCS.WorkEngineering.Extensions;
  13. using WCS.WorkEngineering.Systems;
  14. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  15. namespace WCS.WorkEngineering
  16. {
  17. /// <summary>
  18. /// 业务工程配置信息
  19. /// </summary>
  20. public static class WorkStart
  21. {
  22. /// <summary>
  23. /// 初始化 设备信息
  24. /// </summary>
  25. public static void InitializeDeviceInfo()
  26. {
  27. #region 无交互触发设备
  28. var devs = new List<string>() { nameof(分线计算09), nameof(桁架码垛区补空托盘任务生成), "出库AGV", "入库AGV", nameof(NoInteractionSystems) };
  29. foreach (var conv in devs.Select(code => new Device(code)))
  30. {
  31. conv.AddProtocol<IStation520>(0, 520, "1");
  32. }
  33. #endregion 无交互触发设备
  34. #region 设置设备IP集合
  35. ServiceHub.DeviceIPList = new List<string>() { };
  36. #endregion 设置设备IP集合
  37. #region 初始化RGV相关信息
  38. List<RgvSegmentInfo> RgvInfo = new List<RgvSegmentInfo>
  39. {
  40. new RgvSegmentInfo( 1, "10.30.37.113"),
  41. new RgvSegmentInfo( 2, "10.30.37.118"),
  42. //new RgvSegmentInfo( 3, "10.30.37.123"),
  43. //new RgvSegmentInfo( 4, "10.30.37.128"),
  44. //new RgvSegmentInfo( 5, "10.30.37.133"),
  45. //new RgvSegmentInfo( 6, "10.30.37.138")
  46. };
  47. foreach (var item in RgvInfo)
  48. {
  49. var conv = new Device($"RGV{item.Code}");
  50. conv.AddFlag(DeviceFlags.RGV);
  51. conv.AddProtocol<IRGV520>(0, 520, item.Ip);
  52. conv.AddProtocol<IRGV521>(0, 521, item.Ip);
  53. //conv.AddProtocol<IStation523>(, 523, item.IP);
  54. }
  55. #endregion 初始化RGV相关信息
  56. #region 初始化输送机相关信息
  57. #region 基本信息
  58. #region 托盘线输送线
  59. var tuples = new List<Tuple<string, List<Tuple<int, int>>>>
  60. {
  61. new("10.30.37.89",new List<Tuple<int, int>>()
  62. {
  63. new(1601, 1620),
  64. new(2501, 2540),
  65. new(2701, 2740),
  66. new(1661, 1690),
  67. })
  68. };
  69. foreach (var item in tuples)
  70. {
  71. var db520 = 0;
  72. var db521 = 0;
  73. var db523 = 0;
  74. foreach (var item1 in item.Item2)
  75. {
  76. for (var i = item1.Item1; i <= item1.Item2; i++)
  77. {
  78. var conv = new Device(i.ToString());
  79. conv.AddFlag(DeviceFlags.输送机);
  80. conv.AddProtocol<IStation520>(db520, 520, item.Item1);
  81. conv.AddProtocol<IStation521>(db521, 521, item.Item1);
  82. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  83. db520 += 14;
  84. db521 += 16;
  85. db523 += 12;
  86. }
  87. }
  88. }
  89. #endregion 托盘线输送线
  90. #region 满轮输送线
  91. #region DB523,所有线体都会有DB523
  92. var mLtuples523 = new List<Tuple<string, List<Tuple<int, int>>>>()
  93. {
  94. new("10.30.37.166",new List<Tuple<int, int>>()
  95. {
  96. new(1, 100),
  97. new(1001, 1010),
  98. new(401, 599),
  99. }),
  100. new("10.30.37.198",new List<Tuple<int, int>>()
  101. {
  102. new(101, 210),
  103. new(601, 799),
  104. })
  105. };
  106. foreach (var item in mLtuples523)
  107. {
  108. var db523 = 0;
  109. var db524 = 0;
  110. foreach (var item1 in item.Item2)
  111. {
  112. for (var i = item1.Item1; i <= item1.Item2; i++)
  113. {
  114. var conv = new Device(i.ToString());
  115. conv.AddFlag(DeviceFlags.输送机);
  116. conv.AddProtocol<IStation523>(db523, 523, item.Item1);
  117. conv.AddProtocol<IStation524>(db524, 524, item.Item1);
  118. db523 += 12;
  119. db524 += 16;
  120. }
  121. }
  122. }
  123. #endregion DB523,所有线体都会有DB523
  124. #region 520、521 交互线体会有520、521
  125. //Item2表示线体号集合,Item1表示IP
  126. var mLTuples520 = new List<Tuple<string, List<int>>>()
  127. {
  128. 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}),
  129. 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})
  130. };
  131. foreach (var item in mLTuples520)
  132. {
  133. var db520 = 0;
  134. var db521 = 0;
  135. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  136. {
  137. if (device != null)
  138. {
  139. device.AddProtocol<IStation520>(db520, 520, item.Item1);
  140. device.AddProtocol<IStation521>(db521, 521, item.Item1);
  141. }
  142. db520 += 14;
  143. db521 += 16;
  144. }
  145. }
  146. #endregion 520、521 交互线体会有520、521
  147. #region 满轮扫码器
  148. //Item2表示线体号集合,Item1表示IP
  149. var mLTuples83 = new List<Tuple<string, List<int>>>()
  150. {
  151. new("10.30.37.166",new List<int>(){1,22,41,61,18}) ,
  152. new("10.30.37.198",new List<int>(){101,122,141,161,118,})
  153. };
  154. foreach (var item in mLTuples83)
  155. {
  156. var db83 = 0;
  157. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  158. {
  159. device?.AddProtocol<IBCR83>(db83, 83, item.Item1);
  160. db83 += 604;
  161. }
  162. }
  163. #endregion 满轮扫码器
  164. #region 满轮线告诉分拣预分配
  165. //Item2表示线体号集合,Item1表示IP
  166. var mLTuples525 = new List<Tuple<string, List<int>>>()
  167. {
  168. new("10.30.37.166",new List<int>(){18}),
  169. new("10.30.37.198",new List<int>(){118}),
  170. };
  171. foreach (var item in mLTuples525)
  172. {
  173. var db525 = 0;
  174. foreach (var device in item.Item2.Select(item1 => Device.All.FirstOrDefault(v => v.Code == item1.ToString())))
  175. {
  176. device?.AddProtocol<IStation525>(db525, 525, item.Item1);
  177. db525 += 3266;
  178. }
  179. }
  180. #endregion 满轮线告诉分拣预分配
  181. #region 外检信息
  182. //Item2表示线体号集合,Item1表示IP
  183. var mLTuples91 = new List<Tuple<string, List<int>>>()
  184. {
  185. new("10.30.37.166",new List<int>(){418}),
  186. new("10.30.37.166",new List<int>(){618})
  187. };
  188. foreach (var item in mLTuples91)
  189. {
  190. var db91 = 0;
  191. foreach (var device in item.Item2.Select(item2 => Device.All.FirstOrDefault(v => v.Code == item2.ToString())))
  192. {
  193. device?.AddProtocol<IStation91>(db91, 91, item.Item1);
  194. db91 += 14;
  195. }
  196. }
  197. #endregion 外检信息
  198. #endregion 满轮输送线
  199. #endregion 基本信息
  200. #region 托盘线扫码器
  201. var bcrInfo = new List<BcrInfo>
  202. {
  203. new(new [] { "2532", "2732" }, "10.30.37.89"),
  204. new(new [] {"RGV1"},"10.30.37.113")
  205. };
  206. foreach (var item in bcrInfo)
  207. {
  208. for (var i = 0; i < item.DeviceNo.Length; i++)
  209. {
  210. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i]);
  211. device.AddFlag(DeviceFlags.扫码);
  212. var pos = i * 20;
  213. device.AddProtocol<IBCR81>(pos, 81, item.Ip);
  214. }
  215. }
  216. #endregion 托盘线扫码器
  217. #region 外检信息
  218. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  219. {
  220. new ShapeInfo(new int[] { 2732,2532 }, "10.30.37.89")
  221. };
  222. foreach (var item in shapeInfo)
  223. {
  224. for (int i = 0; i < item.DeviceNo.Length; i++)
  225. {
  226. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  227. conv.AddFlag(DeviceFlags.外检);
  228. int pos = i * 14;
  229. conv.AddProtocol<IStation91>(pos, 91, item.Ip);
  230. }
  231. }
  232. #endregion 外检信息
  233. #endregion 初始化输送机相关信息
  234. #region 初始化桁架相关信息
  235. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  236. {
  237. new TrussSegmentInfo( 1, "10.30.37.211"),
  238. };
  239. foreach (var item in TrussInfo)
  240. {
  241. var conv = new Device($"Truss{item.Code}");
  242. conv.AddFlag(DeviceFlags.桁架);
  243. conv.AddProtocol<ITruss520>(0, 520, item.Ip);
  244. conv.AddProtocol<ITruss521>(0, 521, item.Ip);
  245. conv.AddProtocol<ITruss523>(0, 523, item.Ip);
  246. }
  247. var tuples1 = new List<Tuple<string, List<int>>>
  248. {
  249. //桁架
  250. //new("10.30.37.211",new List<int>(){1662,1663,1664,1665,1670,1671,1672,1673,1674,1675,1677,1678,1679,1680,1685,1686,1687,1688,1689,1690}),
  251. 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}),
  252. //机械臂
  253. new("10.30.37.230",new List<int>(){ 1666, 1661}),
  254. };
  255. foreach (var item in tuples1)
  256. {
  257. var db530 = 0;
  258. var db531 = 0;
  259. foreach (var conv in item.Item2.Select(item1 => Device.All.FirstOrDefault(x => x.Code == item1.ToString())))
  260. {
  261. if (item.Item1 == "10.30.37.211")
  262. {
  263. conv!.AddProtocol<ITruss530>(db530, 530, item.Item1);
  264. conv!.AddProtocol<ITruss531>(db531, 531, item.Item1);
  265. db530 += 8;
  266. db531 += 250;
  267. }
  268. else
  269. {
  270. conv!.AddProtocol<IRobot530>(db530, 530, item.Item1);
  271. conv!.AddProtocol<IRobot531>(db531, 531, item.Item1);
  272. db530 += 8;
  273. db531 += 130;
  274. }
  275. }
  276. }
  277. #endregion 初始化桁架相关信息
  278. #region 初始化机械臂相关信息
  279. List<TrussSegmentInfo> TrussInfo1 = new List<TrussSegmentInfo>
  280. {
  281. new TrussSegmentInfo( 1, "10.30.37.230"),
  282. };
  283. foreach (var item in TrussInfo1)
  284. {
  285. var conv = new Device($"Robot{item.Code}");
  286. conv.AddFlag(DeviceFlags.Robot);
  287. conv.AddProtocol<IRobot520>(0, 520, item.Ip);
  288. conv.AddProtocol<IRobot521>(0, 521, item.Ip);
  289. conv.AddProtocol<IRobot522>(0, 522, item.Ip);
  290. //conv.AddProtocol<IRobot530>(0, 521, item.Ip);
  291. //conv.AddProtocol<IRobot531>(0, 522, item.Ip);
  292. }
  293. #endregion 初始化机械臂相关信息
  294. #region 初始化堆垛机相关信息
  295. int ip = 41;
  296. for (int i = 0; i <= 1; i++)
  297. {
  298. var srm = new Device($"SRM{i + 1}");
  299. srm.AddFlag(DeviceFlags.堆垛机);
  300. ip = i == 0 ? ip : ip + 8;
  301. //三台堆垛机IP主机位分别是 41、49、57、65、73、81
  302. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  303. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  304. srm.AddProtocol<ISRM537>(0, 537, $"10.30.37.{ip}");
  305. //增加巷道
  306. var tunnel = new Device($"TY{i + 1}");
  307. tunnel.AddFlag(DeviceFlags.巷道);
  308. }
  309. #endregion 初始化堆垛机相关信息
  310. #region 配置路径信息
  311. List<RouteInfo> routeInfos = new List<RouteInfo>();
  312. #region 分拣库一
  313. routeInfos.AddRange(new List<RouteInfo>() {
  314. #region 出库路径
  315. //堆垛机--巷道
  316. new RouteInfo("SRM1", new string[] { "TY1" }),
  317. new RouteInfo("SRM2", new string[] { "TY2" }),
  318. //巷道--一楼堆垛机放货口
  319. new RouteInfo("TY1", new string[] { "2532" }), //人工取货口
  320. new RouteInfo("TY2", new string[] { "2732" }),
  321. new RouteInfo("TY1", new string[] { "2534","2533" }),//AGV取货口
  322. new RouteInfo("TY2", new string[] { "2734","2733" }),
  323. //巷道--二楼堆垛机放货口
  324. new RouteInfo("TY1", new string[] { "1601","1605" }),
  325. new RouteInfo("TY2", new string[] { "1611","1615" }),
  326. //二楼堆垛机放货口--二楼拆盘机
  327. new RouteInfo("1601", new string[] { "1602" }),//非09拆盘机
  328. new RouteInfo("1611", new string[] { "1612"}),
  329. new RouteInfo("1605", new string[] { "1606" }),//09拆盘机
  330. new RouteInfo("1615", new string[] { "1616" }),
  331. //二楼拆盘机--RGV
  332. new RouteInfo("1602", new string[] { "RGV1" }),//非09拆盘机
  333. //new RouteInfo("1612", new string[] { "RGV2"}),
  334. new RouteInfo("1606", new string[] { "RGV1" }),//09拆盘机
  335. //new RouteInfo("1616", new string[] { "RGV2" }),
  336. //RGV--码垛区域
  337. new RouteInfo("RGV1", new string[] { "1661","1666" }),//北区机械臂码垛区
  338. //new RouteInfo("RGV2", new string[] { }),//南区机械臂
  339. new RouteInfo("RGV1", new string[] { "1662","1663","1664","1665", "1670","1671","1672","1673","1674","1675"}),//桁架北区码垛站台
  340. //new RouteInfo("RGV2", new string[] { }),//南区桁架
  341. //Robot码垛工位
  342. new RouteInfo("Robot1", new string[] { "1666" }),
  343. new RouteInfo("Robot1", new string[] { "1661" }),
  344. #endregion 出库路径
  345. #region 入库
  346. //一楼人工入库口-巷道
  347. new RouteInfo("2532", new string[] { "TY1" }),
  348. new RouteInfo("2732", new string[] { "TY2" }),
  349. //一楼叠盘机(堆垛机入口)--巷道
  350. new RouteInfo("2527", new string[] { "TY1" }),
  351. new RouteInfo("2528", new string[] { "TY1" }),
  352. new RouteInfo("2727", new string[] { "TY2" }),
  353. new RouteInfo("2728", new string[] { "TY2" }),
  354. //一楼AGV入口
  355. //主线入口--预分配点
  356. new RouteInfo("1", new string[] { "18" }),
  357. new RouteInfo("101", new string[] { "118" }),
  358. //预分配点--主线分流点
  359. new RouteInfo("18", new string[] { "22" }),
  360. new RouteInfo("118", new string[] { "122" }),
  361. //主线分流点--环形库分流点
  362. new RouteInfo("22", new string[] { "418" }),
  363. new RouteInfo("122", new string[] { "618" }),
  364. //环形库分流点--环形库取货点
  365. new RouteInfo("418", new string[] { "424","433","442" }),
  366. //环形库分流点--桁架分流点
  367. new RouteInfo("418", new string[] { "455" }),
  368. //桁架分流点--桁架缓存放行点
  369. new RouteInfo("455", new string[] { "466","480","494","508", "522","536","550","564","578"}),
  370. //桁架分流点--异常缓存放行点
  371. new RouteInfo("455", new string[] { "491" }),
  372. //桁架缓存放行点--桁架取货点
  373. new("466", new[] { "461" }),
  374. new("480", new[] { "475" }),
  375. new("494", new[] { "489" }),
  376. new("508", new[] { "503" }),
  377. new("522", new[] { "517" }),
  378. new("536", new[] { "531" }),
  379. new("550", new[] { "545" }),
  380. new("564", new[] { "559" }),
  381. new("578", new[] { "573" }),
  382. //桁架取货点--桁架
  383. new("461", new[] { "Truss1" }),
  384. new("475", new[] { "Truss1" }),
  385. new("489", new[] { "Truss1" }),
  386. new("503", new[] { "Truss1" }),
  387. new("517", new[] { "Truss1" }),
  388. new("531", new[] { "Truss1" }),
  389. new("545", new[] { "Truss1" }),
  390. new("559", new[] { "Truss1" }),
  391. new("573", new[] { "Truss1" }),
  392. //桁架--码垛工位
  393. new("Truss1", new[] { "1662" }),
  394. new("Truss1", new[] { "1663" }),
  395. new("Truss1", new[] { "1664" }),
  396. new("Truss1", new[] { "1665" }),
  397. new("Truss1", new[] { "1670" }),
  398. new("Truss1", new[] { "1671" }),
  399. new("Truss1", new[] { "1672" }),
  400. new("Truss1", new[] { "1673" }),
  401. new("Truss1", new[] { "1674" }),
  402. new("Truss1", new[] { "1675" }),
  403. //码垛工位--RGV
  404. new RouteInfo("1661", new string[] { "RGV1" }),//机械手码垛工位
  405. new RouteInfo("1666", new string[] { "RGV1" }),
  406. new RouteInfo("1662", new string[] { "RGV1" }),//绗架码垛工位
  407. new RouteInfo("1663", new string[] { "RGV1" }),
  408. new RouteInfo("1664", new string[] { "RGV1" }),
  409. new RouteInfo("1665", new string[] { "RGV1" }),
  410. new RouteInfo("1670", new string[] { "RGV1" }),
  411. new RouteInfo("1671", new string[] { "RGV1" }),
  412. new RouteInfo("1672", new string[] { "RGV1" }),
  413. new RouteInfo("1673", new string[] { "RGV1" }),
  414. new RouteInfo("1674", new string[] { "RGV1" }),
  415. new RouteInfo("1675", new string[] { "RGV1" }),
  416. //RGV--RGV放货点
  417. new RouteInfo("RGV1", new string[] { "1604" }),
  418. //RGV放货点--堆垛机取货口
  419. new RouteInfo("1604", new string[] { "1603" }),//北侧
  420. //二楼堆垛机入库--巷道
  421. new RouteInfo("1603", new string[] { "TY1" }),//北侧
  422. new RouteInfo("1613", new string[] { "TY2" }),//南侧
  423. //巷道--堆垛机
  424. new RouteInfo("TY1", new string[] { "SRM1" }),
  425. new RouteInfo("TY2", new string[] { "SRM2" }),
  426. //线体取货位--Robot
  427. new RouteInfo("442", new string[] { "Robot1" }),
  428. new RouteInfo("433", new string[] { "Robot1" }),
  429. new RouteInfo("424", new string[] { "Robot1" }),
  430. #endregion 入库
  431. });
  432. #endregion 分拣库一
  433. foreach (var item in routeInfos)
  434. {
  435. var device = Device.All.FirstOrDefault(x => x.Code == item.DeviceCode);
  436. device.AddTarget(item.NextList);
  437. foreach (var next in item.NextList)
  438. {
  439. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  440. dev.Parent = device;
  441. }
  442. }
  443. #endregion 配置路径信息
  444. #region 添加设备组
  445. var tuples2 = new List<Tuple<string, List<string>>>()
  446. {
  447. //环形库一北侧机械手取货位
  448. new("424",new List<string> {"424","425"}),
  449. new("433",new List<string> {"433","434"}),
  450. new("442",new List<string> {"442","443"}),
  451. //new("624",new List<string> {"624","625"}),
  452. //new("633",new List<string> {"633","634"}),
  453. //new("642",new List<string> {"642","643"})
  454. };
  455. foreach (var item in tuples2)
  456. {
  457. var device = Device.All.FirstOrDefault(x => x.Code == item.Item1);
  458. device.AddDeviceGroup(item.Item2.ToArray());
  459. }
  460. #endregion 添加设备组
  461. #region 标签配置
  462. Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>
  463. {
  464. { DeviceFlags.入库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734","1603" } },
  465. { DeviceFlags.出库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
  466. { DeviceFlags.扫码, new List<string>() { "2532", "2732" } },
  467. { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
  468. { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
  469. { DeviceFlags.一楼扫码,new List<string>(){ "2532","2732"} },
  470. { DeviceFlags.一楼叠盘机,new List<string>() { "2527","2528","2727","2728"} },
  471. { DeviceFlags.主线分流点,new List<string>() { "22","41","61"} },
  472. { DeviceFlags.满轮主线第一次扫码,new List<string>() { "1"} },
  473. { DeviceFlags.环形库分流点,new List<string>(){ "418"} },
  474. { DeviceFlags.桁架分流点,new List<string>() { "455" } },
  475. { DeviceFlags.桁架缓存放行点, new List<string>(){ "466", "480", "494", "508","522","536" } },
  476. { DeviceFlags.桁架取货点, new List<string>(){ "461", "475", "489", "503","517","531" } },
  477. { DeviceFlags.拆盘机09, new List<string>(){ "1606" } },
  478. { DeviceFlags.拆盘机非09, new List<string>(){ "1602" } },
  479. { DeviceFlags.桁架码垛位, new List<string>(){ "1670", "1671", "1672", "1673", "1674", "1675","1664","1662","1665" } },
  480. { DeviceFlags.环形库码垛工位, new List<string>(){ "1666"/*,"1661"*/ } },
  481. { DeviceFlags.AGV取货站台口, new List<string>(){ "2533", "2534", "2734" } },
  482. { DeviceFlags.Robot, new List<string>(){ "Robot1" } },
  483. };
  484. devices.ForEach(item =>
  485. {
  486. item.Value.ForEach(code =>
  487. {
  488. var device = Device.All.FirstOrDefault(v => v.Code == code);
  489. device.AddFlag(item.Key);
  490. });
  491. });
  492. #endregion 标签配置
  493. }
  494. /// <summary>
  495. /// 初始化数据库连接
  496. /// </summary>
  497. /// <param name="datas"></param>
  498. public static void InitDB(this List<DataBaseConnectionString> datas)
  499. {
  500. //初始化数据库
  501. SqlSugarHelper.Do(db =>
  502. {
  503. foreach (var connectionString in datas!)
  504. {
  505. var _db = db.Connect.GetConnectionScope(connectionString.Key);
  506. switch (connectionString.Key)
  507. {
  508. case "WCSDB"://WCS基本数据库
  509. SqlSugarHelper.SetDefault(connectionString.Key);
  510. _db.CodeFirst.InitTables(typeof(WCS_PlcData));
  511. _db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
  512. _db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
  513. _db.CodeFirst.InitTables(typeof(WCS_TaskOld));
  514. _db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
  515. _db.CodeFirst.InitTables(typeof(WCS_Palletizing));
  516. _db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
  517. _db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
  518. _db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
  519. _db.CodeFirst.InitTables(typeof(WCS_CacheLine));
  520. _db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
  521. break;
  522. case "WCSDlog"://WCS日志数据库
  523. break;
  524. default: //其他库
  525. break;
  526. };
  527. };
  528. });
  529. }
  530. }
  531. }