PumpParameters_TransactionData.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Edge.Core.Parser.BinaryParser.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Wayne_Pump_Dart.MessageEntity.Incoming
  8. {
  9. /// <summary>
  10. /// The pump sends this transaction if Request Total Counters is received.
  11. /// </summary>
  12. public class PumpParameters_TransactionData
  13. {
  14. private TransactionData transactionData;
  15. public PumpParameters_TransactionData(TransactionData transactionData)
  16. {
  17. if (transactionData.TransactionNumber != 0x07)
  18. throw new ArgumentException("PumpParameters_TransactionData must have transaction number 0x07");
  19. if (transactionData.Length != 51)
  20. throw new ArgumentException("TotalCounters_TransactionData must have length 51");
  21. this.transactionData = transactionData;
  22. }
  23. /// <summary>
  24. /// Number of decimals in volume (0-8)
  25. /// </summary>
  26. public byte VolumeDecimalPoint { get { return this.transactionData.RawData.Skip(22).First(); } }
  27. /// <summary>
  28. /// Number of decimals in amount (0-8)
  29. /// </summary>
  30. public byte AmountDecimalPoint { get { return this.transactionData.RawData.Skip(23).First(); } }
  31. /// <summary>
  32. /// Number of decimals in unit price (0-4)
  33. /// </summary>
  34. public byte UnitPriceDecimalPoint { get { return this.transactionData.RawData.Skip(24).First(); } }
  35. /// <summary>
  36. /// Maximum amount
  37. /// </summary>
  38. public int MaxAmount { get { return this.transactionData.RawData.Skip(30).Take(4).GetBCD(); } }
  39. /// <summary>
  40. /// Existing grade per nozzle number
  41. /// </summary>
  42. public string Grade
  43. {
  44. get { return this.transactionData.RawData.Skip(36).Take(15).ToArray().GetBCDString(); }
  45. }
  46. }
  47. }