using System;
using System.Collections.Generic;
using ChuPiao.AutoPrint.Machine.Models;
using ChuPiao.AutoPrint.Machine.Printer;
using ChuPiao.Common.Models;
using log4net;

namespace ChuPiao.AutoPrint.Machine
{
    /// <summary>
    /// 彩票机接口
    /// </summary>
    public interface ILotMachine
    {
        L_LotTicketEntity CurrentTicket { get;set;}

        #region 属性
        /// <summary>
        /// 日志记录器
        /// </summary>
        ILog Log { get; set; }
        /// <summary>
        /// 机器当前投注模式
        /// </summary>
        M_MachineModeConfigEntity MacCurrentMode { get; set; }
        /// <summary>
        /// 机器当前期
        /// </summary>
        string MacCurrentExpect { get; set; }
        /// <summary>
        /// 彩票机相关信息
        /// </summary>
        M_MachineEntity MachineInfo { get; set; }
        /// <summary>
        /// 模拟键盘（键盘线）
        /// </summary>
        IVirtualKeyboard VirtualKeyboard { get; set; }

        /// <summary>
        /// 模拟打印机（打印模块）
        /// </summary>
        IVirtualPrinter VirtualPrinter { get; set; }

        /// <summary>
        /// 彩票打印机
        /// </summary>
        IPrinterClient PrinterClient { get; set; }
        /// <summary>
        /// 是否已打印测试票
        /// </summary>
        bool IsPrintedTest { get; set; }

        /// <summary>
        /// 玩法映射
        /// </summary>
        Dictionary<int, M_LotPlayModeMapEntity> LotPlayMap { get; }

        /// <summary>
        /// 最近一次机器报表
        /// </summary>
        R_MachineReportEntity LastMachineReport { get; set; }

        /// <summary>
        /// 最后一次兑奖是否成功
        /// </summary>
        bool LastEncashSuc { get; set; }
        #endregion

        /// <summary>
        /// 彩票机充值
        /// </summary>
        void Recharge(int money);

        #region 方法
        /// <summary>
        /// 彩票机初始化
        /// </summary>
        void Initialize();

        /// <summary>
        /// 启动驱动
        /// </summary>
        void StartDriver();

        /// <summary>
        /// 停止驱动
        /// </summary>
        void StopDriver();

        /// <summary>
        /// 重启驱动
        /// </summary>
        void ReStartDriver();

        /// <summary>
        /// 打印指定的票
        /// </summary>
        void Print(L_LotTicketEntity ticketEntity, DecodePrintData decodePrintData);

        /// <summary>
        /// 测试电子票解析
        /// </summary>
        /// <param name="ticketEntity"></param>
        /// <param name="decodePrintData"></param>
        void TestDecodeTicket(L_LotTicketEntity ticketEntity, DecodePrintData decodePrintData);

        /// <summary>
        /// 重新获取数据
        /// </summary>
        /// <param name="ticketEntity"></param>
        /// <param name="decodePrintData"></param>
        void ReGetdata(L_LotTicketEntity ticketEntity, DecodePrintData decodePrintData);

        /// <summary>
        /// 获取缓冲区票
        /// </summary>
        /// <returns></returns>
        CaptureDataInfo GetCacheTicket();
        /// <summary>
        /// 获取最后一张票
        /// </summary>
        /// <returns></returns>
        CaptureDataInfo GetLastTicket();

        /// <summary>
        /// 强行停止当前票
        /// </summary>
        void ForceStop();

        /// <summary>
        /// 兑奖指定的票
        /// </summary>
        /// <param name="ticketEntity"></param>
        void Encash(L_LotTicketEntity ticketEntity);

        /// <summary>
        /// 打印缴款报表
        /// </summary>
        /// <returns></returns>
        void PrintPayMoneyReport(DecodeMachinePayMoneyReport decodePrintData, bool isPaperOut);
        /// <summary>
        /// 打印机器报表
        /// </summary>
        /// <returns></returns>
        void PrintReport(DateTime startTime, DateTime endTime, DecodeMachineReport decodePrintData, bool isPaperOut);
        /// <summary>
        /// 打印竟彩机器报表
        /// </summary>
        /// <returns></returns>
        void PrintJcReport(DateTime startTime, DateTime endTime, DecodeMachineReport decodePrintData, bool isPaperOut);

