NonICMessageTemplateBase.cs 2.2 KB

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