using Edge.Core.Parser.BinaryParser.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LanTian_Pump_664_Or_886.MessageEntity.Outgoing { public class PresetAmountRequest : MessageBase { public PresetAmountRequest(int amountWithoutDecimalPoint, byte amountFieldLength) { if (amountFieldLength != 3 && amountFieldLength != 4) throw new ArgumentException("预置字段长度应为 3 or 4"); if (amountFieldLength == 3 && (amountWithoutDecimalPoint > 999999 || amountWithoutDecimalPoint <= 0)) throw new ArgumentException("664机型预置金额区为3字节, so should range from 0 to 999999"); if (amountFieldLength == 4 && (amountWithoutDecimalPoint > 99999999 || amountWithoutDecimalPoint <= 0)) throw new ArgumentException("886机型预置金额区为4字节, so should range from 0 to 99999999"); this.BodyAndXRL = amountWithoutDecimalPoint.GetBCDBytes(amountFieldLength).ToList(); // cmd byte this.BodyAndXRL.Add(0xB5); // add a place hold for XRL this.BodyAndXRL.Add(0); } } }