        /// <summary>
        /// 打印当天报表
        /// </summary>
        /// <param name="decodePrintData"></param>
        void PrintCurrentDayReport(DecodeMachineReport decodePrintData, bool isPaperOut);
        /// <summary>
        /// 打印机器玩法报表
        /// </summary>
        /// <returns></returns>
        void PrintPlayReport(M_PlayTypeEntity playTypeEntity, DateTime startTime, DateTime endTime, DecodeMachinePlayReport decodePrintData, bool isPaperOut);

        /// <summary>
        /// 查看机器中奖金额
        /// </summary>
        /// <param name="ticketEntity"></param>
        void ViewPrizeMoney(L_LotTicketEntity ticketEntity);

        /// <summary>
        /// 登录彩票机
        /// </summary>
        void Login();

        /// <summary>
        /// 关闭彩票机
        /// </summary>
        void Shutdown();

        /// <summary>
        /// 打印测试票
        /// </summary>
        CaptureDataInfo PrintTestTicket(bool isPaperOut);

        /// <summary>
        /// 打印对阵信息
        /// </summary>
        CaptureDataInfo PrintMatch(int lotId);

        /// <summary>
        /// 打印足彩对阵信息
        /// </summary>
        /// <param name="lotId">足彩彩种id</param>
        /// <param name="index">1-当前期；2-下一期；3-下下期</param>
        /// <returns></returns>
        CaptureDataInfo PrintZcMatch(int lotId, int index);

        /// <summary>
        /// 打印开奖报表
        /// </summary>
        CaptureDataInfo PrintOpenCodeReport(int lotId);

        /// <summary>
        /// 清楚彩票机合计金额
        /// </summary>
        /// <returns>是否成功</returns>
        void ClearMahineMoney();

        /// <summary>
        /// 清除彩票机错误
        /// </summary>
        /// <param name="errorType"></param>
        void ClearError(int errorType);

        /// <summary>
        /// 清除彩票机弹窗“奖期已更新”（竟彩）
        /// </summary>
        void ClearExpectUpdate();

        /// <summary>
        /// 刷新机器额度
        /// </summary>
        /// <returns></returns>
        void RefreshMahineMoney();
        /// <summary>
        /// 刷新广播信息
        /// </summary>
        /// <returns></returns>
        void RefreshMahineBroadcast();

        /// <summary>
        /// 清空接收数据缓存
        /// </summary>
        void ClearBuffer();

        /// <summary>
        /// 发送键码
        /// </summary>
        /// <param name="keycodeInfoList"></param>
        void SendKeys(List<KeycodeInfo> keycodeInfoList);

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        CaptureDataInfo GetData();

        /// <summary>
        /// 切换当前玩法
        /// </summary>
        /// <param name="ticketEntity"></param>
        void SetCurrentLotPlayMode(L_LotTicketEntity ticketEntity);

        /// <summary>
        /// 返回顶级界面（多乐彩）
        /// </summary>
        void ReturnTopGui();

        /// <summary>
        /// 进入销售主界面（竟彩）
        /// </summary>
        void EnterSaleGui();
        #endregion

        #region 事件
        /// <summary>
        /// 出票中
        /// </summary>
        event EventHandler<TicketEventArgs> Printing;
        /// <summary>
        /// 出票完成
        /// </summary>
        event EventHandler<TicketEventArgs> Printed;
        /// <summary>
        /// 兑奖中
        /// </summary>
        event EventHandler<TicketEventArgs> Encashing;
        /// <summary>
        /// 兑奖完成
        /// </summary>
        event EventHandler<TicketEventArgs> Encashed;
        /// <summary>
        /// 机器状态变化
        /// </summary>
        //event EventHandler<MachineStatusArgs> StatusChanged;

        #endregion
    }
}
