GetDeviceSystem.cs 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System.Threading.Tasks;
  2. using WCS.Core;
  3. using WCS.WorkEngineering.Extensions;
  4. using WCS.WorkEngineering.Protocol.BCR;
  5. using WCS.WorkEngineering.Protocol.SRM;
  6. using WCS.WorkEngineering.Protocol.Station;
  7. using WCS.WorkEngineering.Worlds;
  8. using static Dm.net.buffer.ByteArrayBuffer;
  9. namespace WCS.WorkEngineering.Systems
  10. {
  11. /// <summary>
  12. /// 设备信息读取接口
  13. /// </summary>
  14. [BelongTo(typeof(MainWorld))]
  15. public class GetDeviceSystem : ServiceSystem<Tuple<string, string>, object>
  16. {
  17. /// <summary>
  18. /// 所有的站台
  19. /// </summary>
  20. private List<Station> Convs;
  21. private List<SRM> Srms;
  22. private List<BCR> Bcrs;
  23. private List<Device<IStation523>> Device91;
  24. /// <summary>
  25. /// 构造函数
  26. /// </summary>
  27. public GetDeviceSystem()
  28. {
  29. //Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
  30. Srms = Device.All.Where(v => v.HasProtocol<ISRM520>()).Select(v => new SRM(v, this.World)).ToList();
  31. Bcrs = Device.All.Where(v => v.HasProtocol<IBCR81>()).Select(v => new BCR(v, this.World)).ToList();
  32. Device91 = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Device<IStation523>(v, this.World)).ToList();
  33. }
  34. protected override object Do(Tuple<string, string> tuple)
  35. {
  36. switch (tuple.Item1)
  37. {
  38. case "堆垛机":
  39. return Srms;
  40. case "输送机":
  41. return Convs;
  42. case "读码器":
  43. var b = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).Data.Content;
  44. var a = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
  45. return Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
  46. case "Disassemble":
  47. List<DeviceInfo> deviceInfos = new List<DeviceInfo>();
  48. var deviceInfo = Device.All.Where(v => v.Code == "8003" || v.Code == "8011" || v.Code == "8019").Select(v => new Station(v, this.World)).ToList();
  49. foreach (dynamic i in deviceInfo)
  50. {
  51. deviceInfos.Add(new DeviceInfo { DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
  52. }
  53. return deviceInfos;
  54. case "PalletizingEquip":
  55. List<DeviceInfo1> deviceInfos1 = new List<DeviceInfo1>();
  56. var equlist = new List<string>() { "8090", "8089", "8156", "8092", "8091", "8157", "8096", "8095", "8159", "8098", "8097", "8160", "8307", "8306" };
  57. var deviceInfo1 = Device.All.Where(v => equlist.Contains(v.Code)).Select(v => new Station(v, this.World)).ToList();
  58. foreach (dynamic i in deviceInfo1)
  59. {
  60. deviceInfos1.Add(new DeviceInfo1 { TaskCode = i.Data2.TaskNumber, DeviceCode = i.Entity.Code, PH_STATUS = i.Data3.Status.HasFlag(StationStatus.PH_Status) });
  61. }
  62. return deviceInfos1;
  63. case "外检":
  64. return Device91;
  65. default: return "未知设备类型";
  66. }
  67. //if (code.Contains("SRM")) return Device.All.Where(v => v.Code == code).Select(v => new SRM(v, this.World)).ToList();
  68. //else if (code.Contains("BCR")) return Device.All.Where(v => v.Code == code).Select(v => new BCR(v, this.World)).ToList();
  69. //else if (code.Contains("D91")) return Device.All.Where(v => v.Code == code).Select(v => new Device<IStation523>(v, this.World)).ToList();
  70. //return Device.All.Where(v => v.Code == code).Select(v => new Station(v, this.World)).ToList();
  71. }
  72. }
  73. public class DeviceInfo
  74. {
  75. public string DeviceCode { get; set; }
  76. public bool PH_STATUS { get; set; }
  77. }
  78. public class DeviceInfo1 : DeviceInfo
  79. {
  80. public int TaskCode { get; set; }
  81. }
  82. }