コード例 #1
0
ファイル: Program.cs プロジェクト: nhoppasit/Polarimetry
        static void MessageReceivedHandler(object sender, MessageReceivedEventArgs args)
        {
            if (args.Message.MessageType == PtpMessageType.SyncMessage)
            {
                LogLastSynchronizationInfo();

                PtpSyncMessage syncMessage = (PtpSyncMessage)args.Message;

                m_lastSyncTime = syncMessage.OriginTimeStamp;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nhoppasit/Polarimetry
        static void Main(string[] args)
        {
            string logFileName = "PtpSyncLog.csv";

            if (args.Length == 2)
            {
                logFileName = args[1];
            }
            else
            {
                Console.WriteLine("Command line syntax: PtpSyncLogger <logfilename>");
                Console.WriteLine("Logging to 'PtpSyncLog.csv'");
            }

            m_logFile      = new StreamWriter(logFileName);
            m_lastSyncTime = null;

            m_ptpMgr = new PtpManager();

            FindActiveClocks();

            LogSynchronizationHeaders();

            // Register a handler for Sync messages (the handler does the writing to the log file)
            m_ptpMgr.MessageReceived += new MessageReceivedEventHandler(MessageReceivedHandler);

            m_ptpMgr.CaptureClockHistory = true;

            Console.WriteLine("Press 'Enter' to stop logging.");

            Console.Read();

            // Stop monitoring Sync messages
            m_ptpMgr.MessageReceived -= new MessageReceivedEventHandler(MessageReceivedHandler);

            m_logFile.Close();
        }