NonCardDispenserMessageTemplateBase.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using Edge.Core.Parser.BinaryParser.Attributes;
  3. using Edge.Core.Parser.BinaryParser.MessageEntity;
  4. namespace Dfs.WayneChina.HengshanTerminalWrapper.MessageEntity.Base
  5. {
  6. /// <summary>
  7. /// 前导码(0FFH)+长度(0-20H)+{命令(0A0H--0AFH)+参数}+校验({...}XRL结果,0FFH=0EEH)
  8. /// 长度=命令+参数+校验
  9. /// 校验 = 命令 + 参数
  10. /// 超时判定:30秒
  11. /// </summary>
  12. [Serializable]
  13. public abstract class NonCardDispenserMessageTemplateBase : MessageTemplateBase
  14. {
  15. public enum Result
  16. {
  17. 成功,
  18. 失败
  19. }
  20. /// <summary>
  21. /// 数据包头,同步头
  22. /// </summary>
  23. [Format(1, EncodingType.BIN, -100)]
  24. public virtual byte Prefix
  25. {
  26. get { return 0xFF; }
  27. set
  28. {
  29. ;
  30. }
  31. }
  32. ///
  33. /// 前导码(0FFH)+长度(0-20H)+{命令(0A0H--0AFH)+参数}+校验
  34. ///
  35. /// <summary>
  36. /// 消息长度
  37. /// </summary>
  38. [Format(1, "%OnSerializingBytesCount", EncodingType.BIN, -99)]
  39. public virtual int MessageLength { get; set; }
  40. ///// <summary>
  41. ///// fixed legth
  42. /// cmd
  43. ///// </summary>
  44. [FormatAttribute(1, EncodingType.BIN, -98)]
  45. public virtual byte CMD { get; set; }
  46. [Format(1, EncodingType.BIN, 1000)]
  47. public virtual byte XRL { get; set; }
  48. /// <summary>
  49. /// Gets the code for the message, the code is variant length, most of them are 1 or 2 byte.
  50. /// </summary>
  51. //public virtual List<byte> Code { get; protected set; }
  52. //protected KaJiLianDongV11MessageTemplateBase()
  53. //{
  54. // // fusion always the host, the pump side msg sender is from a system embeded in pump.
  55. // this.SetMessageCallerSide(MessageCallerSide.Host);
  56. //}
  57. public override string ToLogString()
  58. {
  59. return this.GetType().Name + " "
  60. + base.ToLogString().Replace("FrameSequenceAndControlRaw:",
  61. "(message length: 0x" + MessageLength + ", cmd: 0x" + CMD);
  62. }
  63. }
  64. }