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); }
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; }