using Edge.Core.Parser.BinaryParser.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LanTian_Pump_664_Or_886.MessageEntity.Incoming
{
public class ReadFuelDataResponse : MessageBase
{
/*only used for unit test purpose*/
public void SetAmountAndVolume(int amount, int volume)
{
base.BodyAndXRL = volume.GetBCDBytes(3).Concat(amount.GetBCDBytes(3))
.Concat(new byte[] { 0x00, 0x00 }).ToList();
}
///
/// Without decimal points
///
public int Volume
{
get
{
if (base.BodyAndXRL.Count - 2 == 6)
{
/*Model 664*/
return base.BodyAndXRL.Take(3).GetBCD();
}
else if (base.BodyAndXRL.Count - 2 == 8)
{
/*Model 886*/
return base.BodyAndXRL.Take(4).GetBCD();
}
throw new InvalidDataException("data body length should either 6 or 8, but now is: " + (base.BodyAndXRL.Count - 1));
}
}
///
/// Without decimal points
///
public int Amount
{
get
{
if (base.BodyAndXRL.Count - 2 == 6)
{
/*Model 664*/
return base.BodyAndXRL.Skip(3).Take(3).GetBCD();
}
else if (base.BodyAndXRL.Count - 2 == 8)
{
/*Model 886*/
return base.BodyAndXRL.Skip(4).Take(4).GetBCD();
}
throw new InvalidDataException("data body length should either 6 or 8, but now is: " + (base.BodyAndXRL.Count - 1));
}
}
}
}