MessageTemplateBase.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Edge.Core.Parser.BinaryParser.Attributes;
  2. using Edge.Core.Parser.BinaryParser.MessageEntity;
  3. using Edge.Core.Parser.BinaryParser.Util;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Reflection;
  9. namespace Gilbarco_Pump
  10. {
  11. public abstract class MessageTemplateBase : Edge.Core.Parser.BinaryParser.MessageEntity.MessageTemplateBase
  12. {
  13. /// <summary>
  14. /// 数据包头,同步头
  15. /// </summary>
  16. [Format(1, EncodingType.BIN, -100)]
  17. public virtual byte Prefix
  18. {
  19. get { return 0xFA; }
  20. set
  21. {
  22. ;
  23. }
  24. }
  25. /// <summary>
  26. /// 数据接收端的地址编号 ,中控地址就放0xff
  27. /// </summary>
  28. [Format(1, EncodingType.BIN, -99)]
  29. public virtual byte TargetAddress { get; set; }
  30. /// <summary>
  31. /// 数据发送端的地址编号,中控地址就放0xff
  32. /// </summary>
  33. [Format(1, EncodingType.BIN, -98)]
  34. public virtual byte SourceAddress { get; set; }
  35. /// <summary>
  36. /// 帧号/控制
  37. /// 发送端与接收端的同步帧号,发送方发出某帧号,应答方回送此帧号,
  38. /// 该数从0x01递增到0x3F,然后再回到0x00,继续递增循环。
  39. ///
  40. /// 注意注意,实际加油机会发送0x40进来,可能是油机的BUG,所以这里放开到0x40
  41. /// </summary>
  42. [Format(1, EncodingType.BIN, -97)]
  43. [Range(1, 0x40, "帧号/控制 must between 0x01 to 0x3F, but now is: {0}")]
  44. public virtual byte FrameSeqNo { get; set; }
  45. /// <summary>
  46. /// 有效数据长度, 压缩 BCD,转 义字符 不计入 其中
  47. /// </summary>
  48. [Format(1, "%OnSerializingBytesCount", EncodingType.BIN, -90)]
  49. //[Range(1, 240, "有效数据长度must between 1 and 240, but now is {0}")]
  50. public virtual int DataLength { get; set; }
  51. [Format(1, EncodingType.BIN, -80)]
  52. public virtual byte CommandCode { get; set; }
  53. //[Format(1, EncodingType.BIN, 9999)]
  54. public virtual byte CheckSum { get; set; }
  55. public override string ToLogString()
  56. {
  57. return this.GetType().Name + " " + base.ToLogString();
  58. }
  59. }
  60. }