123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using PlcSiemens.Core.Extension;
- using ServiceCenter;
- using WCS.Core;
- using WCS.Entity.Protocol.SRM;
- using WCS.Entity.Protocol.Station;
- using WCS.WorkEngineering.Extensions;
- using WCS.WorkEngineering.Protocol.BCR;
- using WCS.WorkEngineering.Protocol.RGV;
- using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
- namespace WCS.WorkEngineering
- {
- /// <summary>
- /// 业务工程配置信息
- /// </summary>
- public static class WorkStart
- {
- /// <summary>
- /// 初始化 设备信息
- /// </summary>
- public static void InitializeDeviceInfo()
- {
- #region 设置设备IP集合
- ServiceHub.DeviceIPList = new List<string>() { };
- #endregion 设置设备IP集合
- #region 初始化输送机相关信息
- #region 基本信息
- List<StationSegmentInfo> segmentInfo = new List<StationSegmentInfo>
- {
- new StationSegmentInfo(2701, 2734, "10.30.37.89"),
- new StationSegmentInfo(2501, 2534, "10.30.37.89"),
- new StationSegmentInfo(1611, 1616, "10.30.37.89"),
- new StationSegmentInfo(1601, 1606, "10.30.37.89")
- };
- foreach (var item in segmentInfo)
- {
- for (int i = item.Start; i <= item.End; i++)
- {
- var conv = new Device(i.ToString());
- conv.AddFlag(DeviceFlags.输送机);
- conv.AddProtocol<IStation520>((i - item.Start) * 14, 520, item.IP);
- conv.AddProtocol<IStation521>((i - item.Start) * 16, 521, item.IP);
- conv.AddProtocol<IStation523>((i - item.Start) * 12, 523, item.IP);
- }
- }
- #endregion 基本信息
- #region 扫码器
- List<BcrInfo> bcrInfo = new List<BcrInfo>
- {
- new BcrInfo(new int[] { }, "10.30.37.89")
- };
- foreach (var item in bcrInfo)
- {
- for (int i = 0; i < item.DeviceNo.Length; i++)
- {
- var conv = new Device("BCR" + item.DeviceNo[i]);
- conv.AddFlag(DeviceFlags.扫码);
- int pos = i * 20;
- conv.AddProtocol<IBCR81>(pos, 81, item.IP);
- }
- }
- #endregion 扫码器
- #region 外检信息
- List<ShapeInfo> shapeInfo = new List<ShapeInfo>
- {
- new ShapeInfo(new int[] { }, "10.30.37.89")
- };
- foreach (var item in shapeInfo)
- {
- for (int i = 0; i < item.DeviceNo.Length; i++)
- {
- var conv = Device.All.FirstOrDefault(x => x.Code == item.DeviceNo[i].ToString());
- conv.AddFlag(DeviceFlags.外检);
- int pos = i * 14;
- conv.AddProtocol<IStation91>(pos, 91, item.IP);
- }
- }
- #endregion 外检信息
- #endregion 初始化输送机相关信息
- #region 初始化RGV相关信息
- List<RGVSegmentInfo> RgvInfo = new List<RGVSegmentInfo>
- {
- new RGVSegmentInfo( 1, "10.30.37.113"),
- new RGVSegmentInfo( 2, "10.30.37.118"),
- new RGVSegmentInfo( 3, "10.30.37.123"),
- new RGVSegmentInfo( 4, "10.30.37.128"),
- new RGVSegmentInfo( 5, "10.30.37.133"),
- new RGVSegmentInfo( 6, "10.30.37.138")
- };
- foreach (var item in RgvInfo)
- {
- var conv = new Device($"RGV{item.Code}");
- conv.AddFlag(DeviceFlags.RGV);
- conv.AddProtocol<IRGV520>(0, 520, item.IP);
- conv.AddProtocol<IRGV521>(0, 521, item.IP);
- //conv.AddProtocol<IStation523>(, 523, item.IP);
- }
- #endregion 初始化RGV相关信息
- #region 初始化机械臂相关信息
- //List<RGVSegmentInfo> RgvInfo = new List<RGVSegmentInfo>
- //{
- // new RGVSegmentInfo( 1, "10.30.37.113"),
- // new RGVSegmentInfo( 2, "10.30.37.118"),
- // new RGVSegmentInfo( 3, "10.30.37.123"),
- // new RGVSegmentInfo( 4, "10.30.37.128"),
- // new RGVSegmentInfo( 5, "10.30.37.133"),
- // new RGVSegmentInfo( 6, "10.30.37.138")
- //};
- //foreach (var item in RgvInfo)
- //{
- // var conv = new Device($"RGV{item.Code}");
- // conv.AddFlag(DeviceFlags.RGV);
- // conv.AddProtocol<IRGV520>(0, 520, item.IP);
- // conv.AddProtocol<IRGV521>(0, 521, item.IP);
- // //conv.AddProtocol<IStation523>(, 523, item.IP);
- //}
- #endregion 初始化RGV相关信息
- #region 初始化堆垛机相关信息
- int ip = 41;
- for (int i = 0; i <= 1; i++)
- {
- var srm = new Device($"SRM{i + 1}");
- srm.AddFlag(DeviceFlags.堆垛机);
- ip = i == 0 ? ip : ip + 8;
- //三台堆垛机IP主机位分别是 21 31 41
- srm.AddProtocol<ISRM520>(0, 520, $"10.30.37.{ip}");
- srm.AddProtocol<ISRM521>(0, 521, $"10.30.37.{ip}");
- srm.AddProtocol<ISRM537>(0, 537, $"10.30.37.{ip}");
- //增加巷道
- var tunnel = new Device($"TY{i + 1}");
- tunnel.AddFlag(DeviceFlags.巷道);
- }
- #endregion 初始化堆垛机相关信息
- #region 配置路径信息
- List<RouteInfo> routeInfos = new List<RouteInfo>
- {
- ////new RouteInfo("SRM1", new string[] { "TY1" }),
- //new RouteInfo("SRM2", new string[] { "TY2" }),
- //new RouteInfo("SRM3", new string[] { "TY3" }),
- ////new RouteInfo("TY1", new string[] { "SRM1" }),
- //new RouteInfo("TY2", new string[] { "SRM2" }),
- //new RouteInfo("TY3", new string[] { "SRM3" }),
- ////new RouteInfo("TY1", new string[] { "1011", "1021" }),
- //new RouteInfo("TY2", new string[] { "1013", "1023" }),
- //new RouteInfo("TY3", new string[] { "1015", "1025" }),
- ////new RouteInfo("1012", new string[] { "TY1" }),
- ////new RouteInfo("1022", new string[] { "TY1" }),
- //new RouteInfo("1014", new string[] { "TY2" }),
- //new RouteInfo("1024", new string[] { "TY2" }),
- //new RouteInfo("1016", new string[] { "TY3" }),
- //new RouteInfo("1026", new string[] { "TY3" })
- };
- foreach (var item in routeInfos)
- {
- var device = Device.All.FirstOrDefault(x => x.Code == item.DeviceCode);
- device.AddTarget(item.NextList);
- foreach (var next in item.NextList)
- {
- var dev = Device.All.FirstOrDefault(x => x.Code == next);
- dev.Parent = device;
- }
- }
- #endregion 配置路径信息
- #region 标签配置
- Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>
- {
- { DeviceFlags.巷道口, new List<string>() { "1601", "1603", "1605", "1611", "1613", "1615", "2527", "2528", "2532", "2533", "2534", "2727", "2728", "2732", "2733", "2734" } },
- { DeviceFlags.入库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
- { DeviceFlags.出库, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
- { DeviceFlags.扫码, new List<string>() { "2532", "2732" } },
- //{ DeviceFlags.扫码, new List<string>() { "2532", "2732", "RGV1","RGV2" } },
- { DeviceFlags.一楼出入库口, new List<string>() { "2532", "2533", "2534", "2732", "2733", "2734" } },
- { DeviceFlags.二楼出库口, new List<string>() { "1601", "1605", "1611", "1615" } },
- { DeviceFlags.二楼入库口, new List<string>() { "1603", "1613" } },
- { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
- { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
- //{ DeviceFlags.称重, new List<string>() { "1011", "1013", "1015", "1025" } }
- };
- devices.ForEach(item =>
- {
- item.Value.ForEach(code =>
- {
- var device = Device.All.FirstOrDefault(v => v.Code == code);
- device.AddFlag(item.Key);
- });
- });
- #endregion 标签配置
- }
- }
- }
|