CardMessageBase.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.Generic;
  6. using System.Text;
  7. namespace Dfs.WayneChina.GilbarcoDispenserPayTerminal.MessageEntities
  8. {
  9. public enum CallingParty
  10. {
  11. /// <summary>
  12. /// System/后台
  13. /// </summary>
  14. System,
  15. /// <summary>
  16. /// Pump/加油机,实际上是终端
  17. /// </summary>
  18. Pump
  19. }
  20. public class CardMessageBase : MessageTemplateBase
  21. {
  22. #region Constructor
  23. public CardMessageBase(HandleType handleType)
  24. {
  25. Stx = 0xFA;
  26. Handle = Convert.ToByte(handleType);
  27. }
  28. #endregion
  29. [Format(1, EncodingType.BIN, -100)]
  30. public virtual byte Stx { get; set; }
  31. [Format(1, EncodingType.BIN, -99)]
  32. public virtual byte DestinationAddress { get; set; }
  33. [Format(1, EncodingType.BIN, -98)]
  34. public virtual byte SourceAddress { get; set; }
  35. [Format(1, EncodingType.BIN, -97)]
  36. public virtual byte FrameSqNoByte { get; set; }
  37. [Format(2, "%OnSerializingBytesCount", EncodingType.BCD, -96)]
  38. public virtual int BodyLength { get; set; }
  39. [Format(1, EncodingType.BIN, -95)]
  40. public byte Handle { get; set; }
  41. [EnumerableFormat(2, 1000, EncodingType = EncodingType.BIN)]
  42. public virtual List<byte> CRC { get; set; }
  43. public CallingParty Caller
  44. {
  45. get
  46. {
  47. if (FrameSqNoByte.GetBit(6) == 1)
  48. return CallingParty.Pump;
  49. return CallingParty.System;
  50. }
  51. }
  52. public virtual int FrameNo
  53. {
  54. get { return FrameSqNoByte & 0x3F; }
  55. }
  56. public override string ToLogString()
  57. {
  58. return GetType().Name + " " + base.ToLogString().Replace(
  59. "FrameSqNoByte:", "(Caller: " + Caller + ", FrameNo: " + FrameNo + ")FrameSqNoByte:");
  60. }
  61. }
  62. }