using Org.BouncyCastle.Asn1.Ocsp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HengshanPaymentTerminal.MessageEntity.Outgoing
{
    /// <summary>
    /// 发送取消授权给油机数据对象
    /// </summary>
    public class SendUnAuthorization:CommonMessage
    {
        /// <summary>
        /// 请求授权的枪号
        /// </summary>
        public int NozzleNum { get; set; }

        /// <summary>
        /// 请求授权时间
        /// </summary>
        private DateTime AuthorizationTime { get; set; }

        /// <summary>
        /// 授权后分配的流水号
        /// </summary>
        private int TTC {  get; set; }

        public SendUnAuthorization(int nozzleNum, DateTime authorizationTime, int tTC,byte frame)
        {
            this.Handle = (byte)Command.CANCEL_ACCREDIT;
            NozzleNum = nozzleNum;
            AuthorizationTime = authorizationTime;
            TTC = tTC;
            this.FrameNum = frame;
        }

        public override byte[] ToCommonByteArray()
        {
            List<Byte> list = new List<Byte>();
            byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
            byte[] authorizationTimeBytes = ConvertDateTimeToByteArray(this.AuthorizationTime);

            byte[] ttcBytes = NumberToByteArrayWithPadding(this.TTC, 4);
            list.AddRange(commandAndNozzle);
            list.AddRange(authorizationTimeBytes);
            list.AddRange(ttcBytes);
            byte[] sendBytes = content2data(list.ToArray());

            return sendBytes;
        }

        public override CommonMessage ToObject(byte[] datas)
        {
            return this;
        }
    }
}
