123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using PlcSiemens.Core.Extension;
- using WCS.Core;
- using WCS.Entity.Protocol.BCR;
- using WCS.Entity.Protocol.SRM;
- using WCS.Entity.Protocol.Station;
- using WCS.WorkEngineering.Extensions;
- using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
- namespace WCS.WorkEngineering
- {
- /// <summary>
- /// 业务工程配置信息
- /// </summary>
- public static class WorkStart
- {
- /// <summary>
- /// 初始化 设备信息
- /// </summary>
- public static void InitializeDeviceInfo()
- {
- #region 初始化输送机相关信息
- #region 基本信息
- List<StationSegmentInfo> segmentInfo = new List<StationSegmentInfo>();
- segmentInfo.Add(new StationSegmentInfo(1011, 1026, "10.30.36.51"));
- 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) * 14, 523, item.IP);
- }
- }
- #endregion 基本信息
- #region 扫码器
- List<BcrInfo> bcrInfo = new List<BcrInfo>();
- bcrInfo.Add(new BcrInfo(new int[] { 1011, 1013, 1015, 1022, 1024, 1026 }, "10.30.36.51"));
- 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 * 14;
- conv.AddProtocol<IBCR80>(pos, 80, item.IP);
- conv.AddProtocol<IBCR81>(pos, 81, item.IP);
- }
- }
- #endregion 扫码器
- #region 外检信息
- List<ShapeInfo> shapeInfo = new List<ShapeInfo>();
- shapeInfo.Add(new ShapeInfo(new int[] { 1012, 1014, 1016, 1025 }, "10.30.36.51"));
- 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 初始化堆垛机相关信息
- for (int i = 1; i <= 3; i++)
- {
- var srm = new Device($"SRM{i}");
- srm.AddFlag(DeviceFlags.堆垛机);
- //三台堆垛机IP主机位分别是 21 31 41
- srm.AddProtocol<ISRM520>(0, 520, $"10.30.36.{(i * 10) + 10 + 1}");
- srm.AddProtocol<ISRM521>(0, 521, $"10.30.36.{(i * 10) + 10 + 1}");
- srm.AddProtocol<ISRM523>(0, 523, $"10.30.36.{(i * 10) + 10 + 1}");
- //增加巷道
- var tunnel = new Device($"TY{i}");
- tunnel.AddFlag(DeviceFlags.巷道);
- }
- #endregion 初始化堆垛机相关信息
- #region 配置路径信息
- List<RouteInfo> routeInfos = new List<RouteInfo>();
- routeInfos.Add(new RouteInfo("SRM1", new string[] { "TY1" }));
- routeInfos.Add(new RouteInfo("SRM2", new string[] { "TY2" }));
- routeInfos.Add(new RouteInfo("SRM3", new string[] { "TY3" }));
- #endregion 配置路径信息
- #region 标签配置
- Dictionary<DeviceFlags, List<string>> devices = new Dictionary<DeviceFlags, List<string>>();
- devices.Add(DeviceFlags.巷道口, new List<string>() { "1011", "1012", "1013", "1014", "1015", "1016", "1021", "1022", "1023", "1024", "1025", "1026" });
- devices.Add(DeviceFlags.入库, new List<string>() { "1011", "1013", "1015", "1022", "1024", "1026" });
- devices.Add(DeviceFlags.出库, new List<string>() { "1012", "1014", "1016", "1021", "1023", "1025", });
- devices.ForEach(item =>
- {
- item.Value.ForEach(code =>
- {
- var device = Device.All.FirstOrDefault(v => v.Code == code);
- device.AddFlag(item.Key);
- });
- });
- #endregion 标签配置
- }
- }
- }
|