using System.IO.Ports;
using ChuPiao.AutoPrint.Machine.Models;
using ChuPiao.AutoPrint.Machine.Printer;
using ChuPiao.Common.Models;
using log4net;

namespace ChuPiao.AutoPrint.Machine
{
    public enum VirtualPrinterStatus
    {
        Running,
        Stopping,
        Stopped,
        Exception
    }
    public interface IVirtualPrinter
    {
        #region 属性
        /// <summary>
        /// 打印机状态
        /// </summary>
        VirtualPrinterStatus Status { get; set; }
        /// <summary>
        /// 日志记录器
        /// </summary>
        ILog Log { get; set; }
        /// <summary>
        /// 日志路径，不单单是日志，还有彩票机的电子票文件等都在这个路径下面，格式如：C:\example\
        /// </summary>
        string LogPath { get;set;}
        /// <summary>
        /// 端口
        /// </summary>
        SerialPort PrinterPort { get; set; }
        /// <summary>
        /// 端口号
        /// </summary>
        string Port { get; set; }
        /// <summary>
        /// 端口波特率
        /// </summary>
        int PortBps { get; set; }

        /// <summary>
        /// 彩票机相关信息
        /// </summary>
        M_MachineEntity MachineInfo { get; set; }
        /// <summary>
        /// 
        /// </summary>
        ILotMachine LotMachine { get;set;}
        /// <summary>
        /// 彩票打印机
        /// </summary>
        IPrinterClient PrinterClient { get; set; }

        #endregion

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

        /// <summary>
        /// 启动
        /// </summary>
        void Start();

        /// <summary>
        /// 停止
        /// </summary>
        void Stop();

        /// <summary>
        /// 输出电子票数据
        /// </summary>
        /// <returns></returns>
        CaptureDataInfo Output();

        /// <summary>
        /// 输出电子票数据
        /// </summary>
        /// <returns></returns>
        CaptureDataInfo ReOutput();



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

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

        /// <summary>
        /// 打印计数器
        /// </summary>
        int LastPrintCounter { get; set; }

        /// <summary>
        /// 最近的打印文件路径
        /// </summary>
        string LastPrintFilePath { get; set; }

        void SaveLastFile(byte[] captureDataBytes);

        void DeleteLastFile();

        #endregion
    }
}
