
namespace irisMemory
{
    public class IdentifyConfig
    {
        /**
         * ★是否允许找眼标志位
         * =1表示允许；=0表示退出
         */
        private volatile bool flagFindingEye;
        private volatile bool flagFoundEye; // 是否找到合格眼睛标志位，用于表示是否进入识别过程

        /**
         * ★进入识别过程前，连续没找到眼的次数
         */
        private volatile int countNoEyeLast;

        /**
         * ★进入识别后，尝试找眼及识别次数
         */
        private volatile int countTryIdentify;

        /// <summary>
        /// 识别开始毫秒数
        /// </summary>
        private long identifyStart;

        /// <summary>
        /// 识别成功结束毫秒数
        /// </summary>
        private long identifyEnd;

        /**
         * ★识别过程id
         * ="" 表示不在识别过程中；不为空表示在识别过程中，值为找到眼的时刻值
         */
        private string identifyTaskId; // 一次识别过程的id

        private IdentifyConfig()
        {
            this.InitConfig();
        }

        /**
         * 初始化识别过程控制参数
         */
        public void InitConfig()
        {
            this.FlagFindingEye = false;
            this.FlagFoundEye = false;

            this.CountNoEyeLast = 0;
            this.CountTryIdentify = 0;

            this.IdentifyStart = 0;

            this.IdentifyTaskId = "";
        }

        /// <summary>
        /// 开始一次识别过程
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="millsecond"></param>
        public void StartIdentify(string taskId, long millsecond)
        {
            this.CountNoEyeLast = 0;
            this.countTryIdentify = 0;

            this.IdentifyTaskId = taskId;
            this.IdentifyStart = millsecond;
        }

        public void EndIdentify()
        {
            this.IdentifyStart = 0;
        }

        private static readonly IdentifyConfig identifyConfig = new IdentifyConfig();

        public static IdentifyConfig GetInstance { get => identifyConfig; }

        public bool FlagFindingEye { get => flagFindingEye; set => flagFindingEye = value; }
        public bool FlagFoundEye { get => flagFoundEye; set => flagFoundEye = value; }
        public int CountNoEyeLast { get => countNoEyeLast; set => countNoEyeLast = value; }
        public int CountTryIdentify { get => countTryIdentify; set => countTryIdentify = value; }

        public string IdentifyTaskId { get => identifyTaskId; set => identifyTaskId = value; }
        public long IdentifyStart { get => identifyStart; set => identifyStart = value; }
    }
}
