using PlcSiemens.Core.Extension; using ServiceCenter; using WCS.Core; using WCS.WorkEngineering.Extensions; using WCS.WorkEngineering.Protocol.BCR; using WCS.WorkEngineering.Protocol.RGV; using WCS.WorkEngineering.Protocol.SRM; using WCS.WorkEngineering.Protocol.Station; using WCS.WorkEngineering.Protocol.Truss; using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags; namespace WCS.WorkEngineering { /// /// 业务工程配置信息 /// public static class WorkStart { /// /// 初始化 设备信息 /// public static void InitializeDeviceInfo() { #region 设置设备IP集合 ServiceHub.DeviceIPList = new List() { }; #endregion 设置设备IP集合 #region 初始化输送机相关信息 #region 基本信息 #region 托盘线输送线 List>>> tuples = new List>>>() { //new Tuple>>("10.30.37.89",new List>() //{ // new Tuple(1601, 1620), // new Tuple(2501, 2540), // new Tuple(2701, 2740), //}) }; foreach (var item in tuples) { var db520 = 0; var db521 = 0; var db523 = 0; foreach (var item1 in item.Item2) { for (int i = item1.Item1; i <= item1.Item2; i++) { var conv = new Device(i.ToString()); conv.AddFlag(DeviceFlags.输送机); conv.AddProtocol(db520, 520, item.Item1); conv.AddProtocol(db521, 521, item.Item1); conv.AddProtocol(db523, 523, item.Item1); db520 = db520 + 14; db521 = db521 + 16; db523 = db523 + 12; } } } #endregion 托盘线输送线 #endregion 基本信息 #region 托盘线扫码器 List bcrInfo = new List { //new BcrInfo(new int[] {2532, 2732 }, "10.30.37.89") }; foreach (var item in bcrInfo) { for (int i = 0; i < item.DeviceNo.Length; i++) { var device = Device.All.FirstOrDefault(v => v.Code == item.DeviceNo[i].ToString()); device.AddFlag(DeviceFlags.扫码); int pos = i * 20; device.AddProtocol(pos, 81, item.IP); } } #endregion 托盘线扫码器 #region 外检信息 List shapeInfo = new List { //new ShapeInfo(new int[] { 2732,2532 }, "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(pos, 91, item.IP); } } #endregion 外检信息 #endregion 初始化输送机相关信息 #region 初始化RGV相关信息 List RgvInfo = new List { //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(0, 520, item.IP); conv.AddProtocol(0, 521, item.IP); //conv.AddProtocol(, 523, item.IP); } #endregion 初始化RGV相关信息 #region 初始化桁架相关信息 List TrussInfo = new List { //new TrussSegmentInfo( 1, "10.30.37.211"), }; foreach (var item in TrussInfo) { var conv = new Device($"Truss{item.Code}"); conv.AddFlag(DeviceFlags.桁架); conv.AddProtocol(0, 520, item.IP); conv.AddProtocol(0, 521, item.IP); conv.AddProtocol(0, 523, item.IP); conv.AddProtocol(0, 530, item.IP); conv.AddProtocol(0, 531, item.IP); } #endregion 初始化桁架相关信息 #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主机位分别是 41、49、57、65、73、81 srm.AddProtocol(0, 520, $"10.30.37.{ip}"); srm.AddProtocol(0, 521, $"10.30.37.{ip}"); srm.AddProtocol(0, 537, $"10.30.37.{ip}"); //增加巷道 var tunnel = new Device($"TY{i + 1}"); tunnel.AddFlag(DeviceFlags.巷道); } #endregion 初始化堆垛机相关信息 #region 配置路径信息 List routeInfos = new List { // new RouteInfo("SRM1", new string[] { "TY1" }), // new RouteInfo("SRM2", new string[] { "TY2" }), // //巷道对应堆垛机 及 一楼出库点 // new RouteInfo("TY1", new string[] { "SRM1","2532"}), // new RouteInfo("TY2", new string[] { "SRM2","2732" }), // //一楼入库点 // new RouteInfo("2532", new string[] { "TY1" }), // new RouteInfo("2732", new string[] { "TY2" }), // new RouteInfo("2527", new string[] { "TY1" }), // new RouteInfo("2528", new string[] { "TY1" }), // new RouteInfo("2727", new string[] { "TY2" }), // new RouteInfo("2728", new string[] { "TY2" }), // //分流点路径配置 // new RouteInfo("455", new string[] { "466", "480", "494", "508","522","536"}), }; 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> devices = new Dictionary> { //{ DeviceFlags.入库, new List() { "2532", "2533", "2534", "2732", "2733", "2734" } }, //{ DeviceFlags.出库, new List() { "2532", "2533", "2534", "2732", "2733", "2734" } }, //{ DeviceFlags.扫码, new List() { "2532", "2732" } }, //{ DeviceFlags.一列堆垛机, new List() { "SRM1"/*, "SRM3", "SRM5"*/} }, //{ DeviceFlags.二列堆垛机, new List() { "SRM2"/*, "SRM4", "SRM6"*/ } }, //{ DeviceFlags.一楼扫码,new List(){ "2532","2732"} }, //{ DeviceFlags.一楼叠盘机,new List() { "2527","2528","2727","2728"} }, //{ DeviceFlags.主线分流点,new List() { "22","41","61"} }, //{ DeviceFlags.满轮主线第一次扫码,new List() { "1"} }, //{ DeviceFlags.环形库分流点,new List(){ "418"} }, //{ DeviceFlags.桁架分流点,new List() { "455" } }, //{ DeviceFlags.桁架缓存放行点, new List(){ "466", "480", "494", "508","522","536" } }, //{ DeviceFlags.桁架取货点, new List(){ "461", "475", "489", "503","517","531" } } }; devices.ForEach(item => { item.Value.ForEach(code => { var device = Device.All.FirstOrDefault(v => v.Code == code); device.AddFlag(item.Key); }); }); #endregion 标签配置 } } }