示例#1
0
        public void GetTimerValueTest()
        {
            Console.WriteLine("Starting timer value test...");

            uint time0, time1;

            double scaledTime;

            time0 = FX3.GetTimerValue();
            System.Threading.Thread.Sleep(3000);
            time1 = FX3.GetTimerValue();
            if (time1 < time0)
            {
                /* Timer value just rolled over */
                time0 = time1;
                time1 = FX3.GetTimerValue();
            }
            scaledTime = (time1 - time0) / 10078;
            Assert.AreEqual(3000, scaledTime, 0.02 * 3000, "ERROR: Invalid timestamp");

            /* Timer for measuring elapsed time */
            Stopwatch timer = new Stopwatch();

            time0 = (uint)FX3.GetTimerValue() / 10078;
            timer.Start();
            while (timer.ElapsedMilliseconds < 5000)
            {
                time1 = FX3.GetTimerValue();
                Console.WriteLine("FX3 Time: " + (time1 / 10078).ToString() + "ms, system time: " + (timer.ElapsedMilliseconds + time0).ToString() + "ms");
                Assert.AreEqual((time1 / 10078), (timer.ElapsedMilliseconds + time0), (timer.ElapsedMilliseconds + time0) * 0.02, "ERROR: Invalid FX3 time");
                System.Threading.Thread.Sleep(100);
            }
        }