Example #1
0
        /// <summary>
        /// Establish a connection to the drone and start receiving and sending data
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            if (IsConnected)
            {
                Disconnect();
            }
            Ping_Should_run = false;
            Task <bool> disc = Task <bool> .Factory.StartNew(() => _discovery());

            disc.Wait();
            IsConnected = disc.Result;
            if (IsConnected)
            {
                this.sender               = new SumoSender(this.deviceIp, this.c2d_port);
                this.receiver             = new SumoReceiver(this.deviceIp, this.d2c_port, this.sender, ref sumoInformations);
                this.receiver.SumoEvents += Receiver_SumoEvents;

                // Set Video
                this.video = new SumoVideo(this.receiver);
                video.ImageInSeparateOpenCVWindow = EnableOpenCV;
                this.video.ImageAvailable        += Display_ImageAvailable;

                // Run Threads
                this.receiver.RunThread();
                this.sender.RunThread();
                this.sender.Init();
                this.video.RunThread();
                if (this.piloting != null)
                {
                    this.piloting.InstallHook();
                    this.piloting.RunPilotingThread();
                    this.piloting.RunKeyboardThread();
                }

                EnableVideo();

                // Inform UI that is connected
                OnSumoEvents(new SumoEventArgs(SumoEnumCustom.TypeOfEvents.Connected, sumoInformations));
            }
            return(IsConnected);
        }
Example #2
0
 public SumoVideo(SumoReceiver _receiver)
 {
     this.receiver    = _receiver;
     this.Window_name = "Sumo Display";
 }