using Edge.Core.Parser.BinaryParser.Attributes;
using HengshanPaymentTerminal.Support;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HengshanPaymentTerminal.MessageEntity.Incoming
{
    /// <summary>
    /// Inquiry request from pump against system/EPS.
    /// 加油机查询命令Check_cmd，空闲时对后台发，命令字0x10.
    /// </summary>
    public class CheckCmdRequest : CardMessageBase
    {
        public CheckCmdRequest() : base(Command.Check_cmd)
        {

        }

        [Format(4, EncodingType.HexString, -90)]
        public string TerminalId { get; set; }

        /// <summary>
        /// Fueling point code, first byte is nozzle number, second pump number.
        /// 加油点，字节1为枪号，字节2为泵号。
        /// </summary>
        [Format(2, EncodingType.HexString, -89)]
        public string FPCode { get; set; }

        [Format(1, EncodingType.BIN, -88)]
        public byte WorkMode { get; set; }

        //public WorkMode WorkMode { get; set; }
        [Format(1, EncodingType.BIN, -87)]
        public byte DispenserState { get; set; }
        //public DispenserState DispenserState { get; set; }

        [Format(1, EncodingType.BIN, -86)]
        public int AuthState { get; set; }

        [Format(3, EncodingType.BIN, -85)]
        public int Amount { get; set; }

        [Format(3, EncodingType.BIN, -84)]
        public int Volume { get; set; }

        [Format(2, EncodingType.BIN, -83)]
        public int Price { get; set; }

        #region Specified but not appeared
        //probably these are used when it's a CNG/LNG pump

        public int ValveNo { get; set; }

        public int PressureValue { get; set; }

        public int FlowValue { get; set; }

        public int Temperature { get; set; }

        public byte LockState { get; set; }

        public FuelingPointCode FuelingPoint
        {
            get
            {
                return new FuelingPointCode
                {
                    NozzleNo = FPCode.Substring(0, 2).ToByte(),
                    PumpNo = FPCode.Substring(2, 2).ToByte()
                };
            }
        }

        #endregion
    }
}
