예제 #1
0
 /// <summary>
 /// 窗口退出时关闭TCP服务
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (MessageBox.Show("确定要关闭?", "窗口关闭提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         ProtocolEngine.Instance().Stop();
         e.Cancel = false;
     }
     else
     {
         e.Cancel = true;
     }
 }
예제 #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     StartCurrentTimer();
     Logger.Instance().Info("");
     Logger.Instance().Info("");
     Logger.Instance().Info("");
     Logger.Instance().Info("");
     Logger.Instance().Info("");
     Logger.Instance().Info("=====================应用程序启动===========================");
     System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     if (!(int.TryParse(config.AppSettings.Settings["DockCount"].Value, out m_DockCount)))
     {
         m_DockCount = 10;
     }
     if (!(int.TryParse(config.AppSettings.Settings["QueryInterval"].Value, out m_QueryInterval)))
     {
         m_QueryInterval = 60;
     }
     if (!(int.TryParse(config.AppSettings.Settings["TimeOut"].Value, out m_TimeOut)))
     {
         m_TimeOut = 60000;
     }
     if (!(int.TryParse(config.AppSettings.Settings["HeartBeat"].Value, out m_HeartBeatTimeOut)))
     {
         m_HeartBeatTimeOut = 240000;
     }
     if (!(int.TryParse(config.AppSettings.Settings["CheckPumpStatusMaxMunites"].Value, out m_CheckPumpStatusMaxMunites)))
     {
         m_CheckPumpStatusMaxMunites = 30 * 60;
     }
     if (!(int.TryParse(config.AppSettings.Settings["CheckPumpStopStatusMaxMunites"].Value, out m_CheckPumpStopStatusMaxMunites)))
     {
         m_CheckPumpStopStatusMaxMunites = 5 * 60;//5分钟
     }
     if (!(int.TryParse(config.AppSettings.Settings["CheckDisChargeMaxMunites"].Value, out m_CheckDisChargeMaxMunites)))
     {
         m_CheckDisChargeMaxMunites = 30 * 60;//30分钟
     }
     DockInfoManager.Instance().Init();
     ControllerManager.Instance().Init();
     LoadDockList();
     ProtocolEngine.Instance().SetTimeOut(m_TimeOut);            //设置命令解析超时时间
     AsyncServer.Instance().SocketTimeOut = m_HeartBeatTimeOut;  //心跳超时时间
     ProtocolEngine.Instance().InitTcp();
     ProtocolEngine.Instance().SocketConnectOrCloseResponse += OnSocketConnectOrClose;
     ProtocolEngine.Instance().SendPumpType2Wifi            += OnSendPumpType2Wifi;
     ProtocolEngine.Instance().UploadAlarm += OnUploadAlarm;
     ProtocolEngine.Instance().Start();
 }
예제 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            StartCurrentTimer();
            Logger.Instance().Info("");
            Logger.Instance().Info("");
            Logger.Instance().Info("");
            Logger.Instance().Info("");
            Logger.Instance().Info("");
            Logger.Instance().Info("=====================应用程序启动===========================");
            System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);


            if (config.AppSettings.Settings.AllKeys.Contains("DockNumber"))
            {
                //当架子只有一个时,这个变量才有效, add by 2018-09-01
                if (!(int.TryParse(config.AppSettings.Settings["DockNumber"].Value, out m_DockNumber)))
                {
                    m_DockNumber = 1;
                }
            }
            if (config.AppSettings.Settings.AllKeys.Contains("AgingResultDir"))
            {
                m_AgingResultDir = config.AppSettings.Settings["AgingResultDir"].Value;
            }
            if (config.AppSettings.Settings.AllKeys.Contains("AgingResultDirBackup"))
            {
                m_AgingResultDirBackup = config.AppSettings.Settings["AgingResultDirBackup"].Value;
            }

            if (!(int.TryParse(config.AppSettings.Settings["TcpListenPort"].Value, out m_TcpListenPort)))
            {
                m_TcpListenPort = 20160;
            }

            if (!(int.TryParse(config.AppSettings.Settings["DockCount"].Value, out m_DockCount)))
            {
                m_DockCount = 10;
            }
            if (!(int.TryParse(config.AppSettings.Settings["QueryInterval"].Value, out m_QueryInterval)))
            {
                m_QueryInterval = 60;
            }
            if (!(int.TryParse(config.AppSettings.Settings["TimeOut"].Value, out m_TimeOut)))
            {
                m_TimeOut = 60000;
            }
            if (!(int.TryParse(config.AppSettings.Settings["HeartBeat"].Value, out m_HeartBeatTimeOut)))
            {
                m_HeartBeatTimeOut = 240000;
            }
            if (!(int.TryParse(config.AppSettings.Settings["CheckPumpStatusMaxMunites"].Value, out m_CheckPumpStatusMaxMunites)))
            {
                m_CheckPumpStatusMaxMunites = 30 * 60;
            }
            if (!(int.TryParse(config.AppSettings.Settings["CheckPumpStopStatusMaxMunites"].Value, out m_CheckPumpStopStatusMaxMunites)))
            {
                m_CheckPumpStopStatusMaxMunites = 5 * 60;//5分钟
            }
            if (!(int.TryParse(config.AppSettings.Settings["CheckDisChargeMaxMunites"].Value, out m_CheckDisChargeMaxMunites)))
            {
                m_CheckDisChargeMaxMunites = 30 * 60;//30分钟
            }
            DockInfoManager.Instance().Init();
            ControllerManager.Instance().Init();
            LoadDockList();
            ProtocolEngine.Instance().SetTimeOut(m_TimeOut);            //设置命令解析超时时间
            AsyncServer.Instance().TcpServerPort = m_TcpListenPort;
            AsyncServer.Instance().SocketTimeOut = m_HeartBeatTimeOut;  //心跳超时时间
            ProtocolEngine.Instance().InitTcp();
            ProtocolEngine.Instance().SocketConnectOrCloseResponse += OnSocketConnectOrClose;
            ProtocolEngine.Instance().SendPumpType2Wifi            += OnSendPumpType2Wifi;
            ProtocolEngine.Instance().UploadAlarm += OnUploadAlarm;
            ProtocolEngine.Instance().Start();

            if (m_DockCount == 1)
            {
                this.Width  = 270;
                this.Height = 330;
            }
        }