示例#1
0
        private void OnCommsTimeoutEventHandler(object sender, int timeout)
        {
            try
            {
                if (mGPSPort.StartsWith("can"))
                {
                    CNXLog.ErrorFormat("Comms timeout {0}s.", timeout);
                    return;
                }
            }
            catch (Exception) { }
            try
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                if (timeout > CommsServer.MaxCommsOutageSeconds)
                {
                    CNXLog.ErrorFormat("Comms timeout {0}s. Rebooting gateway {1} {2}", timeout, mGatewayRebootProcess, mGatewayRebootArgs);
                    process.StartInfo.FileName  = mGatewayRebootProcess;
                    process.StartInfo.Arguments = mGatewayRebootArgs;
                    process.Start();
                }
            }
            catch (Exception e)
            {
                CNXLog.Error(string.Format("Comms timeout reboot {0} {1}", mGatewayRebootProcess, mGatewayRebootArgs), e);
            }
            try
            {
                CNXLog.ErrorFormat("Comms timeout {0}s. Rebooting system.", timeout);

                //this statement will cause the S8 reboot
                //BootstrapUpgrader.BeginReboot();
                CNXLog.ErrorFormat("Comms timeout {0}s. Restarting CommsServer", timeout);
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    //RestartCommsServer();
                    mCommsServer.Stop();
                    mCommsServer.Start();
                }
                                             );
            }
            catch (Exception e)
            {
                CNXLog.Error("Comms timeout server restart", e);
            }
        }