public void Unitialize()
        {
            //_waitForInitCompletedMetux.Set();
            _fLogService.Info("Release hardware object...");
            #region 释放发送卡数据读取对象
            if (_readDviInfo != null)
            {
                _readDviInfo.CompleteRefreshDviInfoEvent -= new CompleteRefreshSenderDviEventHandler(ReadDviInfo_CompleteRefreshDviInfoEvent);
                _readDviInfo.CompleteRetryRefreshDviInfoEvent -= _readDviInfo_CompleteRetryRefreshDviInfoEvent;
                _readDviInfo.Dispose();
                _readDviInfo = null;
            }
            #endregion

            #region 释放常规监控数据读取对象
            if (_hwStatusMonitor != null)
            {
                _hwStatusMonitor.CompleteRefreshAllCommPortEvent -= new CompleteRefreshAllCommPortEventHandler(HWStatusMonitor_CompleteRefreshAllCommPortEvent);
                _hwStatusMonitor.BeginReadSBMonitorInfoEvent -= _hwStatusMonitor_BeginReadSBMonitorInfoEvent;
                _hwStatusMonitor.CompleteReadSBMonitorInfoEvent -= _hwStatusMonitor_CompleteReadSBMonitorInfoEvent;
                _hwStatusMonitor.CompleteRetryReadSBMonitorInfoEvent -= HWStatusMonitor_CompleteRetryReadSBMonitorInfoEvent;
                _hwStatusMonitor.Dispose();
                _hwStatusMonitor = null;
            }
            #endregion

            #region 硬件亮度配置
            if (_smartBright != null)
            {
                _smartBright.OutputLogEvent -= _smartBright_OutputLogEvent;
                _smartBright.Dispose();
                _smartBright = null;
            }
            _smartLightAccessor = null;
            #endregion

            #region 释放多功能卡外设监控数据读取对象
            //多功能卡对象不包含要释放的资源,这里不需要处理
            _funcMonitor = null;
            #endregion

            Interlocked.Exchange(ref _isRunningMetux, 0);
        }
        private void OnCompleteReadAllComHWBaseInfoCallback(CompleteReadAllComHWBaseInfoParams allBaseInfo, object userToken)
        {
            #region 组合硬件读取到的数据
            _globalParams.AllBaseInfo = allBaseInfo.AllInfo;
            if (_globalParams.SupperDisplayList != null)
            {
                _globalParams.SupperDisplayList.Clear();
            }
            foreach (KeyValuePair<string, OneCOMHWBaseInfo> pair in allBaseInfo.AllInfo.AllInfoDict)
            {
                string firstSN = pair.Value.FirstSenderSN;
                for (int i = 0; i < pair.Value.LEDDisplayInfoList.Count; i++)
                {
                    string udid = firstSN + i.ToString("x2");
                    List<OneScreenInSupperDisplay> scrList = new List<OneScreenInSupperDisplay>();
                    scrList.Add(new OneScreenInSupperDisplay()
                        {
                            ScreenUDID = udid,
                        });
                    SupperDisplay supper = new SupperDisplay()
                    {
                        DisplayName = "DisplayName",
                        DisplayUDID = udid,
                        ScreenList = scrList
                    };

                    _globalParams.SupperDisplayList.Add(supper);
                }
            }
            #endregion

            #region 从数据库读取配置
            SQLiteAccessor accessor = SQLiteAccessor.Instance;
            if (accessor == null)
            {
                Debug.WriteLine("数据库对象错误,终止智能亮度");
                return;
            }
            List<DisplaySmartBrightEasyConfig> cfgList = accessor.GetAllNeedEasyConfig(new SmartBrightSeleCondition() { BrightAdjMode = BrightAdjustMode.SmartBright, DataVersion = -1 });
            
            
            #endregion

            #region 开始智能亮度
            if (_smartBrightManager != null)
            {
                _smartBrightManager.Dispose();
                _smartBrightManager = null;
            }
            _smartBrightManager = new SmartBright(_proxy, _globalParams.AllBaseInfo, _globalParams.SupperDisplayList);
            _globalParams.SmartBrightManager = _smartBrightManager;

            for (int i = 0; i < cfgList.Count; i++)
            {
                DisplaySmartBrightEasyConfig cfg = cfgList[i];
                if (cfg != null &&
                    cfg.OneDayConfigList != null)
                {
                    int index = _globalParams.SupperDisplayList.FindIndex(delegate(SupperDisplay supperTemp)
                    {
                        if (supperTemp.DisplayUDID == cfg.DisplayUDID)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    });
                    if (index != -1)
                    {
                        _smartBrightManager.AttachSmartBright(cfg.DisplayUDID, cfg);
                    }
                }
            }

            #endregion
        }
        public InitialErryType Initialize()
        {
            _fLogService.Info("Mars开始硬件初始化...");
            lock (_lockCallBack)
            {
                _dicCallBack.Clear();
            }
            if (_allComBaseInfo_Bak == null)
            {
                _allComBaseInfo = new AllCOMHWBaseInfo();
                _allComBaseInfo.AllInfoDict = new SerializableDictionary<string, OneCOMHWBaseInfo>();
                OnNotifyExecResEvent(
                    TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                    UpdateCfgFileResType.OK);
                return InitialErryType.NoServer;
            }
            else
            {
                if (_allComBaseInfo_Bak.AllInfoDict == null || _allComBaseInfo_Bak.AllInfoDict.Count == 0)
                {
                    _allComBaseInfo = new AllCOMHWBaseInfo();
                    _allComBaseInfo.AllInfoDict = new SerializableDictionary<string, OneCOMHWBaseInfo>();
                    OnNotifyExecResEvent(
                        TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                        UpdateCfgFileResType.OK);
                    return InitialErryType.GetBaseInfoErr;
                }
            }
            _hwConfigs = new Dictionary<string, MarsHWConfig>();
            #region 初始化屏体等相关信息
            InitializeScreen(_allComBaseInfo_Bak);
            #endregion
            #region 初始化发送卡数据读取对象
            _readDviInfo = new ReadSenderDviInfo(_serverProxy);
            _readDviInfo.CompleteRefreshDviInfoEvent += new CompleteRefreshSenderDviEventHandler(ReadDviInfo_CompleteRefreshDviInfoEvent);
            _readDviInfo.CompleteRetryRefreshDviInfoEvent += _readDviInfo_CompleteRetryRefreshDviInfoEvent;
            #endregion

            #region 初始化常规监控数据读取对象
            Dictionary<string, List<ILEDDisplayInfo>> displayInfoList = new Dictionary<string, List<ILEDDisplayInfo>>();
            foreach (string key in _allComBaseInfo.AllInfoDict.Keys)
            {
                displayInfoList.Add(key, _allComBaseInfo.AllInfoDict[key].LEDDisplayInfoList);
            }
            _hwStatusMonitor = new HWStatusMonitor(_serverProxy, displayInfoList, _reduInfoList);
            _hwStatusMonitor.Initialize();
            _hwStatusMonitor.IsCycleMonitor = false;
            _hwStatusMonitor.CompleteRefreshAllCommPortEvent += new CompleteRefreshAllCommPortEventHandler(HWStatusMonitor_CompleteRefreshAllCommPortEvent);
            _hwStatusMonitor.BeginReadSBMonitorInfoEvent += _hwStatusMonitor_BeginReadSBMonitorInfoEvent;
            _hwStatusMonitor.CompleteReadSBMonitorInfoEvent += _hwStatusMonitor_CompleteReadSBMonitorInfoEvent;
            _hwStatusMonitor.CompleteRetryReadSBMonitorInfoEvent += new CompleteRefreshAllCommPortEventHandler(HWStatusMonitor_CompleteRetryReadSBMonitorInfoEvent);
            #endregion

            #region 硬件亮度配置
            _smartLightAccessor = new SmartLightDataAccessor(_serverProxy, string.Empty);
            #endregion

            #region 初始化多功能卡外设监控数据读取对象
            _funcMonitor = new FunctionCardOutDeviceMonitor(_serverProxy);
            #endregion
            _smartBright = new SmartBright(_serverProxy, _allComBaseInfo, _supportList);
            _smartBright.OutputLogEvent += _smartBright_OutputLogEvent;
            #region 初始化配置文件路径
            //InitConfigFileName();
            #endregion
            lock (_readHWObjLock)
            {
                _readHWCount = 0;
            }
            OnNotifyExecResEvent(
                        TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                        UpdateCfgFileResType.OK);
            return InitialErryType.OK;
        }