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 }
private void ReadAllComBaseInfoCompleted(CompleteReadAllComHWBaseInfoParams allBaseInfo, object userToken) { _allComBaseInfo_Bak = allBaseInfo.AllInfo; if (_allComBaseInfo_Bak == null || _allComBaseInfo_Bak.AllInfoDict == null || _allComBaseInfo_Bak.AllInfoDict.Count == 0) { _fLogService.Debug("读取软件空间回调结果为空,因此无屏信息"); OnNotifyScreenCfgChangedEvent(this, EventArgs.Empty); _reReadScreenTimer.Change(10000, 10000); lock (_readHWObjLock) { if (_readHWCount > 0) { _readHWCount--; } } return; } else { _reReadScreenTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); _fLogService.Debug("读取软件空间回调结果的个数:" + _allComBaseInfo_Bak.AllInfoDict.Count); } lock (_readHWObjLock) { if (_readHWCount > 0) { _readHWCount--; } if (_readHWCount == 0) { CheckAndSetScreenChanged(allBaseInfo); } else { _fLogService.Debug("由于后面又存在读取,因此本次的判断通知做废处理"); } } //_waitForInitCompletedMetux.Set(); }
private void CheckAndSetScreenChanged(CompleteReadAllComHWBaseInfoParams allBaseInfo) { _fLogService.Debug("进入:CheckAndSetScreenChanged"); string saveFilePath = System.IO.Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"NovaLCT 2012\Config\Monitoring\"), CONFIG_SCREEN_NAME); if (!Directory.Exists(saveFilePath)) { _fLogService.Debug("CheckAndSetScreenChanged:无目录,需要创建"); Directory.CreateDirectory(saveFilePath); } SerializableDictionary<string, List<SenderRedundancyInfo>> reduInfoList = new SerializableDictionary<string, List<SenderRedundancyInfo>>(); if (allBaseInfo == null || allBaseInfo.AllInfo == null || allBaseInfo.AllInfo.AllInfoDict == null) { _fLogService.Debug("CheckAndSetScreenChanged:读硬件数据为空,所以直接退出"); return; } if (_allComBaseInfo != null && (_isNeedNotifyScreenCfgChanged == true || _allComBaseInfo.AllInfoDict.Count != allBaseInfo.AllInfo.AllInfoDict.Count)) { WriteScreenFiles(saveFilePath, allBaseInfo.AllInfo.AllInfoDict); ScreenChangedNotify(); return; } try { string[] strFiles = System.IO.Directory.GetFiles(saveFilePath); foreach (string file in strFiles) { System.IO.File.Delete(file); } } catch (Exception ex) { _fLogService.Error("ExistCatch:Delete Old Screen File Error:" + ex.ToString()); } string saveFileName = string.Empty; string saveFileName_tmp = string.Empty; foreach (KeyValuePair<string, OneCOMHWBaseInfo> pair in allBaseInfo.AllInfo.AllInfoDict) { if (pair.Value.DisplayResult == CommonInfoCompeleteResult.OK) { bool isReduDif = false; _fLogService.Debug("CheckAndSetScreenChanged:冗余判断"); if (!_reduInfoList.ContainsKey(pair.Key)) { if (pair.Value.ReduInfoList != null && pair.Value.ReduInfoList.Count > 0) { isReduDif = true; } } else { isReduDif = IsRedundancyChanged(pair.Value.ReduInfoList, _reduInfoList[pair.Key]); } saveFileName = saveFilePath + pair.Value.FirstSenderSN; if (_allComBaseInfo != null && _allComBaseInfo.AllInfoDict != null) { if (!_allComBaseInfo.AllInfoDict.ContainsKey(pair.Key)) { isReduDif = true; } else { WriteScreenFile(saveFileName, pair.Key, _allComBaseInfo.AllInfoDict[pair.Key].FirstSenderSN, _allComBaseInfo.AllInfoDict[pair.Key].LEDDisplayInfoList); } } saveFileName_tmp = saveFileName + "_tmp"; WriteScreenFile(saveFileName_tmp, pair.Key, pair.Value.FirstSenderSN, pair.Value.LEDDisplayInfoList); if (isReduDif || !MonitorFuncHelper.IsMD5Equal(saveFileName, saveFileName_tmp)) { WriteScreenFiles(saveFilePath, allBaseInfo.AllInfo.AllInfoDict); ScreenChangedNotify(); break; } else { _fLogService.Info("屏体无变更,不需要重新读取"); } } else { OnNotifyScreenCfgChangedEvent(this, EventArgs.Empty); } } }
private void ReadAllComBaseInfoCompleted(CompleteReadAllComHWBaseInfoParams allBaseInfo, object userToken) { if (allBaseInfo == null || allBaseInfo.AllInfo == null || allBaseInfo.AllInfo.AllInfoDict == null) { return; } var currentCOMAndHWBaseInfo = allBaseInfo.AllInfo.AllInfoDict.ElementAt(0); var currentHWBaseInfo = currentCOMAndHWBaseInfo.Value; //currentHWBaseInfo.LEDDisplayInfoList; }