GetDeviceSystem.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using WCS.Core;
  2. using WCS.Entity.Protocol.BCR;
  3. using WCS.Entity.Protocol.SRM;
  4. using WCS.Entity.Protocol.Station;
  5. using WCS.WorkEngineering.Extensions;
  6. using WCS.WorkEngineering.Worlds;
  7. namespace WCS.WorkEngineering.Systems
  8. {
  9. /// <summary>
  10. /// 设备信息读取接口
  11. /// </summary>
  12. [BelongTo(typeof(MainWorld))]
  13. public class GetDeviceSystem : ServiceSystem<Tuple<string, string>, object>
  14. {
  15. /// <summary>
  16. /// 所有的站台
  17. /// </summary>
  18. private List<Station> Convs;
  19. private List<SRM> Srms;
  20. private List<BCR> Bcrs;
  21. private List<Device<IStation523>> Device91;
  22. /// <summary>
  23. /// 构造函数
  24. /// </summary>
  25. public GetDeviceSystem()
  26. {
  27. //Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
  28. Srms = Device.All.Where(v => v.HasProtocol<ISRM520>()).Select(v => new SRM(v, this.World)).ToList();
  29. Bcrs = Device.All.Where(v => v.HasProtocol<IBCR81>()).Select(v => new BCR(v, this.World)).ToList();
  30. Device91 = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Device<IStation523>(v, this.World)).ToList();
  31. }
  32. protected override object Do(Tuple<string, string> tuple)
  33. {
  34. switch (tuple.Item1)
  35. {
  36. case "堆垛机":
  37. return Srms;
  38. case "输送机":
  39. return Convs;
  40. case "读码器":
  41. var b = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).Data.Content;
  42. var a = Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
  43. return Bcrs.FirstOrDefault(v => v.Entity.Code == tuple.Item2).GetBCRCode();
  44. case "外检":
  45. return Device91;
  46. default: return "未知设备类型";
  47. }
  48. //if (code.Contains("SRM")) return Device.All.Where(v => v.Code == code).Select(v => new SRM(v, this.World)).ToList();
  49. //else if (code.Contains("BCR")) return Device.All.Where(v => v.Code == code).Select(v => new BCR(v, this.World)).ToList();
  50. //else if (code.Contains("D91")) return Device.All.Where(v => v.Code == code).Select(v => new Device<IStation523>(v, this.World)).ToList();
  51. //return Device.All.Where(v => v.Code == code).Select(v => new Station(v, this.World)).ToList();
  52. }
  53. }
  54. }