Exemplo n.º 1
0
        public void Activate()
        {
            log.Info("Enter flyhgtspd!");

            horizon_spd.AttachEvents();
            horizon_spd.ValueChanged += RNG_ValueChanged;
            // max_height.AttachEvents();
            // max_height.ValueChanged += RNG_ValueChanged;
            des_vel_decel_s.AttachEvents();
            des_vel_decel_s.ValueChanged += RNG_ValueChanged;
            rng_angle_max.AttachEvents();
            rng_angle_max.ValueChanged += RNG_ValueChanged;
            ThemeManager.ApplyThemeTo(horizon_spd);
            ThemeManager.ApplyThemeTo(rng_angle_max);
            ThemeManager.ApplyThemeTo(des_vel_decel_s);
            if (MainV2.connectOK)
            {
                this.horizon_spd.Value = (MainV2.comPort.GetParam("WPNAV_SPEED") / 100).ToString();
                // BRK_ACCEL
                this.rng_angle_max.Value   = (MainV2.comPort.GetParam("WPNAV_BRK_G") * 10).ToString();
                this.des_vel_decel_s.Value = (MainV2.comPort.GetParam("WPNAV_BRK_DELAY")).ToString();
                this.cb_yaw_mode.Text      = ((int)(MainV2.comPort.GetParam("WP_YAW_BEHAVIOR")) == 0) ? "机头保持不变" : "机头跟随航线";
            }
        }
Exemplo n.º 2
0
        private void BUT_compare_Click(object sender, EventArgs e)
        {
            Hashtable param2 = new Hashtable();

            var ofd = new OpenFileDialog
            {
                AddExtension     = true,
                DefaultExt       = ".param",
                RestoreDirectory = true,
                Filter           = "Param List|*.param;*.parm"
            };

            var dr = ofd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                param2 = loadParamFile(ofd.FileName);

                Form paramCompareForm = new ParamCompare(Params, MainV2.comPort.param, param2);

                ThemeManager.ApplyThemeTo(paramCompareForm);
                paramCompareForm.ShowDialog();
            }
        }
Exemplo n.º 3
0
        void createValueControl(KeyValuePair <string, string> x)
        {
            string value       = ((float)MainV2.comPort.MAV.param[x.Key]).ToString("0.###", CultureInfo.InvariantCulture);
            string description = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Description);
            string displayName = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.DisplayName) + " (" + x.Key + ")";
            string units       = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Units);

            var valueControl = new ValuesControl();

            valueControl.Name            = x.Key;
            valueControl.DescriptionText = FitDescriptionText(units, description);
            valueControl.LabelText       = displayName;

            ThemeManager.ApplyThemeTo(valueControl);

            valueControl.ComboBoxControl.DisplayMember = "Value";
            valueControl.ComboBoxControl.ValueMember   = "Key";
            valueControl.ComboBoxControl.DataSource    = ParameterMetaDataRepository.GetParameterOptionsInt(x.Key);
            valueControl.ComboBoxControl.SelectedItem  = value;

            valueControl.ValueChanged += valueControl_ValueChanged;

            flowLayoutPanel1.Controls.Add(valueControl);
        }
Exemplo n.º 4
0
        public MAVLinkInspector(MAVLinkInterface mav)
        {
            InitializeComponent();

            this.mav = mav;

            mav.OnPacketReceived += MavOnOnPacketReceived;
            mav.OnPacketSent     += MavOnOnPacketReceived;

            mavi.NewSysidCompid += (sender, args) =>
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    comboBox1.DataSource = mavi.SeenSysid();
                    comboBox2.DataSource = mavi.SeenCompid();
                });
            };

            timer1.Tick += (sender, args) => Update();

            timer1.Start();

            ThemeManager.ApplyThemeTo(this);
        }
Exemplo n.º 5
0
        private void but_iris_Click(object sender, EventArgs e)
        {
            try
            {
                string filepath = Application.StartupPath + Path.DirectorySeparatorChar + "Iris.param";

                if (Common.getFilefromNet("https://github.com/diydrones/ardupilot/raw/master/Tools/Frame_params/Iris.param", filepath))
                {
                    Hashtable param2 = Utilities.ParamFile.loadParamFile(filepath);

                    Form paramCompareForm = new ParamCompare(Params, MainV2.comPort.MAV.param, param2);

                    ThemeManager.ApplyThemeTo(paramCompareForm);
                    paramCompareForm.ShowDialog();

                    CustomMessageBox.Show("Loaded parameters, please make sure you write them!", "Loaded");
                }
                else
                {
                    CustomMessageBox.Show("Error getting Iris param file");
                }
            }
            catch (Exception ex) { CustomMessageBox.Show("Error getting Iris param file" + ex.ToString()); }
        }
Exemplo n.º 6
0
        private void BUT_compare_Click(object sender, EventArgs e)
        {
            var param2 = new Dictionary <string, double>();

            using (var ofd = new OpenFileDialog
            {
                AddExtension = true,
                DefaultExt = ".param",
                RestoreDirectory = true,
                Filter = ParamFile.FileMask
            })
            {
                var dr = ofd.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    param2 = ParamFile.loadParamFile(ofd.FileName);

                    Form paramCompareForm = new ParamCompare(Params, MainV2.comPort.MAV.param, param2);

                    ThemeManager.ApplyThemeTo(paramCompareForm);
                    paramCompareForm.ShowDialog();
                }
            }
        }
Exemplo n.º 7
0
        public SonarView(MAVLinkInterface mav)
        {
            InitializeComponent();
            this.mav = mav;
            ThemeManager.ApplyThemeTo(this);

            // Get a random number generator
            //Random rand = new Random();

            //GraphPane myPane = zedGraphControl1.GraphPane;
            //PointPairList list = new PointPairList();
            //for (int i = 0; i < 200; i++)
            //{
            //    double x = rand.NextDouble() * 20.0 + 1;
            //    double y = Math.Log(10.0 * (x - 1.0) + 1.0) * (rand.NextDouble() * 0.2 + 0.9);
            //    list.Add(x, y);
            //}

            //// Add the curve
            //LineItem myCurve = myPane.AddCurve("Performance", list, Color.White, SymbolType.Diamond);
            //// Don't display the line (This makes a scatter plot)
            //myCurve.Line.IsVisible = false;
            //zedGraphControl1.AxisChange();
        }
        public SpectrogramUI()
        {
            InitializeComponent();

            zedGraphControl1.MasterPane[0].Title.Text       = "X";
            zedGraphControl1.MasterPane[0].XAxis.Title.Text = "T";
            zedGraphControl1.MasterPane[0].YAxis.Title.Text = "Frequency";

            zedGraphControl1.MasterPane.Add(new GraphPane());
            zedGraphControl1.MasterPane[1].Title.Text       = "Y";
            zedGraphControl1.MasterPane[1].XAxis.Title.Text = "T";
            zedGraphControl1.MasterPane[1].YAxis.Title.Text = "Frequency";

            zedGraphControl1.MasterPane.Add(new GraphPane());
            zedGraphControl1.MasterPane[2].Title.Text       = "Z";
            zedGraphControl1.MasterPane[2].XAxis.Title.Text = "T";
            zedGraphControl1.MasterPane[2].YAxis.Title.Text = "Frequency";

            zedGraphControl1.AxisChange();

            ThemeManager.ApplyThemeTo(zedGraphControl1);

            zedGraphControl1.Invalidate();
        }
Exemplo n.º 9
0
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            // Prevent upload mission if UAV is armed!
            if (MainV2.comPort.MAV.cs.armed && !Settings.isDevMode)
            {
                if (MessageBox.Show("UAV is Armed! Are You sure want to write parameters?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }


            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float)_changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }
        }
