Exemple #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var end = new IPEndPoint(IPAddress.Parse("192.167.1.2"), 2368);

            Logger.WriteLine();
            Logger.WriteLine("Listening for VLP_16 on " + end.ToString());
            Logger.WriteLine();

            try
            {
                // VLP_16 will callback with live data ASAP, VLP_16_Framer will callback with data once per laser column revoltuion
                if (true)
                {
                    VLP_16.Listen(end, this.PacketRecievedAsync, this.ShouldStopAsync);
                }
                else
                {
                    VLP_16_Framer.Listen(end, this.FrameRecievedAsync, this.ShouldStopAsync);
                }
            }
            catch (Exception initalization_exception)
            {
                Logger.WriteException(this, "Initialization", initalization_exception);
            }
        }
        /// <summary>
        /// Throws a socket exception only on initialization.  Once everything is up and running exceptions are handled internally.
        /// </summary>
        /// <param name="endpoint"></param>
        /// <param name="new_frame_callback"></param>
        /// <param name="should_cancel_callback">Called at 1 Hz</param>
        public static void Listen(
            IPEndPoint endpoint,
            FrameRecieved new_frame_callback    = null,
            ShouldCancel should_cancel_callback = null)
        {
            var framer = new VLP_16_Framer(new_frame_callback);

            VLP_16.Listen(
                endpoint,
                framer.RecievePacket,
                should_cancel_callback);
        }