WorkStart.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. using PlcSiemens.Core.Extension;
  2. using ServiceCenter;
  3. using WCS.Core;
  4. using WCS.WorkEngineering.Extensions;
  5. using WCS.WorkEngineering.Protocol.BCR;
  6. using WCS.WorkEngineering.Protocol.RGV;
  7. using WCS.WorkEngineering.Protocol.SRM;
  8. using WCS.WorkEngineering.Protocol.Station;
  9. using WCS.WorkEngineering.Protocol.Truss;
  10. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  11. namespace WCS.WorkEngineering
  12. {
  13. /// <summary>
  14. /// 业务工程配置信息
  15. /// </summary>
  16. public static class WorkStart
  17. {
  18. /// <summary>
  19. /// 初始化 设备信息
  20. /// </summary>
  21. public static void InitializeDeviceInfo()
  22. {
  23. #region 设置设备IP集合
  24. ServiceHub.DeviceIPList = new List<string>() { "10.30.43.90" };
  25. #endregion 设置设备IP集合
  26. #region 初始化输送机相关信息
  27. #region 基本信息
  28. #region 库尾输送线
  29. List<StationSegmentInfo> segmentInfo = new List<StationSegmentInfo>
  30. {
  31. new StationSegmentInfo(8271, 8279, "10.30.43.90"),
  32. new StationSegmentInfo(8161, 8270, "10.30.43.93")
  33. };
  34. foreach (var item in segmentInfo)
  35. {
  36. for (int i = item.Start; i <= item.End; i++)
  37. {
  38. var conv = new Device(i.ToString());
  39. conv.AddFlag(DeviceFlags.输送机);
  40. conv.AddProtocol<IStation520>((i - item.Start) * 14, 520, item.IP);
  41. conv.AddProtocol<IStation521>((i - item.Start) * 16, 521, item.IP);
  42. conv.AddProtocol<IStation523>((i - item.Start) * 12, 523, item.IP);
  43. }
  44. }
  45. #endregion 库尾输送线
  46. #endregion 基本信息
  47. #region 托盘线扫码器
  48. List<BcrInfo> bcrInfo = new List<BcrInfo>
  49. {
  50. new BcrInfo(new int[] {8277}, "10.30.43.90"),
  51. new BcrInfo(new int[] {8270}, "10.30.43.93")
  52. };
  53. foreach (var item in bcrInfo)
  54. {
  55. for (int i = 0; i < item.DeviceNo.Length; i++)
  56. {
  57. var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i].ToString());
  58. device.AddFlag(DeviceFlags.扫码);
  59. int pos = i * 20;
  60. device.AddProtocol<IBCR81>(pos, 81, item.IP);
  61. }
  62. }
  63. #endregion 托盘线扫码器
  64. #region 外检信息
  65. //要按先后顺序,后面添加外检要注意
  66. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  67. { new ShapeInfo(new int[] { 8277 }, "10.30.43.90"),
  68. new ShapeInfo(new int[] { 8270 }, "10.30.43.93") };
  69. foreach (var item in shapeInfo)
  70. {
  71. for (int i = 0; i < item.DeviceNo.Length; i++)
  72. {
  73. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  74. conv.AddFlag(DeviceFlags.外检);
  75. int pos = i * 14;
  76. conv.AddProtocol<IStation91>(pos, 91, item.IP);
  77. }
  78. }
  79. #endregion 外检信息
  80. #endregion 初始化输送机相关信息
  81. #region 初始化RGV相关信息
  82. List<RGVSegmentInfo> RgvInfo = new List<RGVSegmentInfo>
  83. {
  84. //new RGVSegmentInfo( 1, "10.30.37.113"),
  85. //new RGVSegmentInfo( 2, "10.30.37.118"),
  86. //new RGVSegmentInfo( 3, "10.30.37.123"),
  87. //new RGVSegmentInfo( 4, "10.30.37.128"),
  88. //new RGVSegmentInfo( 5, "10.30.37.133"),
  89. //new RGVSegmentInfo( 6, "10.30.37.138")
  90. };
  91. foreach (var item in RgvInfo)
  92. {
  93. var conv = new Device($"RGV{item.Code}");
  94. conv.AddFlag(DeviceFlags.RGV);
  95. conv.AddProtocol<IRGV520>(0, 520, item.IP);
  96. conv.AddProtocol<IRGV521>(0, 521, item.IP);
  97. //conv.AddProtocol<IStation523>(, 523, item.IP);
  98. }
  99. #endregion 初始化RGV相关信息
  100. #region 初始化堆垛机相关信息
  101. int ip = 21;
  102. for (int i = 0; i <= 1; i++)
  103. {
  104. var srm = new Device($"SRM{i + 1}");
  105. srm.AddFlag(DeviceFlags.堆垛机);
  106. ip = i == 0 ? ip : ip + 10;
  107. srm.AddProtocol<ISRM520>(0, 520, $"10.30.43.{ip}");
  108. srm.AddProtocol<ISRM521>(0, 521, $"10.30.43.{ip}");
  109. srm.AddProtocol<ISRM537>(0, 537, $"10.30.43.{ip}");
  110. //增加巷道
  111. var tunnel = new Device($"TY{i + 1}");
  112. tunnel.AddFlag(DeviceFlags.巷道);
  113. }
  114. #endregion 初始化堆垛机相关信息
  115. #region 配置路径信息
  116. List<RouteInfo> routeInfos = new List<RouteInfo>
  117. {
  118. new RouteInfo("SRM1", new string[] { "TY1" }),
  119. new RouteInfo("SRM2", new string[] { "TY2" }),
  120. new RouteInfo("SRM3", new string[] { "TY3" }),
  121. new RouteInfo("SRM4", new string[] { "TY4" }),
  122. new RouteInfo("SRM5", new string[] { "TY5" }),
  123. new RouteInfo("TY1", new string[] { "SRM1" }),
  124. new RouteInfo("TY2", new string[] { "SRM2" }),
  125. new RouteInfo("TY3", new string[] { "SRM3" }),
  126. new RouteInfo("TY4", new string[] { "SRM4" }),
  127. new RouteInfo("TY5", new string[] { "SRM5" }),
  128. //入
  129. new RouteInfo("TY1", new string[] { "8271" ,"8250"}),
  130. new RouteInfo("TY2", new string[] { "8272" ,"8249"}),
  131. new RouteInfo("TY3", new string[] { "8273" ,"8246"}),
  132. new RouteInfo("TY4", new string[] { "8274" ,"8244"}),
  133. new RouteInfo("TY5", new string[] { "8275" ,"8243"}),
  134. //出
  135. new RouteInfo("8271", new string[] { "TY1" }),
  136. new RouteInfo("8272", new string[] { "TY2" }),
  137. new RouteInfo("8273", new string[] { "TY3" }),
  138. new RouteInfo("8274", new string[] { "TY4" }),
  139. new RouteInfo("8275", new string[] { "TY5" }),
  140. new RouteInfo("8251", new string[] { "TY1" }),
  141. new RouteInfo("8248", new string[] { "TY2" }),
  142. new RouteInfo("8247", new string[] { "TY3" }),
  143. new RouteInfo("8245", new string[] { "TY4" }),
  144. new RouteInfo("8242", new string[] { "TY5" }),
  145. //new RouteInfo("8271", new string[] { "8278" }),
  146. //new RouteInfo("8272", new string[] { "8278" }),
  147. //new RouteInfo("8273", new string[] { "8278" }),
  148. //new RouteInfo("8274", new string[] { "8278" }),
  149. //new RouteInfo("8275", new string[] { "8278" }),
  150. };
  151. foreach (var item in routeInfos)
  152. {
  153. var device = Device.All.FirstOrDefault(x => x.Code == item.DeviceCode);
  154. device.AddTarget(item.NextList);
  155. foreach (var next in item.NextList)
  156. {
  157. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  158. dev.Parent = device;
  159. }
  160. }
  161. #endregion 配置路径信息
  162. #region 标签配置
  163. Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>
  164. {
  165. { DeviceFlags.入库, new List<string>() { "8271", "8272", "8273", "8274", "8275", "8250", "8249", "8246", "8244", "8243"} },
  166. { DeviceFlags.出库, new List<string>() { "8271", "8272", "8273", "8274", "8275" } },
  167. { DeviceFlags.扫码, new List<string>() {"8277"} },
  168. { DeviceFlags.出库口, new List<string>() { "8271","8272", "8273", "8274", "8275" } },
  169. { DeviceFlags.出货口, new List<string>() { "8263", "8257", "8269" } }
  170. };
  171. devices.ForEach(item =>
  172. {
  173. item.Value.ForEach(code =>
  174. {
  175. var device = Device.All.FirstOrDefault(v => v.Code == code);
  176. device.AddFlag(item.Key);
  177. });
  178. });
  179. #endregion 标签配置
  180. }
  181. }
  182. }