コード例 #1
0
        /// <summary>Handles the <see cref="ProximitySensor.ObjectDetected"/> event</summary>
        /// <param name="sender">The sender of the <see cref="ProximitySensor.ObjectDetected"/> event</param>
        /// <param name="objectDetectedEventArgs">The event arguments containing distance information about a detected object</param>
        private static void OnObjectDetected(object sender, ObjectDetectedEventArgs objectDetectedEventArgs)
        {
            if (ShouldRecordUpperSensorEvent(sender))
            {
                DisplayMessage("-   Recorded   -", "Upper sensor");
                SlideRun.OccurredOn = objectDetectedEventArgs.DateTime;
            }

            if (ShouldRecordLowerSensorEvent(sender))
            {
                DisplayMessage("-   Recorded   -", "Lower sensor");

                SlideRun.TimeInMs = objectDetectedEventArgs.DateTime.Subtract(SlideRun.OccurredOn)
                                    .Milliseconds;

                var restClient = new RestClient(Api, ApiPort)
                {
                    AcceptHeader      = "text/plain",
                    ContentTypeHeader = "application/json"
                };
                restClient.Post("/slide-runs", SlideRun.ToPostRequestContent());

                SlideRun = new SlideRun();

                Thread.Sleep(500);
                DisplayMessage("-   Duration   -", SlideRun.TimeInMs.ToString());

                Thread.Sleep(500);
                DisplayMessage("-   Velocity   -", CalculateVelocity(SlideRun.TimeInMs) + " mph");
            }
        }
コード例 #2
0
        /// <summary>Program entry point</summary>
        public static void Main()
        {
            SlideRun = new SlideRun();

            InitializeSerialLcd();
            InitializeClock();
            InitializeHidDecoder();
            InitializeLowerProximitySensor();
            InitializeUpperProximitySensor();

            DisplayMessage("Ready");

            Thread.Sleep(Timeout.Infinite);
        }