1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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();
- }
- /// <summary>
- /// Without decimal points
- /// </summary>
- 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));
- }
- }
- /// <summary>
- /// Without decimal points
- /// </summary>
- 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));
- }
- }
- }
- }
|