Exemple #1
0
        public DroneIo(string hostName)
        {
            cmdClient   = new UdpClient(hostName, CommandPort);
            videoClient = new UdpClient(hostName, VideoPort);
            CommandThreadState cmdState = new CommandThreadState()
            {
                Client = cmdClient, Queue = commandQueue
            };
            EventThreadState eventState = new EventThreadState()
            {
                Client = cmdClient, Queue = commandQueue, Handler = HandleCommandEvent
            };
            VideoThreadState videoState = new VideoThreadState()
            {
                Client = cmdClient
            };

            cmdThread.Start(cmdState);
            videoThread.Start(videoState);
            eventThread.Start(eventState);
            RequestConnection();
        }
Exemple #2
0
        private static void EventThreadMain(object state)
        {
            EventThreadState eventState             = (EventThreadState)state;
            BlockingCollection <TelloCommand> queue = eventState.Queue;

            isActive = true;
            while (isActive)
            {
                TelloCommand command = null;
                try { command = queue.Take(); }
                catch (InvalidOperationException) { Thread.Sleep(100); }

                if (command == null)
                {
                    continue;
                }
                ICommandReader reader = commandReaders.SingleOrDefault(t => t.Id == command.Id);
                IEventCommand  evt    = reader?.Read(command);
                if (evt == null)
                {
                    continue;
                }
            }
        }