PriceUpdateRequest.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.Outgoing
  8. {
  9. /// <summary>
  10. /// NOZ1-n specifies the logical nozzle numbers that is allowed for filling.
  11. /// The transaction is used when a pump is authorized.
  12. /// E.g. if nozzle 1-3 is allowed, the transaction contains 1, 2, 3.
  13. /// </summary>
  14. public class PriceUpdateRequest : MessageBase
  15. {
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. /// <param name="address"></param>
  20. /// <param name="blockSeqNumber"></param>
  21. /// <param name="newPrices">PRI is the price in packet BCD with MSB in first byte. PRI1 is the price for logical nozzle number 1. PRI2 is the price for logical nozzle number 2 and so on.</param>
  22. public PriceUpdateRequest(byte address, byte blockSeqNumber, IEnumerable<int> newPrices)
  23. {
  24. if (newPrices.Any(p => p.ToString().Length > 6)) throw new ArgumentException("Price must <= 6 digits");
  25. base.Adrs = address;
  26. base.BlockSeqNumber = blockSeqNumber;
  27. base.ControlCharacter = ControlCharacter.DATA;
  28. base.TransactionDatas = new List<TransactionData>()
  29. {
  30. new TransactionData()
  31. {
  32. TransactionNumber = 0x05,
  33. RawData = newPrices.Select(p=>p.GetBCDBytes(3)).SelectMany(s=>s).ToList()
  34. }
  35. };
  36. }
  37. }
  38. }