Exemplo n.º 10
0
        internal void processToScreen()
        {
            toolTip1.RemoveAll();

            disableNumericUpDownControls(this);


            // process hashdefines and update display
            foreach (string value in MainV2.comPort.MAV.param.Keys)
            {
                if (value == null || value == "")
                {
                    continue;
                }

                //System.Diagnostics.Debug.WriteLine("Doing: " + value);


                string    name = value;
                Control[] text = this.Controls.Find(name, true);
                foreach (Control ctl in text)
                {
                    try
                    {
                        if (ctl.GetType() == typeof(NumericUpDown))
                        {
                            float numbervalue = (float)MainV2.comPort.MAV.param[value];

                            MAVLink.modifyParamForDisplay(true, value, ref numbervalue);

                            NumericUpDown thisctl = ((NumericUpDown)ctl);
                            thisctl.Maximum   = 9000;
                            thisctl.Minimum   = -9000;
                            thisctl.Value     = (decimal)numbervalue;
                            thisctl.Increment = (decimal)0.0001;
                            if (thisctl.Name.EndsWith("_P") || thisctl.Name.EndsWith("_I") || thisctl.Name.EndsWith("_D") ||
                                thisctl.Name.EndsWith("_LOW") || thisctl.Name.EndsWith("_HIGH") || thisctl.Value == 0 ||
                                thisctl.Value.ToString("0.####", new System.Globalization.CultureInfo("en-US")).Contains("."))
                            {
                                thisctl.DecimalPlaces = 4;
                            }
                            else
                            {
                                thisctl.Increment     = (decimal)1;
                                thisctl.DecimalPlaces = 1;
                            }

                            if (thisctl.Name.ToUpper().EndsWith("THR_RATE_IMAX"))
                            {
                                thisctl.Maximum = 1000; // is a pwm
                                thisctl.Minimum = 0;
                            }
                            else if (thisctl.Name.EndsWith("_IMAX"))
                            {
                                thisctl.Maximum = 180;
                                thisctl.Minimum = -180;
                            }

                            thisctl.Enabled = true;

                            ThemeManager.ApplyThemeTo(thisctl);

                            thisctl.Validated += null;
                            if (tooltips[value] != null)
                            {
                                try
                                {
                                    toolTip1.SetToolTip(ctl, ((paramsettings)tooltips[value]).desc);
                                }
                                catch { }
                            }
                            thisctl.Validated += new EventHandler(EEPROM_View_float_TextChanged);
                        }
                        else if (ctl.GetType() == typeof(ComboBox))
                        {
                            ComboBox thisctl = ((ComboBox)ctl);

                            thisctl.SelectedValue = (int)(float)MainV2.comPort.MAV.param[value];

                            thisctl.Validated += new EventHandler(ComboBox_Validated);

                            ThemeManager.ApplyThemeTo(thisctl);
                        }
                    }
                    catch { }
                }
                if (text.Length == 0)
                {
                    //Console.WriteLine(name + " not found");
                }
            }
        }
Exemplo n.º 11
0
Arquivo: Help.cs Projeto: 894880010/MP
 private void Help_Load(object sender, EventArgs e)
 {
     richTextBox1.Rtf = Resources.help_text;
     ThemeManager.ApplyThemeTo(richTextBox1);
 }
        private void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                MainV2.comPort.MAV.cs.UpdateCurrentSettings(currentStateBindingSource.UpdateDataSource(MainV2.comPort.MAV.cs));
            }
            catch
            {
            }

            float pwm = 0;

            if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduPlane ||
                MainV2.comPort.MAV.cs.firmware == Firmwares.ArduRover ||
                MainV2.comPort.MAV.cs.firmware == Firmwares.Ateryx) // APM
            {
                if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH") ||
                    MainV2.comPort.MAV.param.ContainsKey("MODE_CH"))
                {
                    var sw = 0;
                    if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH"))
                    {
                        sw = (int)MainV2.comPort.MAV.param["FLTMODE_CH"].Value;
                    }
                    else
                    {
                        sw = (int)MainV2.comPort.MAV.param["MODE_CH"].Value;
                    }

                    switch (sw)
                    {
                    case 5:
                        pwm = MainV2.comPort.MAV.cs.ch5in;
                        break;

                    case 6:
                        pwm = MainV2.comPort.MAV.cs.ch6in;
                        break;

                    case 7:
                        pwm = MainV2.comPort.MAV.cs.ch7in;
                        break;

                    case 8:
                        pwm = MainV2.comPort.MAV.cs.ch8in;
                        break;

                    default:

                        break;
                    }

                    if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH"))
                    {
                        LBL_flightmodepwm.Text = MainV2.comPort.MAV.param["FLTMODE_CH"] + ": " + pwm;
                    }
                    else
                    {
                        LBL_flightmodepwm.Text = MainV2.comPort.MAV.param["MODE_CH"] + ": " + pwm;
                    }
                }
            }

            if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2) // ac2
            {
                pwm = MainV2.comPort.MAV.cs.ch5in;
                LBL_flightmodepwm.Text = "5: " + MainV2.comPort.MAV.cs.ch5in;
            }

            Control[] fmodelist = { CMB_fmode1, CMB_fmode2, CMB_fmode3, CMB_fmode4, CMB_fmode5, CMB_fmode6 };

            foreach (var ctl in fmodelist)
            {
                ThemeManager.ApplyThemeTo(ctl);
            }

            var no = readSwitch(pwm);

            fmodelist[no].BackColor = ThemeManager.CurrentPPMBackground;
        }
