1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System.Threading.Tasks;
- using WCS.Core;
- using WCS.WorkEngineering.Extensions;
- using WCS.WorkEngineering.Protocol.BCR;
- using WCS.WorkEngineering.Protocol.SRM;
- using WCS.WorkEngineering.Protocol.Station;
- using WCS.WorkEngineering.Worlds;
- using static Dm.net.buffer.ByteArrayBuffer;
- namespace WCS.WorkEngineering.Systems
- {
- /// <summary>
- /// 设备信息读取接口
- /// </summary>
- [BelongTo(typeof(MainWorld))]
- public class GetDeviceSystem : ServiceSystem<Tuple<string, string>, object>
- {
- /// <summary>
- /// 所有的站台
- /// </summary>
- private List<Station> Convs;
- private List<SRM> Srms;
- private List<BCR> Bcrs;
- private List<Device<IStation523>> Device91;
- /// <summary>
- /// 构造函数
- /// </summary>
- public GetDeviceSystem()
- {
- //Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
- Srms = Device.All.Where(v => v.HasProtocol<ISRM520>()).Select(v => new SRM(v, this.World)).ToList();
- Bcrs = Device.All.Where(v => v.HasProtocol<IBCR81>()).Select(v => new BCR(v, this.World)).ToList();
- Device91 = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Device<IStation523>(v, this.World)).ToList();
- }
- protected override object Do(Tuple<string, string> tuple)
- {
- switch (tuple.Item1)
- {
- case "堆垛机":
- return Srms;
- case "输送机":
- return Convs;
- case "读码器":
- var b = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).Data.Content;
- var a = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
- return Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
- case "Disassemble":
- List<DeviceInfo> deviceInfos = new List<DeviceInfo>();
- var deviceInfo = Device.All.Where(v => v.Code == "8003" || v.Code == "8011" || v.Code == "8019").Select(v => new Station(v, this.World)).ToList();
- foreach (dynamic i in deviceInfo)
- {
- deviceInfos.Add(new DeviceInfo { DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
- }
- return deviceInfos;
- case "PalletizingEquip":
- List<DeviceInfo1> deviceInfos1 = new List<DeviceInfo1>();
- var equlist = new List<string>() { "8090", "8089", "8156", "8092", "8091", "8157", "8096", "8095", "8159", "8098", "8097", "8160", "8307", "8306" };
- var deviceInfo1 = Device.All.Where(v => equlist.Contains(v.Code)).Select(v => new Station(v, this.World)).ToList();
- foreach (dynamic i in deviceInfo1)
- {
- deviceInfos1.Add(new DeviceInfo1 { TaskCode = i.Data2.TaskNumber, DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
- }
- return deviceInfos1;
- case "外检":
- return Device91;
- default: return "未知设备类型";
- }
- //if (code.Contains("SRM")) return Device.All.Where(v => v.Code == code).Select(v => new SRM(v, this.World)).ToList();
- //else if (code.Contains("BCR")) return Device.All.Where(v => v.Code == code).Select(v => new BCR(v, this.World)).ToList();
- //else if (code.Contains("D91")) return Device.All.Where(v => v.Code == code).Select(v => new Device<IStation523>(v, this.World)).ToList();
- //return Device.All.Where(v => v.Code == code).Select(v => new Station(v, this.World)).ToList();
- }
- }
- public class DeviceInfo
- {
- public string DeviceCode { get; set; }
- public bool PH_STATUS { get; set; }
- }
- public class DeviceInfo1 : DeviceInfo
- {
- public int TaskCode { get; set; }
- }
- }
|