예제 #1
0
 public static void HandleException(Drone drone, Exception exception)
 {
     if (exception == null)
     {
         Log.Error("ErrorHandler.HandleException(): Exception is null");
     }
     else
     {
         Log.Error(exception);
         if (drone == null)
         {
             Log.Error("ErrorHandler.HandleException(): Drone is null");
         }
         else if (drone.Data.State.AreMotorsRunning())
         {
             Log.Warning("ErrorHandler.HandleException(): Exception while motors are running");
         }
         else
         {
             MessageBox.Show(exception.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
예제 #2
0
 private void blinkButton_Click(object sender, EventArgs e)
 {
     Drone.SendBlink();
 }
예제 #3
0
 private void OpenMainForm(Drone drone)
 {
     new MainForm(drone).Show();
     Hide();
 }
예제 #4
0
 public static void removeDrone(Drone drone)
 {
     drone.stop();
     drone.land();
     drones.Remove(drone);
 }
예제 #5
0
        public SettingsForm(Drone drone)
        {
            InitializeComponent();

            this.drone        = drone;
            this.info         = drone.Info;
            this.originalData = drone.Settings;
            this.data         = drone.Settings;

            try
            {
                Bind(nameTextBox, "data.DroneName");
                Bind(saveConfigCheckBox, "data.SaveConfig");

                Bind(firmwareVersionTextBox, "info.BuildVersion");
                Bind(buildDateTextBox, "info.BuildName");

                Bind(modelTextBox, "info.ModelName");
                Bind(idTextBox, "info.SerialCode");
                Bind(gyroSensorTextBox, "info.GyroSensor");
                Bind(magnetometerTextBox, "info.Magnetometer");
                Bind(baroSensorTextBox, "info.BaroSensor");

                Bind(minValueTextBox, "data.ServoMin");
                Bind(idleValueTextBox, "data.ServoIdle");
                Bind(maxValueTextBox, "data.ServoMax");

                Bind(safeMotorValueTextBox, "data.SafeServoValue");
                Bind(ignoreSafeOrientationCheckBox, "data.IgnoreSafeOrientationWhileFlying");
                Bind(safeTemperatureTextBox, "data.MaxTemperature");
                Bind(safeRollTextBox, "data.SafeRoll");
                Bind(safePitchTextBox, "data.SafePitch");

                Bind(rollKpTextBox, "data.RollPid.Kp");
                Bind(rollKiTextBox, "data.RollPid.Ki");
                Bind(rollKdTextBox, "data.RollPid.Kd");

                Bind(pitchKpTextBox, "data.PitchPid.Kp");
                Bind(pitchKiTextBox, "data.PitchPid.Ki");
                Bind(pitchKdTextBox, "data.PitchPid.Kd");

                Bind(yawKpTextBox, "data.YawPid.Kp");
                Bind(yawKiTextBox, "data.YawPid.Ki");
                Bind(yawKdTextBox, "data.YawPid.Kd");

                Bind(enableStabilizationCheckBox, "data.EnableStabilization");

                Bind(maxThrustForFlyingTextBox, "data.MaxThrustForFlying");
                Bind(ignoreSafeOrientationCheckBox, "data.OnlyArmWhenStill");

                Bind(angleRollKpTextBox, "data.AngleRoll.Kp");
                Bind(angleRollKiTextBox, "data.AngleRoll.Ki");
                Bind(angleRollKdTextBox, "data.AngleRoll.Kd");

                Bind(anglePitchKpTextBox, "data.AnglePitch.Kp");
                Bind(anglePitchKiTextBox, "data.AnglePitch.Ki");
                Bind(anglePitchKdTextBox, "data.AnglePitch.Kd");

                Bind(angleYawKpTextBox, "data.AngleYaw.Kp");
                Bind(angleYawKiTextBox, "data.AngleYaw.Ki");
                Bind(angleYawKdTextBox, "data.AngleYaw.Kd");

                Bind(rollTrim, "data.RollTrim");
                Bind(pitchTrim, "data.PitchTrim");
                Bind(yawTrim, "data.YawTrim");

                drone.OnSettingsChange += Drone_OnSettingsChange;
                drone.OnInfoChange     += Drone_OnInfoChange;
            }
            catch (Exception e)
            {
                bindingError = true;

                Log.Error(e);
                MessageBox.Show("Could not load the settings.", "Error while loading settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }