using Edge.Core.Parser.BinaryParser.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Wayne_Pump_Dart.MessageEntity.Incoming
{
///
/// The pump sends this transaction if Request Total Counters is received.
///
public class TotalCounters_TransactionData
{
private TransactionData transactionData;
public TotalCounters_TransactionData(TransactionData transactionData)
{
if (transactionData.TransactionNumber != 0x65)
throw new ArgumentException("TotalCounters_TransactionData must have transaction number 0x65");
if (transactionData.Length != 0x10)
throw new ArgumentException("TotalCounters_TransactionData must have length 16");
this.transactionData = transactionData;
}
///
/// Combine with `TotalValue`, `Meter1_TotalValue_Or_NumberOfFill` or `Meter2_TotalValue` property
/// to know what's this proerperty for.
///
public byte LogicalNozzleNumber { get { return this.transactionData.RawData.First(); } }
///
/// `LogicalNozzleNumber` 01H-08H: this property is the Volume Totals for specifiec logical nozzle
/// `LogicalNozzleNumber` 09H: this property is the sum of all logical nozzle Volume totals.
/// `LogicalNozzleNumber` 11H-18H: this property is the Amount Totals for logical nozzle(substract 10H to get real logical nozzle number)
/// `LogicalNozzleNumber` 19H: this property is the sum of all logical nozzle Amount totals.
///
public int TotalValue { get { return this.transactionData.RawData.Skip(1).Take(5).GetBCD(); } }
///
/// `LogicalNozzleNumber` 01H-08H: this property is the Primary meter Volume totals for logical nozzle.
/// `LogicalNozzleNumber` 09H: this property is Not used shall be zero (0).
/// `LogicalNozzleNumber` 11H-18H: this property is the Number of fillings for logical nozzle(substract 10H to get real logical nozzle number)
/// `LogicalNozzleNumber` 19H: this property is the Total no of fillings for whole pump.
///
public int Meter1_TotalValue_Or_NumberOfFill { get { return this.transactionData.RawData.Skip(6).Take(5).GetBCD(); } }
///
/// `LogicalNozzleNumber` 01H-08H: this property is the Secondary meter Volume totals for logical nozzle.
/// `LogicalNozzleNumber` 09H: this property is Not used shall be zero (0).
/// `LogicalNozzleNumber` 11H-19H: this property is Not used shall be zero (0).
///
public int Meter2_TotalValue { get { return this.transactionData.RawData.Skip(11).Take(5).GetBCD(); } }
}
}