PresetAmountRequest.cs 1.2 KB

1234567891011121314151617181920212223242526272829
  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 LanTian_Pump_664_Or_886.MessageEntity.Outgoing
  8. {
  9. public class PresetAmountRequest : MessageBase
  10. {
  11. public PresetAmountRequest(int amountWithoutDecimalPoint, byte amountFieldLength)
  12. {
  13. if (amountFieldLength != 3 && amountFieldLength != 4)
  14. throw new ArgumentException("预置字段长度应为 3 or 4");
  15. if (amountFieldLength == 3
  16. && (amountWithoutDecimalPoint > 999999 || amountWithoutDecimalPoint <= 0))
  17. throw new ArgumentException("664机型预置金额区为3字节, so should range from 0 to 999999");
  18. if (amountFieldLength == 4
  19. && (amountWithoutDecimalPoint > 99999999 || amountWithoutDecimalPoint <= 0))
  20. throw new ArgumentException("886机型预置金额区为4字节, so should range from 0 to 99999999");
  21. this.BodyAndXRL = amountWithoutDecimalPoint.GetBCDBytes(amountFieldLength).ToList();
  22. // cmd byte
  23. this.BodyAndXRL.Add(0xB5);
  24. // add a place hold for XRL
  25. this.BodyAndXRL.Add(0);
  26. }
  27. }
  28. }