using Edge.Core.Parser.BinaryParser.Attributes;
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 ChangePriceRequest : MessageBase
{
///
///
///
/// 664机型单价区为2字节
/// 2 or 3
public ChangePriceRequest(int newPriceWithoutDecimalPoint, byte priceFieldLength)
{
if (priceFieldLength != 2 && priceFieldLength != 3)
throw new ArgumentException("单价字段长度应为 2 or 3");
if (priceFieldLength == 2
&& (newPriceWithoutDecimalPoint > 9999 || newPriceWithoutDecimalPoint <= 0))
throw new ArgumentException("664机型单价区为2字节, so should range from 0 to 9999");
if (priceFieldLength == 3
&& (newPriceWithoutDecimalPoint > 999999 || newPriceWithoutDecimalPoint <= 0))
throw new ArgumentException("886机型单价区为3字节, so should range from 0 to 999999");
this.BodyAndXRL = newPriceWithoutDecimalPoint.GetBCDBytes(priceFieldLength).ToList();
// cmd byte
this.BodyAndXRL.Add(0xB2);
// add a place hold for XRL
this.BodyAndXRL.Add(0);
}
}
}