/// <summary>
        /// 关闭播放的录像文件
        /// </summary>
        /// <returns>true表示成功,false表示失败</returns>
        public bool Close()
        {
            if (this.player == null) return false;

            if (this.player.OpenState == OpenStateEnum.FilePlay)
            {
                this.player.Close();

                this.player = null;
            }

            return true;
        }
        /// <summary>
        /// 根据区域名和设备名打开这个设备在参数time时间所录的录像文件
        /// </summary>
        /// <param name="area">区域名</param>
        /// <param name="device">设备名</param>
        /// <param name="time">时间</param>
        /// <returns>true表示成功,false表示失败</returns>
        public bool Open(string area, string device, DateTime time)
        {
            if (this.player != null)
            {
                if (this.player.OpenState != OpenStateEnum.Close)
                {
                    this.player.Close();
                }

                if (this.area != area || this.device != device)
                {
                    this.player = null;//如果设备发生改变,则需重新创建Player
                }

                //this.Invalidate();//刷新
            }

            if (this.player == null)
            {
                //获取配置信息
                this.configInfo = FileConfigReader.SingleConfig[area, device];

                if (this.configInfo == null)
                    throw new ApplicationException(string.Format("Get area {0} device {1} config failed!|Initialize", area, device));

                //动态加载播放模块
                this.player = this.CreateType(configInfo["PlayerFile"], configInfo["PlayerType"]) as IPlayer.IPlayerSDK;
                //添加绘图委托
                this.player.PaintCallback = new PaintCallback(this.PlayerPaintCall);

            }

            //获取录像文件全路径
            string file = FilePath.GetDatePathTimeFile(this.configInfo["record"], area, device, time, "mp4");

            if (!File.Exists(file)) return false;

            if (this.player.Open(file, this.Handle))
            {
                this.area = area;
                this.device = device;
                this.startTime = time;//录像起始时间
                return true;
            }
            else
                return false;
        }
        /// <summary>
        /// 初始化设备
        /// </summary>
        /// <param name="area">设备的区域名</param>
        /// <param name="device">设备的设备名</param>
        /// <returns>true表示成功,false表示失败</returns>
        public bool Initialize(string area, string device)
        {
            if (this.isInitialized) return true;

            //获取配置信息
            this.configInfo = FileConfigReader.SingleConfig[area, device];

            if (this.configInfo == null)
                throw new ApplicationException(string.Format("Get area {0} device {1} config failed!|Initialize", area, device));

            //动态加载播放模块
            //this.player = this.CreateType(configInfo["PlayerFile"], configInfo["PlayerType"]) as IPlayer.IPlayerSDK;
            this.player = new PlayerSDKHC();
            this.player.DecodeCallback = new DecodeCallback(DecodeCall);
            //this.recordReader = this.CreateType(configInfo["PlayerFile"], configInfo["PlayerType"]) as IPlayer.IPlayerSDK;
            this.recordReader = new PlayerSDKHC();

            //动态加载视频模块
            //this.video = this.CreateType(configInfo["VideoFile"], configInfo["VideoType"]) as IVideoSDK;
            this.video = new VideoSDKHC();
            this.video.RealStreamCallback = new RealStreamCallback(this.player.Open);
            this.video.PaintCallback = new IVideo.PaintCallback(this.PaintCall);

            //动态加载识别模块
            //this.analyze = this.CreateType(configInfo["AnalyzeFile"], configInfo["AnalyzeType"]) as IAnalyze.IAnalyze;
            this.analyze = new SmokeFireAnalyze.SmokeFireAnalyze();

            //报警保存
            this.alarmWriter = new FileAlarmWriter();

            //动态加载识别策略模块
            //this.analyzeStrategy = this.CreateType(configInfo["AnalyzeStrategyFile"], configInfo["AnalyzeStrategyType"]) as IAnalyze.IAnalyzeStrategy;
            this.analyzeStrategy = new SmokeFireAnalyze.SmokeFireAnalyzeStrategy();

            this.analyzeStrategy.Analyze = this.analyze;
            this.analyzeStrategy.AnalyzeBegin += new EventHandler<IAnalyze.EventArgsAnalyzeBegin>(analyzeStrategy_AnalyzeBegin);
            this.analyzeStrategy.AnalyzeAlarm += new EventHandler<IAnalyze.EventArgsAnalyzeAlarm>(analyzeStrategy_AnalyzeAlarm);
            this.analyzeStrategy.AnalyzeEnd += new EventHandler<IAnalyze.EventArgsAnalyzeEnd>(analyzeStrategy_AnalyzeEnd);

            //动态加载巡航脚本模块
            //this.cruise = this.CreateType(configInfo["CruiseFile"], configInfo["CruiseType"]) as IScript.ICruiseAnalyzeScript;
            this.cruise = new TimeCruise();

            this.cruise.ScriptCallFucntion = new CallFunctionCallback(this.CallFunction);
            this.cruise.ScriptCallParameter = new CallParameterCallback(this.CallParameter);

            this.areaName = area;
            this.deviceName = device;

            //获取水平修正角
            if (!short.TryParse(this.configInfo["revise"], out this.revise))
                this.revise = 0;

            //获取经度
            if (!uint.TryParse(this.configInfo["longitude"], out this.longitude))
                longitude = Convert.ToUInt32(random.Next(5000));

            //获取纬度
            if (!uint.TryParse(this.configInfo["latitude"], out this.latitude))
                this.latitude = Convert.ToUInt32(random.Next(5000));

            //获取高度
            if (!uint.TryParse(this.configInfo["high"], out this.high))
                this.high = Convert.ToUInt32(random.Next(100, 500));

            //是否能开启透明通道
            bool.TryParse(configInfo["videotransfer"], out this.enableTransfer);

            this.ip = this.configInfo["ip"];

            if (ushort.TryParse(this.configInfo["port"], out this.port)) this.port = 8000;
            this.user = this.configInfo["user"];
            this.password = this.configInfo["password"];

            if (!byte.TryParse(this.configInfo["channel"], out this.channel))
                this.channel = 1;

            this.isInitialized = true;
            this.State |= StateType.Initial;
            OnInitialized();

            return true;
        }