MessageBase.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.Threading.Tasks;
  8. namespace FR_Pump_HaoSheng.MessageEntity
  9. {
  10. public abstract class MessageBase : MessageTemplateBase
  11. {
  12. public enum NozzleStateEnum { Replaced = 0x00, Lifted = 0x01, }
  13. /// <summary>
  14. /// 包头第一字节,固定值。
  15. /// </summary>
  16. [Format(1, EncodingType.BIN, -1000)]
  17. public byte PrefixFirstByte
  18. {
  19. get { return 0xFA; }
  20. set
  21. {
  22. ;
  23. }
  24. }
  25. /// <summary>
  26. /// 包头第二字节,固定值。
  27. /// </summary>
  28. [Format(1, EncodingType.BIN, -950)]
  29. public byte PrefixSecondByte
  30. {
  31. get { return 0x00; }
  32. set
  33. {
  34. ;
  35. }
  36. }
  37. /// <summary>
  38. /// 包头第三字节。
  39. /// </summary>
  40. [Format(1, EncodingType.BIN, -930)]
  41. public NozzleStateEnum NozzleState
  42. {
  43. get; set;
  44. }
  45. /// <summary>
  46. /// 当前油枪号码,通过协议文档,貌似只可能是1 or 2, 当raw值为 0x00时,指1号枪,当raw值为 0x01时,指2号枪。
  47. /// </summary>
  48. [Format(1, EncodingType.BIN, -900)]
  49. public byte NozzleNumberRaw { get; set; }
  50. /// <summary>
  51. /// </summary>
  52. [Format(2, EncodingType.BCD, -800)]
  53. public virtual int MessageBodyLength
  54. {
  55. get; set;
  56. }
  57. [EnumerableFormat("MessageBodyLength", 1000)]
  58. public virtual List<byte> MessageBodyRaw { get; set; }
  59. /// <summary>
  60. /// .两字节校验码为 FA 之后字节开始 到 有效数据的 CRC16 值
  61. /// </summary>
  62. [EnumerableFormat(2, 1100)]
  63. public virtual List<byte> Crc16 { get; set; }
  64. }
  65. }