TextMessageBase.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Edge.Core.Parser.BinaryParser.Attributes;
  2. using Edge.Core.Parser.BinaryParser.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using static TATSUNO_Pump.Messages.PollingOrSelectingRequest;
  7. namespace TATSUNO_Pump.Messages
  8. {
  9. public abstract class TextMessageBase : MessageBase
  10. {
  11. [Format(1, EncodingType.BIN, -9999)]
  12. public byte STX { get; set; } = 0x02;
  13. /// <summary>
  14. /// actual the device address which configed in device side, range from 40H~7FH
  15. /// </summary>
  16. [Format(1, EncodingType.BIN, -9900)]
  17. [Range(0x40, 0x7F, "StationAddress must range from 0x40 to 0x7F")]
  18. public byte StationAddress { get; set; }
  19. private byte unitAddress_Raw = 0;
  20. [Format(1, EncodingType.BIN, -9800)]
  21. public byte UnitAddress_Raw
  22. {
  23. get { return this.unitAddress_Raw; }
  24. set
  25. {
  26. this.unitAddress_Raw = value;
  27. if (this.unitAddress_Raw.GetBit(4) == 0)
  28. this.RequestType = RequestTypeEnum.Selecting;
  29. else
  30. this.RequestType = RequestTypeEnum.Polling;
  31. var kindsRaw = this.unitAddress_Raw & 0x0F;
  32. this.DeviceKind = (DeviceKindEnum)Enum.Parse(typeof(DeviceKindEnum), kindsRaw.ToString());
  33. }
  34. }
  35. public RequestTypeEnum RequestType { get; set; }
  36. public DeviceKindEnum DeviceKind { get; set; }
  37. [Format(1, EncodingType.BIN, -9700)]
  38. public byte Code { get; set; }
  39. //public enum PosToDeviceTextMessageCodeEnum
  40. //{
  41. // //code 11
  42. // PermissionOfRefueling,
  43. // //code 12
  44. // CancellationOfRefueling,
  45. // //code 13
  46. // PumpLock,
  47. // //code 14
  48. // CancellationOfPumpLock,
  49. // //code 15
  50. // RequestForStatusOfGasPump,
  51. // //code 20
  52. // RequestForTota1AmountOfRefueling
  53. //}
  54. }
  55. }