DeviceExtension.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System.Collections.Concurrent;
  2. using WCS.Core;
  3. using WCS.Entity.Protocol.Station;
  4. namespace WCS.WorkEngineering.Extensions
  5. {
  6. /// <summary>
  7. /// 设备扩展
  8. /// </summary>
  9. public static class DeviceExtension
  10. {
  11. public static bool IsConv(this Device source)
  12. {
  13. return source.HasProtocol(typeof(IStation521)) || source.HasProtocol(typeof(IStation520)) || source.HasProtocol(typeof(IStation522));
  14. }
  15. #region WCS_DEVICE扩展数据
  16. private static ConcurrentDictionary<string, object> DeviceValues = new ConcurrentDictionary<string, object>();
  17. public static void AddFlag(this Device source, DF flag)
  18. {
  19. var df = source.Get<DF>("DeviceFlag");
  20. df = df | flag;
  21. source.Set("DeviceFlag", df);
  22. }
  23. public static bool Is(this Device source, DF flag)
  24. {
  25. var df = source.Get<DF>("DeviceFlag");
  26. return (df & flag) == flag;
  27. }
  28. public static void Set<T>(this Device source, string key, T value)
  29. {
  30. DeviceValues[source.Code + key] = value;
  31. }
  32. public static T Get<T>(this Device source, string key)
  33. {
  34. if (!DeviceValues.ContainsKey(source.Code + key))
  35. return default(T);
  36. return (T)DeviceValues[source.Code + key];
  37. }
  38. public static short Code(this Device source)
  39. {
  40. return short.Parse(source.Code);
  41. }
  42. public static string Tunnel(this Device source)
  43. {
  44. return source.Get<string>("Tunnel");
  45. }
  46. public static int TunnelNum(this Device source)
  47. {
  48. return int.Parse(source.Tunnel().Last().ToString());
  49. }
  50. public static int Floor(this Device source)
  51. {
  52. return source.Get<int>("Floor");
  53. }
  54. public static Device SC(this Device source)
  55. {
  56. return source.Get<Device>("SC");
  57. }
  58. public static Device RGV(this Device source)
  59. {
  60. return source.Get<Device>("RGV");
  61. }
  62. #endregion WCS_DEVICE扩展数据
  63. }
  64. /// <summary>
  65. /// 设备配置
  66. /// </summary>
  67. [Flags]
  68. public enum DF
  69. {
  70. 无 = 0,
  71. SRM = 1 << 0,
  72. SRM二级品取货 = 1 << 1,
  73. SRM涂布取货 = 1 << 2,
  74. SRM月台放货 = 1 << 3,
  75. 一楼RGV放货 = 1 << 4,
  76. 月台 = 1 << 5,
  77. 涂布RGV = 1 << 6,
  78. BOPPRGV = 1 << 7,
  79. 涂布RGV取货设备组 = 1 << 8,
  80. 涂布RGV放货设备组 = 1 << 9,
  81. 涂布出库RGV取货站台 = 1 << 10,
  82. 涂布入库RGV取货站台 = 1 << 11,
  83. SRM涂布放货 = 1 << 12,
  84. 涂布RGV取货站台 = 1 << 13,
  85. BOPPRGV取货设备组 = 1 << 14,
  86. BOPPRGV放货设备组 = 1 << 15,
  87. SRMBOPP取货 = 1 << 16,
  88. }
  89. }