WorkStart.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using PlcSiemens.Core.Extension;
  2. using ServiceCenter;
  3. using WCS.Core;
  4. using WCS.Entity.Protocol.Station;
  5. using WCS.WorkEngineering.Extensions;
  6. using WCS.WorkEngineering.Protocol.BCR;
  7. using WCS.WorkEngineering.Protocol.RGV;
  8. using WCS.WorkEngineering.Protocol.SRM;
  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>() { };
  25. #endregion 设置设备IP集合
  26. #region 初始化输送机相关信息
  27. #region 基本信息
  28. List<StationSegmentInfo> segmentInfo = new List<StationSegmentInfo>
  29. {
  30. new StationSegmentInfo(2701, 2734, "10.30.37.89"),
  31. new StationSegmentInfo(2501, 2534, "10.30.37.89"),
  32. new StationSegmentInfo(1611, 1616, "10.30.37.89"),
  33. new StationSegmentInfo(1601, 1606, "10.30.37.89")
  34. };
  35. foreach (var item in segmentInfo)
  36. {
  37. for (int i = item.Start; i <= item.End; i++)
  38. {
  39. var conv = new Device(i.ToString());
  40. conv.AddFlag(DeviceFlags.输送机);
  41. conv.AddProtocol<IStation520>((i - item.Start) * 14, 520, item.IP);
  42. conv.AddProtocol<IStation521>((i - item.Start) * 16, 521, item.IP);
  43. conv.AddProtocol<IStation523>((i - item.Start) * 12, 523, item.IP);
  44. }
  45. }
  46. #endregion 基本信息
  47. #region 扫码器
  48. List<BcrInfo> bcrInfo = new List<BcrInfo>
  49. {
  50. new BcrInfo(new int[] { }, "10.30.37.89")
  51. };
  52. foreach (var item in bcrInfo)
  53. {
  54. for (int i = 0; i < item.DeviceNo.Length; i++)
  55. {
  56. var conv = new Device("BCR" + item.DeviceNo[i]);
  57. conv.AddFlag(DeviceFlags.扫码);
  58. int pos = i * 20;
  59. conv.AddProtocol<IBCR81>(pos, 81, item.IP);
  60. }
  61. }
  62. #endregion 扫码器
  63. #region 外检信息
  64. List<ShapeInfo> shapeInfo = new List<ShapeInfo>
  65. {
  66. new ShapeInfo(new int[] { }, "10.30.37.89")
  67. };
  68. foreach (var item in shapeInfo)
  69. {
  70. for (int i = 0; i < item.DeviceNo.Length; i++)
  71. {
  72. var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
  73. conv.AddFlag(DeviceFlags.外检);
  74. int pos = i * 14;
  75. conv.AddProtocol<IStation91>(pos, 91, item.IP);
  76. }
  77. }
  78. #endregion 外检信息
  79. #endregion 初始化输送机相关信息
  80. #region 初始化RGV相关信息
  81. List<RGVSegmentInfo> RgvInfo = new List<RGVSegmentInfo>
  82. {
  83. new RGVSegmentInfo( 1, "10.30.37.113"),
  84. new RGVSegmentInfo( 2, "10.30.37.118"),
  85. new RGVSegmentInfo( 3, "10.30.37.123"),
  86. new RGVSegmentInfo( 4, "10.30.37.128"),
  87. new RGVSegmentInfo( 5, "10.30.37.133"),
  88. new RGVSegmentInfo( 6, "10.30.37.138")
  89. };
  90. foreach (var item in RgvInfo)
  91. {
  92. var conv = new Device($"RGV{item.Code}");
  93. conv.AddFlag(DeviceFlags.RGV);
  94. conv.AddProtocol<IRGV520>(0, 520, item.IP);
  95. conv.AddProtocol<IRGV521>(0, 521, item.IP);
  96. //conv.AddProtocol<IStation523>(, 523, item.IP);
  97. }
  98. #endregion 初始化RGV相关信息
  99. #region 初始化桁架相关信息
  100. List<TrussSegmentInfo> TrussInfo = new List<TrussSegmentInfo>
  101. {
  102. new TrussSegmentInfo( 1, "10.30.37.211"),
  103. };
  104. foreach (var item in TrussInfo)
  105. {
  106. var conv = new Device($"Truss{item.Code}");
  107. conv.AddFlag(DeviceFlags.桁架);
  108. conv.AddProtocol<ITruss520>(0, 520, item.IP);
  109. conv.AddProtocol<ITruss521>(0, 521, item.IP);
  110. conv.AddProtocol<ITruss523>(0, 523, item.IP);
  111. conv.AddProtocol<ITruss530>(0, 530, item.IP);
  112. conv.AddProtocol<ITruss531>(0, 531, item.IP);
  113. }
  114. #endregion 初始化桁架相关信息
  115. #region 初始化堆垛机相关信息
  116. int ip = 41;
  117. for (int i = 0; i <= 1; i++)
  118. {
  119. var srm = new Device($"SRM{i + 1}");
  120. srm.AddFlag(DeviceFlags.堆垛机);
  121. ip = i == 0 ? ip : ip + 8;
  122. //三台堆垛机IP主机位分别是 21 31 41
  123. srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
  124. srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
  125. srm.AddProtocol<ISRM537>(0, 537, $"10.30.37.{ip}");
  126. //增加巷道
  127. var tunnel = new Device($"TY{i + 1}");
  128. tunnel.AddFlag(DeviceFlags.巷道);
  129. }
  130. #endregion 初始化堆垛机相关信息
  131. #region 配置路径信息
  132. List<RouteInfo> routeInfos = new List<RouteInfo>
  133. {
  134. ////new RouteInfo("SRM1", new string[] { "TY1" }),
  135. //new RouteInfo("SRM2", new string[] { "TY2" }),
  136. //new RouteInfo("SRM3", new string[] { "TY3" }),
  137. ////new RouteInfo("TY1", new string[] { "SRM1" }),
  138. //new RouteInfo("TY2", new string[] { "SRM2" }),
  139. //new RouteInfo("TY3", new string[] { "SRM3" }),
  140. ////new RouteInfo("TY1", new string[] { "1011", "1021" }),
  141. //new RouteInfo("TY2", new string[] { "1013", "1023" }),
  142. //new RouteInfo("TY3", new string[] { "1015", "1025" }),
  143. ////new RouteInfo("1012", new string[] { "TY1" }),
  144. ////new RouteInfo("1022", new string[] { "TY1" }),
  145. //new RouteInfo("1014", new string[] { "TY2" }),
  146. //new RouteInfo("1024", new string[] { "TY2" }),
  147. //new RouteInfo("1016", new string[] { "TY3" }),
  148. //new RouteInfo("1026", new string[] { "TY3" })
  149. };
  150. foreach (var item in routeInfos)
  151. {
  152. var device = Device.All.FirstOrDefault(x => x.Code == item.DeviceCode);
  153. device.AddTarget(item.NextList);
  154. foreach (var next in item.NextList)
  155. {
  156. var dev = Device.All.FirstOrDefault(x => x.Code == next);
  157. dev.Parent = device;
  158. }
  159. }
  160. #endregion 配置路径信息
  161. #region 标签配置
  162. Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>
  163. {
  164. { DeviceFlags.巷道口, new List<string>() { "1601", "1603", "1605", "1611", "1613", "1615", "2527", "2528", "2532", "2533", "2534", "2727", "2728", "2732", "2733", "2734" } },
  165. { DeviceFlags.入库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
  166. { DeviceFlags.出库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
  167. { DeviceFlags.扫码, new List<string>() { "2532", "2732" } },
  168. //{ DeviceFlags.扫码, new List<string>() { "2532", "2732", "RGV1","RGV2" } },
  169. { DeviceFlags.一楼出入库口, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
  170. { DeviceFlags.二楼出库口, new List<string>() { "1601", "1605", "1611", "1615" } },
  171. { DeviceFlags.二楼入库口, new List<string>() { "1603", "1613" } },
  172. { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
  173. { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
  174. //{ DeviceFlags.称重, new List<string>() { "1011", "1013", "1015", "1025" } }
  175. };
  176. devices.ForEach(item =>
  177. {
  178. item.Value.ForEach(code =>
  179. {
  180. var device = Device.All.FirstOrDefault(v => v.Code == code);
  181. device.AddFlag(item.Key);
  182. });
  183. });
  184. #endregion 标签配置
  185. }
  186. }
  187. }