Пример #1
0
        private void btnReadConfig_Click(object sender, EventArgs e)
        {
            Task <Settings> configurationTask = _droneClient.GetConfigurationTask();

            configurationTask.ContinueWith(delegate(Task <Settings> task)
            {
                if (task.Exception != null)
                {
                    Trace.TraceWarning("Get configuration task is faulted with exception: {0}", task.Exception.InnerException.Message);
                    return;
                }

                _settings = task.Result;
            });
            configurationTask.Start();
        }
Пример #2
0
        void InitConfig()
        {
            Task <Settings> configurationTask = _droneClient.GetConfigurationTask();

            configurationTask.ContinueWith(delegate(Task <Settings> task)
            {
                if (task.Exception != null)
                {
                    Trace.TraceWarning("Get configuration task is faulted with exception: {0}", task.Exception.InnerException.Message);
                    return;
                }

                _configuration = task.Result;
                GetConfig();
            });
            configurationTask.Start();
        }
Пример #3
0
        /// <summary>
        /// Requests the current configuration from the drone asynchronously.
        /// Triggers OnSettingsReceived when completed
        /// Settings/Results are loaded to the settings variale
        /// </summary>
        private void ReadDroneConfig()
        {
            // If the drone is not connected, droneClient will throw an exception
            // although there is some exeption handling
            if (droneClient.IsConnected)
            {
                Task <Settings> configurationTask = droneClient.GetConfigurationTask();
                configurationTask.ContinueWith(delegate(Task <Settings> task)
                {
                    if (task.Exception != null)
                    {
                        Trace.TraceWarning("Get configuration task is faulted with exception: {0}", task.Exception.InnerException.Message);
                        return;
                    }

                    settings = task.Result;
                    this.Invoke(new SettingsReceived(OnSettingsReceived));
                });
                configurationTask.Start();
            }
        }
Пример #4
0
        public void Configure(DroneConfiguration droneConfiguration)
        {
            Task <Settings> configurationTask = droneClient.GetConfigurationTask();

            configurationTask.ContinueWith(
                delegate(Task <Settings> task)
            {
                if (task.Exception != null)
                {
                    Trace.TraceWarning("Get configuration task is faulted with exception: {0}",
                                       task.Exception.InnerException.Message);
                    return;
                }

                settings = task.Result;
            });
            configurationTask.Start();

            var sendConfigTask = new Task(() =>
            {
                if (settings == null)
                {
                    settings = new Settings();
                }

                if (string.IsNullOrEmpty(settings.Custom.SessionId) ||
                    settings.Custom.SessionId == "00000000")
                {
                    // set new session, application and profile
                    droneClient.AckControlAndWaitForConfirmation(); // wait for the control confirmation

                    settings.Custom.SessionId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ProfileId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();

                    settings.Custom.ApplicationId = Settings.NewId();
                    droneClient.Send(settings);

                    droneClient.AckControlAndWaitForConfirmation();
                }

                settings.General.NavdataDemo    = false;
                settings.General.NavdataOptions = NavdataOptions.All;

                //settings.Video.BitrateCtrlMode = VideoBitrateControlMode.Dynamic;
                settings.Video.Bitrate    = 1000;
                settings.Video.MaxBitrate = 2000;

                settings.Leds.LedAnimation       = new LedAnimation(LedAnimationType.BlinkGreenRed, 2.0f, 2);
                settings.Control.FlightAnimation = new FlightAnimation(FlightAnimationType.Wave);


                //start
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Start);
                //stop
                settings.Userbox.Command = new UserboxCommand(UserboxCommandType.Stop);

                //send all changes in one pice
                droneClient.Send(settings);

                droneClient.FlatTrim(); // calibrates the drone on flat surface
            });

            sendConfigTask.Start();
        }