StationInfo.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using Edge.Core.Parser.BinaryParser.Attributes;
  2. using Edge.Core.Parser.BinaryParser.MessageEntity;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. namespace FuRen_Sinopec_IcCardReader
  9. {
  10. /// <summary>
  11. /// 加油站通用信息
  12. /// </summary>
  13. public class StationGenericInfo : MessageTemplateBase
  14. {
  15. private byte _Ver;
  16. /// <summary>
  17. /// 版本 , 0,1~255 0: 数据无效
  18. /// </summary>
  19. [Format(1, EncodingType.BIN, 1)]
  20. public byte Ver
  21. {
  22. get { return this._Ver; }
  23. set
  24. {
  25. this._Ver = value > 255 ? (byte)1 : value;
  26. }
  27. }
  28. /// <summary>
  29. /// 石化编码规范中地区编码的头两个数字
  30. /// </summary>
  31. [Format(1, EncodingType.BCD, 2)]
  32. [Range(@"^\d{1,2}$", RegexOptions.IgnoreCase, "Prov_省代号 value {0} does not match regex requirment.")]
  33. public byte Prov_省代号 { get; set; }
  34. /// <summary>
  35. /// 石化编码规范中地区编码的中间两个数字
  36. /// </summary>
  37. [Format(1, EncodingType.BCD, 3)]
  38. [Range(@"^\d{1,2}$", RegexOptions.IgnoreCase, "City_地市代码 value {0} does not match regex requirment.")]
  39. public byte City_地市代码 { get; set; }
  40. /// <summary>
  41. /// 同石化编码
  42. /// </summary>
  43. [Format(4, EncodingType.BcdString, 4)]
  44. [Range(@"^\d{1,8}$", RegexOptions.IgnoreCase, "Superior_上级单位代号 value {0} does not match regex requirment.")]
  45. public string Superior_上级单位代号 { get; set; }
  46. /// <summary>
  47. /// 同石化编码
  48. /// </summary>
  49. [Format(4, EncodingType.BcdString, 5)]
  50. [Range(@"^\d{1,8}$", RegexOptions.IgnoreCase, "S_ID_加油站ID value {0} does not match regex requirment.")]
  51. public string S_ID_加油站ID { get; set; }
  52. /// <summary>
  53. /// 通讯终端逻辑编号 0-249
  54. /// </summary>
  55. [Format(1, EncodingType.BCD, 6)]
  56. [Range(0, 249, "0-249 ")]
  57. public byte POS_P_通讯终端逻辑编号 { get; set; }
  58. /// <summary>
  59. ///
  60. /// </summary>
  61. [Format(1, EncodingType.BIN, 7)]
  62. public byte GUN_N_油枪数 { get; set; }
  63. [EnumerableFormat("GUN_N_油枪数", 8, EncodingType = EncodingType.BIN)]
  64. public List<byte> MZN_单个油枪 { get; set; }
  65. public override bool Equals(object obj)
  66. {
  67. var target = obj as StationGenericInfo;
  68. if (this.Prov_省代号 != target?.Prov_省代号) return false;
  69. if (this.City_地市代码 != target.City_地市代码) return false;
  70. if (this.Superior_上级单位代号 != target.Superior_上级单位代号) return false;
  71. if (this.S_ID_加油站ID != target.S_ID_加油站ID) return false;
  72. if (this.GUN_N_油枪数 != target.GUN_N_油枪数) return false;
  73. if (this.POS_P_通讯终端逻辑编号 != target.POS_P_通讯终端逻辑编号) return false;
  74. if (this.MZN_单个油枪 != null ^ target.MZN_单个油枪 != null) return false;
  75. //if (this.NozzleBelongToPumpSide != null ^ target.NozzleBelongToPumpSide != null) return false;
  76. if (this.MZN_单个油枪 != null)
  77. {
  78. if (this.MZN_单个油枪.Count != target.MZN_单个油枪.Count) return false;
  79. for (int i = 0; i < this.MZN_单个油枪.Count; i++)
  80. {
  81. if (this.MZN_单个油枪[i] != target.MZN_单个油枪[i]) return false;
  82. }
  83. }
  84. //if (this.NozzleBelongToPumpSide != null)
  85. //{
  86. // if (this.NozzleBelongToPumpSide.Count != target.NozzleBelongToPumpSide.Count) return false;
  87. // for (int i = 0; i < this.NozzleBelongToPumpSide.Count; i++)
  88. // {
  89. // if (this.NozzleBelongToPumpSide[i] != target.NozzleBelongToPumpSide[i]) return false;
  90. // }
  91. //}
  92. return true;
  93. }
  94. public override int GetHashCode()
  95. {
  96. return base.GetHashCode();
  97. }
  98. }
  99. }