Exemple #1
0
        public static void Main(string[] args)
        {
            mTelemetryBroadcastTimer           = new Timer(kTelemetryBroadcastPeriod);
            mTelemetryBroadcastTimer.AutoReset = true;
            mTelemetryBroadcastTimer.Elapsed  += OnTelemetryPublishAlarm;

            string fileName = string.Format("Server-{0}.txt", System.DateTime.Now.ToString("dd MM yyyy HH-mm-ss"));

            mLogger = new ProsthesisCore.Utility.Logger(fileName, true);
            mLogger.LogMessage(ProsthesisCore.Utility.Logger.LoggerChannels.General, "ProsthesisOS startup", true);

            mContext = new States.ProsthesisMainContext(ProsthesisCore.ProsthesisConstants.ConnectionPort, mLogger);

            mTelemetryBroadcastTimer.Start();

            //Safely shut down app
            AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs e)
            {
                if (mContext.IsRunning)
                {
                    mContext.Terminate("Aborted");
                }

                mLogger.ShutDown();
            };

            Console.WriteLine("Press 'x' to exit");

            while (Console.ReadKey().Key != ConsoleKey.X)
            {
            }

            if (mContext.IsRunning)
            {
                mContext.Terminate("User terminated");
            }

            mTelemetryBroadcastTimer.Stop();
            mLogger.ShutDown();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            mTelemetryBroadcastTimer = new Timer(kTelemetryBroadcastPeriod);
            mTelemetryBroadcastTimer.AutoReset = true;
            mTelemetryBroadcastTimer.Elapsed += OnTelemetryPublishAlarm;

            string fileName = string.Format("Server-{0}.txt", System.DateTime.Now.ToString("dd MM yyyy HH-mm-ss"));
            mLogger = new ProsthesisCore.Utility.Logger(fileName, true);
            mLogger.LogMessage(ProsthesisCore.Utility.Logger.LoggerChannels.General, "ProsthesisOS startup", true);

            mContext = new States.ProsthesisMainContext(ProsthesisCore.ProsthesisConstants.ConnectionPort, mLogger);

            mTelemetryBroadcastTimer.Start();

            //Safely shut down app
            AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs e)
            {
                if (mContext.IsRunning)
                {
                    mContext.Terminate("Aborted");
                }

                mLogger.ShutDown();
            };

            Console.WriteLine("Press 'x' to exit");

            while (Console.ReadKey().Key != ConsoleKey.X) { }

            if (mContext.IsRunning)
            {
                mContext.Terminate("User terminated");
            }

            mTelemetryBroadcastTimer.Stop();
            mLogger.ShutDown();
        }