Exemplo n.º 13
0
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = _changes.Keys.Cast <string>().ToList();

            temp.SortENABLE();

            bool enable = temp.Any(a => a.EndsWith("_ENABLE"));

            if (enable)
            {
                CustomMessageBox.Show(
                    "You have changed an Enable parameter. You may need to do a full param refresh to show all params",
                    "Params");
            }

            int error = 0;

            foreach (string value in temp)
            {
                try
                {
                    if (MainV2.comPort.BaseStream == null || !MainV2.comPort.BaseStream.IsOpen)
                    {
                        CustomMessageBox.Show("Your are not connected", Strings.ERROR);
                        return;
                    }

                    MainV2.comPort.setParam(value, (float)_changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch
                {
                    error++;
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }

            if (error > 0)
            {
                CustomMessageBox.Show("Not all parameters successfully saved.", "Saved");
            }
            else
            {
                CustomMessageBox.Show("Parameters successfully saved.", "Saved");
            }
        }
Exemplo n.º 14
0
        private void Rtcm3_ObsMessage(object sender, EventArgs e)
        {
            if (MainV2.instance.IsDisposed)
            {
                threadrun = false;
            }

            MainV2.instance.BeginInvoke((MethodInvoker) delegate
            {
                List <rtcm3.ob> obs = sender as List <rtcm3.ob>;

                // get system controls
                Func <char, List <VerticalProgressBar2> > ctls = delegate(char sys)
                {
                    return(panel1.Controls.OfType <VerticalProgressBar2>()
                           .Where(ctl => { return ctl.Label.StartsWith(sys + ""); }).ToList());
                };

                // we need more ctls for this system
                while (ctls.Invoke(obs[0].sys).Count() < obs.Count)
                {
                    panel1.Controls.Add(new VerticalProgressBar2()
                    {
                        Height = panel1.Height - 30,
                        Label  = obs[0].sys + ""
                    });
                }

                // we need to remove ctls for this system
                while (ctls.Invoke(obs[0].sys).Count() > obs.Count)
                {
                    var list = ctls.Invoke(obs[0].sys);
                    panel1.Controls.Remove(list.First());
                    panel1.Controls.Remove(list.First().lbl);
                    panel1.Controls.Remove(list.First().lbl1);
                }

                int width = panel1.Width / panel1.Controls.OfType <VerticalProgressBar2>().Count();

                var tmp  = ctls('G');
                var tmp2 = ctls('R');
                var tmp3 = ctls('C');

                var start = 0;

                if (obs[0].sys == 'G')
                {
                    start = 0;
                }
                if (obs[0].sys == 'R')
                {
                    start = tmp.Count;
                }
                if (obs[0].sys == 'C')
                {
                    start = tmp.Count + tmp2.Count;
                }

                // if G 0, if R = G.count (2 system support)
                var a = start;

                var sysctls = ctls.Invoke(obs[0].sys);
                var cnt     = 0;
                foreach (var ob in obs)
                {
                    var vpb   = sysctls[cnt];
                    vpb.Value = (int)ob.snr;
                    //vpb.Text = ob.snr.ToString();
                    vpb.Label     = ob.sys + ob.prn.ToString();
                    vpb.Location  = new Point(width * (a + cnt), 0);
                    vpb.DrawLabel = true;
                    vpb.Width     = width;
                    vpb.Height    = panel1.Height - 30;
                    vpb.Minimum   = 25;
                    vpb.Maximum   = 55;
                    vpb.minline   = 30;
                    vpb.maxline   = 99;
                    cnt++;
                }

                ThemeManager.ApplyThemeTo(panel1);
            }
                                        );
        }
Exemplo n.º 15
0
 public Setup()
 {
     InitializeComponent();
     ThemeManager.ApplyThemeTo(this);
 }
Exemplo n.º 16
0
        private void btn_docalc_Click(object sender, EventArgs e)
        {
            //Convert for sanity check
            prop_size             = t_prop.Text.ConvertToDouble();
            batt_cells            = t_cellcount.Text.ConvertToDouble();
            batt_cell_max_voltage = t_cellmax.Text.ConvertToDouble();
            batt_cell_min_voltage = t_cellmin.Text.ConvertToDouble();

            if (prop_size <= 0)
            {
                CustomMessageBox.Show("Prop size must be larger than zero.", "ERROR!");
                return;
            }

            if (batt_cells < 1)
            {
                CustomMessageBox.Show("Battery cell count must be at least 1.", "ERROR!");
                return;
            }


            calc_values();

            if (cb_tmotor.Checked)
            {
                mot_thst_expo = 0.2;
            }


            var atc_prefix = "ATC";
            var mot_prefix = "MOT";

            if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduPlane)
            {
                atc_prefix = "Q_A";
                mot_prefix = "Q_M";
            }

            var new_params = new Dictionary <string, double>();

            //Fill up the list of params to change
            new_params.Add("ACRO_YAW_P", acro_yaw_p);
            new_params.Add(atc_prefix + "_ACCEL_P_MAX", atc_accel_p_max);
            new_params.Add(atc_prefix + "_ACCEL_R_MAX", atc_accel_r_max);
            new_params.Add(atc_prefix + "_ACCEL_Y_MAX", atc_accel_y_max);

            //Filters has different name in 4.x and in 3.x
            if (MainV2.comPort.MAV.cs.version.Major == 4)
            {
                new_params.Add(atc_prefix + "_RAT_PIT_FLTD", atc_rat_pit_fltd);
                new_params.Add(atc_prefix + "_RAT_PIT_FLTE", atc_rat_pit_flte);
                new_params.Add(atc_prefix + "_RAT_PIT_FLTT", atc_rat_pit_fltt);
                new_params.Add(atc_prefix + "_RAT_RLL_FLTD", atc_rat_rll_fltd);
                new_params.Add(atc_prefix + "_RAT_RLL_FLTE", atc_rat_rll_flte);
                new_params.Add(atc_prefix + "_RAT_RLL_FLTT", atc_rat_rll_fltt);
                new_params.Add(atc_prefix + "_RAT_YAW_FLTD", atc_rat_yaw_fltd);
                new_params.Add(atc_prefix + "_RAT_YAW_FLTE", atc_rat_yaw_flte);
                new_params.Add(atc_prefix + "_RAT_YAW_FLTT", atc_rat_yaw_fltt);
            }
            else
            {
                new_params.Add(atc_prefix + "_RAT_PIT_FILT", atc_rat_pit_fltd);
                new_params.Add(atc_prefix + "_RAT_RLL_FILT", atc_rat_rll_fltd);
                new_params.Add(atc_prefix + "_RAT_YAW_FILT", atc_rat_yaw_flte);
            }

            new_params.Add(atc_prefix + "_THR_MIX_MAN", atc_thr_mix_man);
            new_params.Add("INS_ACCEL_FILTER", ins_accel_filter);
            new_params.Add("INS_GYRO_FILTER", ins_gyro_filter);
            new_params.Add(mot_prefix + "_THST_EXPO", mot_thst_expo);
            new_params.Add(mot_prefix + "_THST_HOVER", mot_thst_hover);
            new_params.Add("BATT_ARM_VOLT", batt_arm_volt);
            new_params.Add("BATT_CRT_VOLT", batt_crt_volt);
            new_params.Add("BATT_LOW_VOLT", batt_low_volt);
            new_params.Add(mot_prefix + "_BAT_VOLT_MAX", mot_bat_volt_max);
            new_params.Add(mot_prefix + "_BAT_VOLT_MIN", mot_bat_volt_min);

            if (cb_tmotor.Checked)
            {
                new_params.Add(mot_prefix + "_PWM_MIN", 1100);
                new_params.Add(mot_prefix + "_PWM_MAX", 1940);
            }

            if (cb_suggested.Checked && MainV2.comPort.MAV.cs.version.Major == 4 && (MainV2.comPort.MAV.cs.firmware != Firmwares.ArduPlane))
            {
                new_params.Add("BATT_FS_CRT_ACT", 1);
                new_params.Add("BATT_FS_LOW_ACT", 2);
                new_params.Add("FENCE_ACTION", 3);
                new_params.Add("FENCE_ALT_MAX", 120);
                new_params.Add("FENCE_ENABLE", 1);
                new_params.Add("FENCE_RADIUS", 150);
                new_params.Add("FENCE_TYPE", 7);
            }

            Form paramCompareForm = new ParamCompare(null, MainV2.comPort.MAV.param, new_params);

            ThemeManager.ApplyThemeTo(paramCompareForm);

            MissionPlanner.Controls.MyButton button = paramCompareForm.Controls.Find("BUT_save", true).FirstOrDefault() as MissionPlanner.Controls.MyButton;
            button.Text = "Write to FC";
            paramCompareForm.StartPosition = FormStartPosition.CenterParent;
            paramCompareForm.ShowDialog();

            if (paramCompareForm.DialogResult == DialogResult.OK)
            {
                CustomMessageBox.Show("Initial Parameters succesfully updated.\r\nCheck parameters before flight!\r\n\r\nAfter test flight :\r\n\tSet ATC_THR_MIX_MAN to 0.5\r\n\tSet PSC_ACCZ_P to MOT_THST_HOVER\r\n\tSet PSC_ACCZ_I to 2*MOT_THST_HOVER\r\n\r\nHappy flying!", "Initial parameter calculator");
            }
        }
Exemplo n.º 17
0
        private void SoftwareConfig_Load(object sender, EventArgs e)
        {
            try
            {
                BackstageViewPage start = null;

                if (gotAllParams)
                {
                    if (MainV2.comPort.BaseStream.IsOpen)
                    {
                        AddBackstageViewPage(typeof(Parametermodification), "舵机/PID快捷");

                        if (MainV2.DisplayConfiguration.displayFlightModes)
                        {
                            start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
                        }

                        if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2)
                        {
                            AddBackstageViewPage(typeof(ConfigAC_Fence), Strings.GeoFence);
                        }

                        if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2)
                        {
                            if (MainV2.DisplayConfiguration.displayBasicTuning)
                            {
                                start = AddBackstageViewPage(typeof(ConfigSimplePids), Strings.BasicTuning);
                            }

                            if (MainV2.DisplayConfiguration.displayExtendedTuning)
                            {
                                AddBackstageViewPage(typeof(ConfigArducopter), Strings.ExtendedTuning);
                            }
                        }

                        if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduPlane)
                        {
                            start = AddBackstageViewPage(typeof(ConfigArduplane), Strings.BasicTuning);
                        }

                        if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduRover)
                        {
                            start = AddBackstageViewPage(typeof(ConfigArdurover), Strings.BasicTuning);
                        }

                        if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduTracker)
                        {
                            start = AddBackstageViewPage(typeof(ConfigAntennaTracker), Strings.ExtendedTuning);
                        }

                        if (MainV2.DisplayConfiguration.displayBasicTuning)
                        {
                            AddBackstageViewPage(typeof(ConfigFriendlyParams), Strings.StandardParams);
                        }

                        if (MainV2.DisplayConfiguration.displayAdvancedParams)
                        {
                            AddBackstageViewPage(typeof(ConfigFriendlyParamsAdv), Strings.AdvancedParams, null, true);
                        }

                        if (!Program.MONO && ConfigOSD.IsApplicable())
                        {
                            AddBackstageViewPage(typeof(ConfigOSD), Strings.OnboardOSD);
                        }

                        if ((MainV2.comPort.MAV.cs.capabilities & (int)MAVLink.MAV_PROTOCOL_CAPABILITY.FTP) > 0)
                        {
                            AddBackstageViewPage(typeof(MavFTPUI), Strings.MAVFtp);
                        }

                        if (true)
                        {
                            AddBackstageViewPage(typeof(ConfigUserDefined), Strings.User_Params);
                        }
                    }
                }

                if (MainV2.DisplayConfiguration.displayFullParamList)
                {
                    if (!MainV2.comPort.BaseStream.IsOpen || gotAllParams)
                    {
                        AddBackstageViewPage(typeof(ConfigRawParams), Strings.FullParameterList, null, true);
                    }
                }
                if (MainV2.DisplayConfiguration.displayFullParamTree && !Program.MONO)
                {
                    if (!MainV2.comPort.BaseStream.IsOpen || gotAllParams)
                    {
                        AddBackstageViewPage(typeof(ConfigRawParamsTree), Strings.FullParameterTree, null, true);
                    }
                }

                if (MainV2.comPort.BaseStream.IsOpen)
                {
                    if (MainV2.comPort.MAV.cs.firmware == Firmwares.Ateryx)
                    {
                        start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
                        AddBackstageViewPage(typeof(ConfigAteryxSensors), "Ateryx Zero Sensors");
                        AddBackstageViewPage(typeof(ConfigAteryx), "Ateryx Pids");
                    }

                    if (!gotAllParams)
                    {
                        if (start == null)
                        {
                            start = AddBackstageViewPage(typeof(ConfigParamLoading), Strings.Loading);
                        }
                        else
                        {
                            AddBackstageViewPage(typeof(ConfigParamLoading), Strings.Loading);
                        }
                    }

                    AddBackstageViewPage(typeof(ConfigPlanner), Strings.Planner);
                }
                else
                {
                    start = AddBackstageViewPage(typeof(ConfigPlanner), Strings.Planner);
                }

                // apply theme before trying to display it
                ThemeManager.ApplyThemeTo(this);

                // remeber last page accessed
                foreach (BackstageViewPage page in backstageView.Pages)
                {
                    if (page.LinkText == lastpagename)
                    {
                        backstageView.ActivatePage(page);
                        break;
                    }
                }


                if (backstageView.SelectedPage == null && start != null)
                {
                    this.BeginInvoke((Action) delegate
                    {
                        try
                        {
                            backstageView.ActivatePage(start);
                        }
                        catch (Exception ex)
                        {
                            log.Error(ex);
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemplo n.º 18
0
 public ConfigRawParams()
 {
     InitializeComponent();
     ThemeManager.ApplyThemeTo(this);
     Activate();
 }
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (MainV2.joystick == null || MainV2.joystick.enabled == false)
                {
                    //Console.WriteLine(DateTime.Now.Millisecond + " start ");
                    Joystick joy = MainV2.joystick;
                    if (joy == null)
                    {
                        joy = new Joystick();
                        if (CMB_CH1.Text != "")
                        {
                            joy.setChannel(1,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH1.Text),
                                           revCH1.Checked, int.Parse(expo_ch1.Text));
                        }
                        if (CMB_CH2.Text != "")
                        {
                            joy.setChannel(2,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH2.Text),
                                           revCH2.Checked, int.Parse(expo_ch2.Text));
                        }
                        if (CMB_CH3.Text != "")
                        {
                            joy.setChannel(3,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH3.Text),
                                           revCH3.Checked, int.Parse(expo_ch3.Text));
                        }
                        if (CMB_CH4.Text != "")
                        {
                            joy.setChannel(4,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH4.Text),
                                           revCH4.Checked, int.Parse(expo_ch4.Text));
                        }
                        if (CMB_CH5.Text != "")
                        {
                            joy.setChannel(5,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH5.Text),
                                           revCH5.Checked, int.Parse(expo_ch5.Text));
                        }
                        if (CMB_CH6.Text != "")
                        {
                            joy.setChannel(6,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH6.Text),
                                           revCH6.Checked, int.Parse(expo_ch6.Text));
                        }
                        if (CMB_CH7.Text != "")
                        {
                            joy.setChannel(7,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH7.Text),
                                           revCH7.Checked, int.Parse(expo_ch7.Text));
                        }
                        if (CMB_CH8.Text != "")
                        {
                            joy.setChannel(8,
                                           (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH8.Text),
                                           revCH8.Checked, int.Parse(expo_ch8.Text));
                        }

                        joy.elevons = CHK_elevons.Checked;

                        joy.AcquireJoystick(CMB_joysticks.Text);

                        joy.name = CMB_joysticks.Text;

                        noButtons = joy.getNumButtons();

                        noButtons = Math.Min(15, noButtons);

                        SuspendLayout();

                        MainV2.joystick = joy;

                        for (int f = 0; f < noButtons; f++)
                        {
                            string name = (f).ToString();

                            doButtontoUI(name, 10, CMB_CH8.Bottom + 20 + f * 25);

                            var config = joy.getButton(f);

                            joy.setButton(f, config);
                        }

                        ResumeLayout();

                        ThemeManager.ApplyThemeTo(this);

                        CMB_joysticks.SelectedIndex = CMB_joysticks.Items.IndexOf(joy.name);
                    }

                    MainV2.joystick.elevons = CHK_elevons.Checked;

                    MainV2.comPort.MAV.cs.rcoverridech1 = joy.getValueForChannel(1, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech2 = joy.getValueForChannel(2, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech3 = joy.getValueForChannel(3, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech4 = joy.getValueForChannel(4, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech5 = joy.getValueForChannel(5, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech6 = joy.getValueForChannel(6, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech7 = joy.getValueForChannel(7, CMB_joysticks.Text);
                    MainV2.comPort.MAV.cs.rcoverridech8 = joy.getValueForChannel(8, CMB_joysticks.Text);

                    //Console.WriteLine(DateTime.Now.Millisecond + " end ");
                }
            }
            catch (SharpDX.SharpDXException ex)
            {
                ex.ToString();
                if (MainV2.joystick != null && MainV2.joystick.enabled == true)
                {
                    BUT_enable_Click(null, null);
                }

                if (ex.Message.Contains("DIERR_NOTACQUIRED"))
                {
                    MainV2.joystick = null;
                }
            }
            catch
            {
            }

            progressBarRoll.Value     = MainV2.comPort.MAV.cs.rcoverridech1;
            progressBarPith.Value     = MainV2.comPort.MAV.cs.rcoverridech2;
            progressBarThrottle.Value = MainV2.comPort.MAV.cs.rcoverridech3;
            progressBarRudder.Value   = MainV2.comPort.MAV.cs.rcoverridech4;
            ProgressBarCH5.Value      = MainV2.comPort.MAV.cs.rcoverridech5;
            ProgressBarCH6.Value      = MainV2.comPort.MAV.cs.rcoverridech6;
            ProgressBarCH7.Value      = MainV2.comPort.MAV.cs.rcoverridech7;
            ProgressBarCH8.Value      = MainV2.comPort.MAV.cs.rcoverridech8;

            try
            {
                if (MainV2.joystick != null)
                {
                    progressBarRoll.maxline     = MainV2.joystick.getRawValueForChannel(1);
                    progressBarPith.maxline     = MainV2.joystick.getRawValueForChannel(2);
                    progressBarThrottle.maxline = MainV2.joystick.getRawValueForChannel(3);
                    progressBarRudder.maxline   = MainV2.joystick.getRawValueForChannel(4);
                    ProgressBarCH5.maxline      = MainV2.joystick.getRawValueForChannel(5);
                    ProgressBarCH6.maxline      = MainV2.joystick.getRawValueForChannel(6);
                    ProgressBarCH7.maxline      = MainV2.joystick.getRawValueForChannel(7);
                    ProgressBarCH8.maxline      = MainV2.joystick.getRawValueForChannel(8);
                }
            }
            catch
            {
                //Exception Error in the application. -2147024866 (DIERR_INPUTLOST)
            }

            try
            {
                for (int f = 0; f < noButtons; f++)
                {
                    string name = (f).ToString();

                    var items = this.Controls.Find("hbar" + name, false);

                    if (items.Length > 0)
                    {
                        ((HorizontalProgressBar)items[0]).Value =
                            MainV2.joystick.isButtonPressed(f) ? 100 : 0;
                    }
                }
            }
            catch
            {
            } // this is for buttons - silent fail
        }
Exemplo n.º 20
0
        private void SoftwareConfig_Load(object sender, EventArgs e)
        {
            try
            {
                BackstageView.BackstageViewPage start = null;

                if (MainV2.comPort.BaseStream.IsOpen)
                {
                    AddBackstageViewPage(new ConfigFlightModes(), "Flight Modes");

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
                    {
                        AddBackstageViewPage(new ConfigAC_Fence(), "GeoFence");
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
                    {
                        start = AddBackstageViewPage(new ConfigSimplePids(), "Basic Pids");

                        //     AddBackstageViewPage(new ConfigSimplePidsV2(), "Basic Pids V2");
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
                    {
                        start = AddBackstageViewPage(new ConfigArduplane(), "APM:Plane Pids");
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduRover)
                    {
                        start = AddBackstageViewPage(new ConfigArdurover(), "APM:Rover Pids");
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
                    {
                        // var configpanel = new Controls.ConfigPanel(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "ArduCopterConfig.xml");
                        // AddBackstageViewPage(configpanel, "ArduCopter Pids");

                        AddBackstageViewPage(new ConfigArducopter(), "APM:Copter Pids");
                    }

                    if (MainV2.comPort.MAV.param["H_SWASH_TYPE"] != null)
                    {
                        AddBackstageViewPage(new ConfigTradHeli(), "Heli Setup");
                    }

                    AddBackstageViewPage(new ConfigFriendlyParams {
                        ParameterMode = ParameterMetaDataConstants.Standard
                    }, "Standard Params");
                    AddBackstageViewPage(new ConfigFriendlyParams {
                        ParameterMode = ParameterMetaDataConstants.Advanced
                    }, "Advanced Params");
                    AddBackstageViewPage(new ConfigRawParams(), "Full Parameter List");



                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.Ateryx)
                    {
                        start = AddBackstageViewPage(new ConfigFlightModes(), "Flight Modes");
                        AddBackstageViewPage(new ConfigAteryxSensors(), "Ateryx Zero Sensors");
                        AddBackstageViewPage(new ConfigAteryx(), "Ateryx Pids");
                    }

                    AddBackstageViewPage(new ConfigPlanner(), "Planner");
                }
                else
                {
                    start = AddBackstageViewPage(new ConfigPlanner(), "Planner");
                }

                AddBackstageViewPage(new ConfigHelp(), "Help");

                // remeber last page accessed
                foreach (BackstageView.BackstageViewPage page in backstageView.Pages)
                {
                    if (page.LinkText == lastpagename)
                    {
                        this.backstageView.ActivatePage(page);
                        break;
                    }
                }


                if (this.backstageView.SelectedPage == null)
                {
                    backstageView.ActivatePage(start);
                }

                ThemeManager.ApplyThemeTo(this);
            }
            catch (Exception ex) { log.Error(ex); }
        }
Exemplo n.º 21
0
 public Setup()
 {
     InitializeComponent();
     ThemeManager.ApplyThemeTo(this);
     this.Controls.Add(flashMessage);
 }
Exemplo n.º 22
0
        private void SoftwareConfig_Load(object sender, EventArgs e)
        {
            try
            {
                ConfigArducopter conf_PID = new ConfigArducopter();
                conf_PID.Dock = DockStyle.Fill;
                TabPage pid_tp = new TabPage();//Create new tabpage
                pid_tp.Controls.Add(conf_PID);
                pid_tp.Text = "参数调试";
                tabControl_debug.TabPages.Add(pid_tp);
                tabControl_debug.SelectedIndexChanged += new EventHandler(conf_PID.OnFocus);

                ConfigRawParams conf_rawParams = new ConfigRawParams();
                conf_rawParams.Dock = DockStyle.Fill;
                TabPage rp_tp = new TabPage();//Create new tabpage
                rp_tp.Controls.Add(conf_rawParams);
                rp_tp.Text = "参数列表";
                tabControl_debug.TabPages.Add(rp_tp);
                tabControl_debug.SelectedIndexChanged += new EventHandler(conf_rawParams.OnFocus);

                return;

                BackstageViewPage start = null;

                if (MainV2.comPort.BaseStream.IsOpen)
                {
                    start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
                    {
                        AddBackstageViewPage(typeof(ConfigAC_Fence), Strings.GeoFence);
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2)
                    {
                        start = AddBackstageViewPage(typeof(ConfigSimplePids), Strings.BasicTuning);

                        AddBackstageViewPage(typeof(ConfigArducopter), Strings.ExtendedTuning);
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane)
                    {
                        start = AddBackstageViewPage(typeof(ConfigArduplane), Strings.BasicTuning);
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduRover)
                    {
                        start = AddBackstageViewPage(typeof(ConfigArdurover), Strings.BasicTuning);
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduTracker)
                    {
                        start = AddBackstageViewPage(typeof(ConfigAntennaTracker), Strings.ExtendedTuning);
                    }
                    AddBackstageViewPage(typeof(ConfigFriendlyParams), Strings.StandardParams);

                    if (MainV2.DisplayConfiguration.displayAdvancedParams)
                    {
                        AddBackstageViewPage(typeof(ConfigFriendlyParamsAdv), Strings.AdvancedParams, null, true);
                    }
                    if (MainV2.DisplayConfiguration.displayFullParamList)
                    {
                        AddBackstageViewPage(typeof(ConfigRawParams), Strings.FullParameterList, null, true);
                    }
                    if (MainV2.DisplayConfiguration.displayFullParamTree)
                    {
                        AddBackstageViewPage(typeof(ConfigRawParamsTree), Strings.FullParameterTree, null, true);
                    }

                    if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.Ateryx)
                    {
                        start = AddBackstageViewPage(typeof(ConfigFlightModes), Strings.FlightModes);
                        AddBackstageViewPage(typeof(ConfigAteryxSensors), "Ateryx Zero Sensors");
                        AddBackstageViewPage(typeof(ConfigAteryx), "Ateryx Pids");
                    }

                    AddBackstageViewPage(typeof(ConfigPlanner), "Planner");
                }
                else
                {
                    start = AddBackstageViewPage(typeof(ConfigPlanner), "Planner");
                }

                // apply theme before trying to display it
                ThemeManager.ApplyThemeTo(this);

                // remeber last page accessed
                foreach (BackstageViewPage page in backstageView.Pages)
                {
                    if (page.LinkText == lastpagename)
                    {
                        backstageView.ActivatePage(page);
                        break;
                    }
                }


                if (backstageView.SelectedPage == null && start != null)
                {
                    backstageView.ActivatePage(start);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemplo n.º 23
0
        public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            if (text == null)
            {
                text = "";
            }

            if (caption == null)
            {
                caption = "";
            }

            // ensure we are always in a known state
            _state = DialogResult.None;

            // convert to nice wrapped lines.
            text = AddNewLinesToText(text);
            // get pixel width and height
            Size textSize = TextRenderer.MeasureText(text, SystemFonts.DefaultFont);

            // allow for icon
            if (icon != MessageBoxIcon.None)
            {
                textSize.Width += SystemIcons.Question.Width;
            }

            var msgBoxFrm = new Form
            {
                FormBorderStyle = FormBorderStyle.FixedDialog,
                ShowInTaskbar   = false,
                StartPosition   = FormStartPosition.CenterScreen,
                Text            = caption,
                MaximizeBox     = false,
                MinimizeBox     = false,
                Width           = textSize.Width + 50,
                Height          = textSize.Height + 100,
                TopMost         = true,
            };

            Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle);
            int       titleHeight     = screenRectangle.Top - msgBoxFrm.Top;

            var lblMessage = new Label
            {
                Left   = 58,
                Top    = 15,
                Width  = textSize.Width + 10,
                Height = textSize.Height + 10,
                Text   = text
            };

            msgBoxFrm.Controls.Add(lblMessage);

            var actualIcon = getMessageBoxIcon(icon);

            if (actualIcon == null)
            {
                lblMessage.Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN);
            }
            else
            {
                var iconPbox = new PictureBox
                {
                    Image    = actualIcon.ToBitmap(),
                    Location = new Point(FORM_X_MARGIN, FORM_Y_MARGIN)
                };
                msgBoxFrm.Controls.Add(iconPbox);
            }


            AddButtonsToForm(msgBoxFrm, buttons);

            // display even if theme fails
            try
            {
                ThemeManager.ApplyThemeTo(msgBoxFrm);
            }
            catch { }

            if (System.Windows.Forms.Application.OpenForms.Count > 0)
            {
                msgBoxFrm.StartPosition = FormStartPosition.Manual;
                Form parentForm = System.Windows.Forms.Application.OpenForms[0];
                // center of first form
                msgBoxFrm.Location = new Point(parentForm.Location.X + parentForm.Width / 2 - msgBoxFrm.Width / 2,
                                               parentForm.Location.Y + parentForm.Height / 2 - msgBoxFrm.Height / 2);
                DialogResult test = msgBoxFrm.ShowDialog();
            }
            else
            {
                DialogResult test = msgBoxFrm.ShowDialog();
            }

            DialogResult answer = _state;

            return(answer);
        }
Exemplo n.º 24
0
        private void HardwareConfig_Load(object sender, EventArgs e)
        {
            ResourceManager rm = new ResourceManager(this.GetType());

            if (!gotAllParams)
            {
                if (MainV2.comPort.BaseStream.IsOpen)
                {
                    AddBackstageViewPage(typeof(ConfigParamLoading), Strings.Loading);
                }
            }

            if (MainV2.DisplayConfiguration.displayInstallFirmware)
            {
                // if (!Program.WindowsStoreApp)
                {
                    AddBackstageViewPage(typeof(ConfigFirmwareDisabled), rm.GetString("backstageViewPagefw.Text"),
                                         isConnected);
                    AddBackstageViewPage(typeof(ConfigFirmwareManifest), rm.GetString("backstageViewPagefw.Text"),
                                         isDisConnected);
                    AddBackstageViewPage(typeof(ConfigFirmware), rm.GetString("backstageViewPagefw.Text") + " Legacy",
                                         isDisConnected);
                }
            }


            var mand = AddBackstageViewPage(typeof(ConfigMandatory), rm.GetString("backstageViewPagemand.Text"), isConnected && gotAllParams);

            if (MainV2.DisplayConfiguration.displayFrameType)
            {
                //AddBackstageViewPage(typeof(ConfigTradHeli), rm.GetString("backstageViewPagetradheli.Text"), isHeli && gotAllParams, mand);
                AddBackstageViewPage(typeof(ConfigTradHeli4), rm.GetString("backstageViewPagetradheli.Text"), isHeli && gotAllParams, mand);
                AddBackstageViewPage(typeof(ConfigFrameType), rm.GetString("backstageViewPageframetype.Text"), isCopter && gotAllParams && !isCopter35plus, mand);
                AddBackstageViewPage(typeof(ConfigFrameClassType), rm.GetString("backstageViewPageframetype.Text"),
                                     MainV2.comPort.MAV.param.ContainsKey("FRAME_CLASS") || isCopter && gotAllParams && isCopter35plus,
                                     mand);
            }

            if (MainV2.DisplayConfiguration.displayAccelCalibration)
            {
                AddBackstageViewPage(typeof(ConfigAccelerometerCalibration), rm.GetString("backstageViewPageaccel.Text"), isConnected && gotAllParams, mand);
            }

            if (MainV2.DisplayConfiguration.displayCompassConfiguration)
            {
                if (MainV2.comPort.MAV.param.ContainsKey("COMPASS_PRIO1_ID"))
                {
                    AddBackstageViewPage(typeof(ConfigHWCompass2), rm.GetString("backstageViewPagecompass.Text"),
                                         isConnected && gotAllParams, mand);
                }
                else
                {
                    AddBackstageViewPage(typeof(ConfigHWCompass), rm.GetString("backstageViewPagecompass.Text"),
                                         isConnected && gotAllParams, mand);
                }
            }

            if (MainV2.DisplayConfiguration.displayRadioCalibration)
            {
                AddBackstageViewPage(typeof(ConfigRadioInput), rm.GetString("backstageViewPageradio.Text"), isConnected && gotAllParams, mand);
                AddBackstageViewPage(typeof(ConfigRadioOutput), "Servo Output", isConnected && gotAllParams, mand);
            }
            if (MainV2.DisplayConfiguration.displayEscCalibration)
            {
                AddBackstageViewPage(typeof(ConfigESCCalibration), "ESC Calibration", isConnected && gotAllParams, mand);
            }
            if (MainV2.DisplayConfiguration.displayFlightModes)
            {
                AddBackstageViewPage(typeof(ConfigFlightModes), rm.GetString("backstageViewPageflmode.Text"), isConnected && gotAllParams, mand);
            }
            if (MainV2.DisplayConfiguration.displayFailSafe)
            {
                AddBackstageViewPage(typeof(ConfigFailSafe), rm.GetString("backstageViewPagefs.Text"), isConnected && gotAllParams, mand);
            }

            if (MainV2.DisplayConfiguration.displayHWIDs)
            {
                AddBackstageViewPage(typeof(ConfigHWIDs), "HW ID", isConnected && gotAllParams, mand);
            }

            var opt = AddBackstageViewPage(typeof(ConfigOptional), rm.GetString("backstageViewPageopt.Text"));

            AddBackstageViewPage(typeof(ConfigSerialInjectGPS), "RTK/GPS Inject", true, opt);
            if (MainV2.DisplayConfiguration.displaySikRadio)
            {
                AddBackstageViewPage(typeof(Sikradio), rm.GetString("backstageViewPageSikradio.Text"), true, opt);
            }

            if (MainV2.DisplayConfiguration.displayADSB)
            {
                AddBackstageViewPage(typeof(ConfigADSB), "ADSB", isConnected && gotAllParams, mand);
            }

            if (MainV2.DisplayConfiguration.displayGPSOrder)
            {
                AddBackstageViewPage(typeof(ConfigGPSOrder), "CAN GPS Order", isConnected && gotAllParams, opt);
            }

            if (MainV2.DisplayConfiguration.displayBattMonitor)
            {
                AddBackstageViewPage(typeof(ConfigBatteryMonitoring), rm.GetString("backstageViewPagebatmon.Text"), isConnected && gotAllParams, opt);
                AddBackstageViewPage(typeof(ConfigBatteryMonitoring2), rm.GetString("backstageViewPageBatt2.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayCAN)
            {
                //AddBackstageViewPage(typeof(ConfigHWCAN), "CAN", isConnected, opt);
                AddBackstageViewPage(typeof(ConfigUAVCAN), "UAVCAN", true, opt);
            }

            AddBackstageViewPage(typeof(Joystick.JoystickSetup), "Joystick", true, opt);

            if (MainV2.DisplayConfiguration.displayCompassMotorCalib)
            {
                AddBackstageViewPage(typeof(ConfigCompassMot), rm.GetString("backstageViewPagecompassmot.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayRangeFinder)
            {
                AddBackstageViewPage(typeof(ConfigHWRangeFinder), rm.GetString("backstageViewPagesonar.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayAirSpeed)
            {
                AddBackstageViewPage(typeof(ConfigHWAirspeed), rm.GetString("backstageViewPageairspeed.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayPx4Flow)
            {
                AddBackstageViewPage(typeof(ConfigHWPX4Flow), rm.GetString("backstageViewPagePX4Flow.Text"), true, opt);
            }
            if (MainV2.DisplayConfiguration.displayOpticalFlow)
            {
                AddBackstageViewPage(typeof(ConfigHWOptFlow), rm.GetString("backstageViewPageoptflow.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayOsd)
            {
                AddBackstageViewPage(typeof(ConfigHWOSD), rm.GetString("backstageViewPageosd.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayCameraGimbal)
            {
                AddBackstageViewPage(typeof(ConfigMount), rm.GetString("backstageViewPagegimbal.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayAntennaTracker)
            {
                AddBackstageViewPage(typeof(ConfigAntennaTracker), rm.GetString("backstageViewPageAntTrack.Text"), isTracker, opt);
            }
            if (MainV2.DisplayConfiguration.displayMotorTest)
            {
                AddBackstageViewPage(typeof(ConfigMotorTest), rm.GetString("backstageViewPageMotorTest.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayBluetooth)
            {
                AddBackstageViewPage(typeof(ConfigHWBT), rm.GetString("backstageViewPagehwbt.Text"), true, opt);
            }
            if (MainV2.DisplayConfiguration.displayParachute)
            {
                AddBackstageViewPage(typeof(ConfigHWParachute), rm.GetString("backstageViewPageParachute.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayEsp)
            {
                AddBackstageViewPage(typeof(ConfigHWESP8266), rm.GetString("backstageViewPageESP.Text"), isConnected && gotAllParams, opt);
            }
            if (MainV2.DisplayConfiguration.displayAntennaTracker)
            {
                AddBackstageViewPage(typeof(Antenna.TrackerUI), "Antenna Tracker", true, opt);
            }

            AddBackstageViewPage(typeof(ConfigFFT), "FFT Setup", isConnected && gotAllParams, opt);

            if (MainV2.DisplayConfiguration.isAdvancedMode)
            {
                var adv = AddBackstageViewPage(typeof(ConfigAdvanced), "Advanced");

                AddBackstageViewPage(typeof(ConfigTerminal), "Terminal", true, adv);

                AddBackstageViewPage(typeof(ConfigREPL), "Script REPL", isConnected, adv);
            }

            // remeber last page accessed
            foreach (BackstageViewPage page in backstageView.Pages)
            {
                if (page.LinkText == lastpagename && page.Show)
                {
                    backstageView.ActivatePage(page);
                    break;
                }
            }

            ThemeManager.ApplyThemeTo(this);
        }
Exemplo n.º 25
0
        void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                MainV2.comPort.MAV.cs.UpdateCurrentSettings(currentStateBindingSource);
            }
            catch { }

            float pwm = 0;

            if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduPlane || MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduRover || MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.Ateryx) // APM
            {
                if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH") || MainV2.comPort.MAV.param.ContainsKey("MODE_CH"))
                {
                    int sw = 0;
                    if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH"))
                    {
                        sw = (int)(float)MainV2.comPort.MAV.param["FLTMODE_CH"];
                    }
                    else
                    {
                        sw = (int)(float)MainV2.comPort.MAV.param["MODE_CH"];
                    }

                    switch (sw)
                    {
                    case 5:
                        pwm = MainV2.comPort.MAV.cs.ch5in;
                        break;

                    case 6:
                        pwm = MainV2.comPort.MAV.cs.ch6in;
                        break;

                    case 7:
                        pwm = MainV2.comPort.MAV.cs.ch7in;
                        break;

                    case 8:
                        pwm = MainV2.comPort.MAV.cs.ch8in;
                        break;

                    default:

                        break;
                    }

                    if (MainV2.comPort.MAV.param.ContainsKey("FLTMODE_CH"))
                    {
                        LBL_flightmodepwm.Text = MainV2.comPort.MAV.param["FLTMODE_CH"].ToString() + ": " + pwm.ToString();
                    }
                    else
                    {
                        LBL_flightmodepwm.Text = MainV2.comPort.MAV.param["MODE_CH"].ToString() + ": " + pwm.ToString();
                    }
                }
            }

            if (MainV2.comPort.MAV.cs.firmware == MainV2.Firmwares.ArduCopter2) // ac2
            {
                pwm = MainV2.comPort.MAV.cs.ch5in;
                LBL_flightmodepwm.Text = "5: " + MainV2.comPort.MAV.cs.ch5in.ToString();
            }

            Control[] fmodelist = new Control[] { CMB_fmode1, CMB_fmode2, CMB_fmode3, CMB_fmode4, CMB_fmode5, CMB_fmode6 };

            foreach (Control ctl in fmodelist)
            {
                ThemeManager.ApplyThemeTo(ctl);
            }

            byte no = readSwitch(pwm);

            fmodelist[no].BackColor = Color.Green;
        }
Exemplo n.º 26
0
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            int failed = 0;

            foreach (string value in temp)
            {
                try
                {
                    _can.SetParameter(_node, value, _changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    failed++;
                    CustomMessageBox.Show("Set " + value + " Failed " + ex.ToString());
                }
            }

            _can.SaveConfig(_node);

            if (failed > 0)
            {
                CustomMessageBox.Show("Some Parameters Failed to be saved.", "Saved");
            }
            else
            {
                CustomMessageBox.Show("Parameters successfully saved.", "Saved");
            }
        }
Exemplo n.º 27
0
        private void HardwareConfig_Load(object sender, EventArgs e)
        {
            ResourceManager rm = new ResourceManager(this.GetType());

            if (MainV2.DisplayConfiguration.displayInstallFirmware)
            {
                if (!Program.WindowsStoreApp)
                {
                    AddBackstageViewPage(typeof(ConfigFirmwareDisabled), rm.GetString("backstageViewPagefw.Text"),
                                         isConnected);
                    AddBackstageViewPage(typeof(ConfigFirmware), rm.GetString("backstageViewPagefw.Text"),
                                         isDisConnected);
                }
            }

            if (MainV2.DisplayConfiguration.displayWizard)
            {
                AddBackstageViewPage(typeof(ConfigWizard), rm.GetString("backstageViewPagewizard.Text"));
            }

            var mand = AddBackstageViewPage(typeof(ConfigMandatory), rm.GetString("backstageViewPagemand.Text"), isConnected);

            if (MainV2.DisplayConfiguration.displayFrameType)
            {
                AddBackstageViewPage(typeof(ConfigTradHeli), rm.GetString("backstageViewPagetradheli.Text"), isHeli, mand);
                AddBackstageViewPage(typeof(ConfigFrameType), rm.GetString("backstageViewPageframetype.Text"), isCopter && !isCopter35plus, mand);
                AddBackstageViewPage(typeof(ConfigFrameClassType), rm.GetString("backstageViewPageframetype.Text"), isCopter && isCopter35plus, mand);
            }

            if (MainV2.DisplayConfiguration.displayAccelCalibration)
            {
                AddBackstageViewPage(typeof(ConfigAccelerometerCalibration), rm.GetString("backstageViewPageaccel.Text"), isConnected, mand);
            }

            AddBackstageViewPage(typeof(ConfigHWCompass), rm.GetString("backstageViewPagecompass.Text"), isConnected, mand);

            if (MainV2.DisplayConfiguration.displayRadioCalibration)
            {
                AddBackstageViewPage(typeof(ConfigRadioInput), rm.GetString("backstageViewPageradio.Text"), isConnected, mand);
                AddBackstageViewPage(typeof(ConfigRadioOutput), "Servo Output", isConnected, mand);
            }
            if (MainV2.DisplayConfiguration.displayEscCalibration)
            {
                AddBackstageViewPage(typeof(ConfigESCCalibration), "ESC Calibration", isConnected, mand);
            }
            if (MainV2.DisplayConfiguration.displayFlightModes)
            {
                AddBackstageViewPage(typeof(ConfigFlightModes), rm.GetString("backstageViewPageflmode.Text"), isConnected, mand);
            }
            if (MainV2.DisplayConfiguration.displayFailSafe)
            {
                AddBackstageViewPage(typeof(ConfigFailSafe), rm.GetString("backstageViewPagefs.Text"), isConnected, mand);
            }

            var opt = AddBackstageViewPage(typeof(ConfigOptional), rm.GetString("backstageViewPageopt.Text"));

            AddBackstageViewPage(typeof(ConfigGPSInject), "RTK/GPS Inject", true, opt);
            if (MainV2.DisplayConfiguration.displaySikRadio)
            {
                AddBackstageViewPage(typeof(Sikradio), rm.GetString("backstageViewPageSikradio.Text"), true, opt);
            }
            if (MainV2.DisplayConfiguration.displayBattMonitor)
            {
                AddBackstageViewPage(typeof(ConfigBatteryMonitoring), rm.GetString("backstageViewPagebatmon.Text"), isConnected, opt);
                AddBackstageViewPage(typeof(ConfigBatteryMonitoring2), rm.GetString("backstageViewPageBatt2.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayUAVCAN)
            {
                AddBackstageViewPage(typeof(ConfigHWUAVCAN), "UAVCAN", isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayCompassMotorCalib)
            {
                AddBackstageViewPage(typeof(ConfigCompassMot), rm.GetString("backstageViewPagecompassmot.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayRangeFinder)
            {
                AddBackstageViewPage(typeof(ConfigHWRangeFinder), rm.GetString("backstageViewPagesonar.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayAirSpeed)
            {
                AddBackstageViewPage(typeof(ConfigHWAirspeed), rm.GetString("backstageViewPageairspeed.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayPx4Flow)
            {
                AddBackstageViewPage(typeof(ConfigHWPX4Flow), rm.GetString("backstageViewPagePX4Flow.Text"), true, opt);
            }
            if (MainV2.DisplayConfiguration.displayOpticalFlow)
            {
                AddBackstageViewPage(typeof(ConfigHWOptFlow), rm.GetString("backstageViewPageoptflow.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayOsd)
            {
                AddBackstageViewPage(typeof(ConfigHWOSD), rm.GetString("backstageViewPageosd.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayCameraGimbal)
            {
                AddBackstageViewPage(typeof(ConfigMount), rm.GetString("backstageViewPagegimbal.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayAntennaTracker)
            {
                AddBackstageViewPage(typeof(ConfigAntennaTracker), rm.GetString("backstageViewPageAntTrack.Text"), isTracker, opt);
            }
            if (MainV2.DisplayConfiguration.displayMotorTest)
            {
                AddBackstageViewPage(typeof(ConfigMotorTest), rm.GetString("backstageViewPageMotorTest.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayBluetooth)
            {
                AddBackstageViewPage(typeof(ConfigHWBT), rm.GetString("backstageViewPagehwbt.Text"), true, opt);
            }
            if (MainV2.DisplayConfiguration.displayParachute)
            {
                AddBackstageViewPage(typeof(ConfigHWParachute), rm.GetString("backstageViewPageParachute.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayEsp)
            {
                AddBackstageViewPage(typeof(ConfigHWESP8266), rm.GetString("backstageViewPageESP.Text"), isConnected, opt);
            }
            if (MainV2.DisplayConfiguration.displayAntennaTracker)
            {
                AddBackstageViewPage(typeof(Antenna.Tracker), "Antenna Tracker", true, opt);
            }

            AddBackstageViewPage(typeof(ConfigFFT), "FFT Setup", isConnected, opt);

            // remeber last page accessed
            foreach (BackstageViewPage page in backstageView.Pages)
            {
                if (page.LinkText == lastpagename && page.Show)
                {
                    backstageView.ActivatePage(page);
                    break;
                }
            }

            ThemeManager.ApplyThemeTo(this);
        }
Exemplo n.º 28
0
        public LogDownloadMavLink()
        {
            InitializeComponent();

            ThemeManager.ApplyThemeTo(this);
        }
Exemplo n.º 29
0
        public void Activate()
        {
            TrackerGeneric.Activate();

            ThemeManager.ApplyThemeTo(this);
        }
Exemplo n.º 30
0
        public int WizardValidate()
        {
            comport = CMB_port.Text;

            if (comport == "")
            {
                CustomMessageBox.Show("Please select a comport", "error");
                return(0);
            }

            if (!fwdone)
            {
                pdr = new ProgressReporterDialogue();

                pdr.DoWork += pdr_DoWork;

                ThemeManager.ApplyThemeTo(pdr);

                pdr.RunBackgroundOperationAsync();

                if (pdr.doWorkArgs.CancelRequested || !string.IsNullOrEmpty(pdr.doWorkArgs.ErrorMessage))
                {
                    return(0);
                }
            }

            if (MainV2.comPort.BaseStream.IsOpen)
            {
                MainV2.comPort.BaseStream.Close();
            }

            // setup for over usb
            MainV2.comPort.BaseStream.BaudRate = 115200;
            MainV2.comPort.BaseStream.PortName = comport;


            MainV2.comPort.Open(true);

            // try again
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                CustomMessageBox.Show("Error connecting. Please unplug, plug back in, wait 10 seconds, and click OK", "Try Again");
                MainV2.comPort.Open(true);
            }

            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                return(0);
            }

            if (string.IsNullOrEmpty(pdr.doWorkArgs.ErrorMessage))
            {
                if (Wizard.config["fwtype"].ToString() == "copter")
                {
                    // check if its a quad, and show the frame type screen
                    return(1);
                }
                else
                {
                    // skip the frame type screen as its not valid for anythine else
                    return(2);
                }
            }

            return(0);
        }