ChangePriceRequest.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace LanTian_Pump_664_Or_886.MessageEntity.Outgoing
  9. {
  10. public class ChangePriceRequest : MessageBase
  11. {
  12. /// <summary>
  13. ///
  14. /// </summary>
  15. /// <param name="newPriceWithoutDecimalPoint">664机型单价区为2字节</param>
  16. /// <param name="priceFieldLength">2 or 3</param>
  17. public ChangePriceRequest(int newPriceWithoutDecimalPoint, byte priceFieldLength)
  18. {
  19. if (priceFieldLength != 2 && priceFieldLength != 3)
  20. throw new ArgumentException("单价字段长度应为 2 or 3");
  21. if (priceFieldLength == 2
  22. && (newPriceWithoutDecimalPoint > 9999 || newPriceWithoutDecimalPoint <= 0))
  23. throw new ArgumentException("664机型单价区为2字节, so should range from 0 to 9999");
  24. if (priceFieldLength == 3
  25. && (newPriceWithoutDecimalPoint > 999999 || newPriceWithoutDecimalPoint <= 0))
  26. throw new ArgumentException("886机型单价区为3字节, so should range from 0 to 999999");
  27. this.BodyAndXRL = newPriceWithoutDecimalPoint.GetBCDBytes(priceFieldLength).ToList();
  28. // cmd byte
  29. this.BodyAndXRL.Add(0xB2);
  30. // add a place hold for XRL
  31. this.BodyAndXRL.Add(0);
  32. }
  33. }
  34. }