using System;
using Edge.Core.Parser.BinaryParser.Attributes;

namespace HengshanPaymentTerminal.MessageEntity.Outgoing
{
    /// <summary>
    /// System's response for the inquiry request from pump.
    /// 后台对查询命令Check_cmd的回复
    /// </summary>
    public class InquiryResult : CardMessageBase
    {
        #region Constructor

        public InquiryResult() : base(Command.Ver_info)
        {
            
        }

        #endregion

        #region Properties

        /// <summary>
        /// PC_TIME, System time.
        /// 后台时间，7字节压缩BCD。
        /// </summary>
        [Format(7, EncodingType.BcdString, -90)]
        public long Time { get; private set; }

        /// <summary>
        /// BL_VER, Base black list version.
        /// 基础黑名单版本。
        /// </summary>
        [Format(2, EncodingType.BIN, -89)]
        public ushort BaseBlacklistVersion { get; set; }

        /// <summary>
        /// ADD_BL_VER, Newly added black list version.
        /// 新增黑名单版本。
        /// </summary>
        [Format(1, EncodingType.BIN, -88)]
        public byte NewlyAddedBlacklistVersion { get; set; }

        /// <summary>
        /// DEL_BL_VER, Newly deleted black list version.
        /// 新删黑名单版本。
        /// </summary>
        [Format(1, EncodingType.BIN, -87)]
        public byte NewlyDeletedBlacklistVersion { get; set; }

        /// <summary>
        /// WH_VER, Whitelist version.
        /// 白名单版本号。
        /// </summary>
        [Format(1, EncodingType.BIN, -86)]
        public byte WhitelistVersion { get; set; }

        /// <summary>
        /// PRC_VER, Fuel price version.
        /// 油品油价版本。
        /// </summary>
        [Format(1, EncodingType.BIN, -85)]
        public byte FuelPriceVersion { get; set; }

        /// <summary>
        /// Sta_VER, Station general information version.
        /// 油站通用信息版本。
        /// </summary>
        [Format(1, EncodingType.BIN, -84)]
        public byte StationGeneralInfoVersion { get; set; }

        /// <summary>
        /// SELF_D_VER, Reecipt info version for printers.
        /// 打印机凭条信息版本。
        /// </summary>
        [Format(1, EncodingType.BIN, -83)]
        public byte PrinterReceiptInfoVersion { get; set; }

        /// <summary>
        /// SOFT_FLAG, Flag indicating whether pump SW update is available or not, 0: No update, 1: Update required.
        /// 加油机程序下载更新标志，0：无数据，1：有新的程序需要下载。
        /// </summary>
        [Format(1, EncodingType.BIN, -82)]
        public byte SoftwareDownloadFlag { get; set; }

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

        #endregion

        #region Methods

        /// <summary>
        /// Set the PC time
        /// </summary>
        /// <param name="timeStamp">Current time on PC/Fusion/后台.</param>
        public void SetTime(DateTime timeStamp)
        {
            var formattedTime = timeStamp.ToString("yyyyMMddHHmmss");
            Time = long.Parse(formattedTime);
        }

        #endregion
    }
}
