コード例 #1
0
        public static void Debug(string text)
        {
            if ((LoggingServer != null) && (LoggingServer.Active == true))
            {
                LoggingServer.Log(DateTime.Now.ToString() + ": DEBUG: " + text);
            }

            Instance.log_facility.DebugLog(text);
        }
コード例 #2
0
        public static void AppendLog(string line)
        {
            if ((LoggingServer != null) && (LoggingServer.Active == true))
            {
                LoggingServer.Log(DateTime.Now.ToString() + ":" + line);
            }

            Instance.log_facility.AppendLog(line);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: karthikalavala/ZCommander
        static void Main(string[] args)
        {
            //Modified to be a Relative Path.
            XMLConfig config = new XMLConfig(new FileInfo(@"Configs\SimpleSQL.xml"));

            ZombieServer  TestServer = new ZombieServer();
            LoggingServer LogServer  = new LoggingServer(config);

            TestServer.Subscribe(LogServer);
            TestServer.Start(config);
            Console.WriteLine("Press \'q\' to quit the sample.");
            while (Console.Read() != 'q')
            {
                ;
            }
            //testing sandbox branch
        }
コード例 #4
0
 public MavlinkServerBase(IMavlinkV2Connection connection, MavlinkServerIdentity identity, IPacketSequenceCalculator sequenceCalculator = null)
 {
     _seq      = sequenceCalculator ?? new PacketSequenceCalculator();
     Heartbeat = new MavlinkHeartbeatServer(connection, _seq, identity, new MavlinkHeartbeatServerConfig
     {
         HeartbeatRateMs = 1000
     });
     StatusText = new StatusTextServer(connection, _seq, identity, new StatusTextLoggerConfig
     {
         MaxQueueSize  = 100,
         MaxSendRateHz = 10
     });
     CommandLong = new CommandLongServer(connection, _seq, identity);
     Debug       = new DebugServer(connection, _seq, identity);
     Logging     = new LoggingServer(connection, _seq, identity);
     V2Extension = new V2ExtensionServer(connection, _seq, identity);
 }
コード例 #5
0
        private void _exec()
        {
            try
            {
                this.running = true;

                Debug("Starting Log Server Thread...");
                LoggingServer.Start();
                DateTime timeoutStart = DateTime.Now;
                while (LoggingServer.Active == false)
                {
                    TimeSpan tsTimeout = DateTime.Now - timeoutStart;
                    if (tsTimeout.TotalMilliseconds > 1500)
                    {
                        throw new UPSMonFatalException("Log Server could not start!! Terminating!");
                    }
                    Thread.Sleep(1);
                }
                Debug("Log Server Thread Started");

                AppendLog("Reading configuration file...");
                try
                {
                    ReadConfigFile();
                    Debug("Configuration file successfully read");
                }
                catch (XmlException xmlex)
                {
                    AppendLog("Error reading Configuration File" + xmlex.Message);
                    this.running = false;
                }

                if (this.running)
                {
                    PowerSupply.Initialize();
                }

                bool critical        = false;
                bool updatedCritical = false;
                while (this.running)
                {
                    Thread.Sleep(100);
                    if (shutdown)
                    {
                        continue;
                    }

                    PowerSupply.Update();
                    updatedCritical = PowerSupply.GoneCritical;
                    if (updatedCritical != critical)
                    {
                        if (updatedCritical == true)
                        {
                            AppendLog("Power Supply has gone critical... Shutting down!");
                            ExecuteShutdown();
                        }
                        critical = updatedCritical;
                    }
                }

                PowerSupply.End();

                Debug("Stopping Log Server Thread...");
                LoggingServer.Stop();
                LoggingServer.Join();
                Debug("Log Server Thread Stopped");
            }
            catch (UPSMonFatalException fatalEx)
            {
                throw new Exception(fatalEx.Message);
            }
            catch (Exception ex)
            {
                this.log_facility.ErrorLog("Unhandled Exception in Xelpro AMR Threads!! " + ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }