예제 #1
0
        protected override void OnInitialize()
        {
            if (_moniDatareader == null)
            {
                _moniDatareader = new MarsHWMonitorDataReader();
                _moniDatareader.ReadFailedRetryTimes = _retryCount;
            }
            _fLogService.Info("开始初始化...");
            SendData("M3_StateData", "OnInitialize");
            //打开服务
            _moniDatareader.NotifyRegisterErrEvent -= MoniDatareader_NotifyRegisterErrEvent;
            _moniDatareader.NotifyRegisterErrEvent += MoniDatareader_NotifyRegisterErrEvent;
            //配屏信息
            _moniDatareader.NotifyScreenCfgChangedEvent -= MoniDatareader_NotifyScreenCfgChangedEvent;
            _moniDatareader.NotifyScreenCfgChangedEvent += MoniDatareader_NotifyScreenCfgChangedEvent;
            //监控配置文件
            _moniDatareader.NotifyUpdateCfgFileResEvent -= MoniDatareader_NotifyUpdateCfgFileResEvent;
            _moniDatareader.NotifyUpdateCfgFileResEvent += MoniDatareader_NotifyUpdateCfgFileResEvent;
            //参数更新
            _moniDatareader.NotifySettingCompletedEvent -= MoniDatareader_NotifySettingCompletedEvent;
            _moniDatareader.NotifySettingCompletedEvent += MoniDatareader_NotifySettingCompletedEvent;
            UpdateConfigMessage(TransferType.M3_FirstInitialize, string.Empty);

            //这个地方不再初始化,改为由底下事件通知来定:MarsScreenChangedInit
            //InitialErryType res = InitialErryType.OK;
            //_fLogService.Info("硬件开始初始化...");
            //SendData("M3_StateData", "HWOnInitialize");
            //res = _moniDatareader.Initialize();
            //_fLogService.Info("硬件完成初始化");
            //if (res == InitialErryType.OK)
            //{
            //    //GetScreenListInfo();
            //}
            //if (res != InitialErryType.OK)
            //{
            //    _fLogService.Error("硬件初始化异常:" + res.ToString());
            //    WriteLog("硬件初始化异常:" + res.ToString());
            //    SendData("M3_StateData", "HWOnInitializeFailed");
            //    MonitorException = new Exception(res.ToString()) { Source = "M3_MonitorData" };
            //}
            //else
            //{
            //    WriteLog("硬件初始化完成");
            //    _fLogService.Info("硬件初始化完成");
            //    SendData("M3_StateData", "OnInitializeSuccess");
            //}

            if (_dataReadTimer == null)
            {
                WriteLog("周期开始启动");
                _fLogService.Info("周期开始启动");
                _dataReadTimer = new System.Timers.Timer();
                _dataReadTimer.Interval = 60000;
                _dataReadTimer.Elapsed += DataReadTimer_Elapsed;
            }
        }
예제 #2
0
 protected override void OnDispose()
 {
     if (_moniDatareader != null)
     {
         //监控配置文件
         _moniDatareader.NotifyUpdateCfgFileResEvent -= MoniDatareader_NotifyUpdateCfgFileResEvent;
         //配屏信息
         _moniDatareader.NotifyScreenCfgChangedEvent -= MoniDatareader_NotifyScreenCfgChangedEvent;
         //参数更新
         _moniDatareader.NotifySettingCompletedEvent -= MoniDatareader_NotifySettingCompletedEvent;
         //错误
         _moniDatareader.NotifyRegisterErrEvent -= MoniDatareader_NotifyRegisterErrEvent;
         _moniDatareader.Unitialize();
         _moniDatareader = null;
     }
     if (_dataReadTimer != null)
     {
         _dataReadTimer.Elapsed -= DataReadTimer_Elapsed;
         _dataReadTimer.Dispose();
         _dataReadTimer = null;
     }
 }