예제 #1
0
        public void Activate()
        {
            if (MainV2.comPort.MAV.param["H_GYR_ENABLE"] == null)
            {
                this.Enabled = false;
                return;
            }

            timer.Tick += new EventHandler(timer_Tick);

            timer.Enabled  = true;
            timer.Interval = 100;
            timer.Start();

            mavlinkNumericUpDown1min.setup(800, 1400, 1, 1, "HS1_MIN", MainV2.comPort.MAV.param);
            mavlinkNumericUpDown1max.setup(1600, 2200, 1, 1, "HS1_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDown2min.setup(800, 1400, 1, 1, "HS2_MIN", MainV2.comPort.MAV.param);
            mavlinkNumericUpDown2max.setup(1600, 2200, 1, 1, "HS2_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDown3min.setup(800, 1400, 1, 1, "HS3_MIN", MainV2.comPort.MAV.param);
            mavlinkNumericUpDown3max.setup(1600, 2200, 1, 1, "HS3_MAX", MainV2.comPort.MAV.param);

            mavlinkNumericUpDownpitchmax.setup(10, 65, 100, 1, "H_PIT_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDownrollmax.setup(10, 65, 100, 1, "H_ROL_MAX", MainV2.comPort.MAV.param);

            startup = true;
            try
            {
                if (MainV2.comPort.MAV.param.ContainsKey("H_SWASH_TYPE"))
                {
                    CCPM.Checked         = MainV2.comPort.MAV.param["H_SWASH_TYPE"].ToString() == "0" ? true : false;
                    H_SWASH_TYPE.Checked = !CCPM.Checked;
                }

                foreach (string value in MainV2.comPort.MAV.param.Keys)
                {
                    if (value == "")
                    {
                        continue;
                    }

                    Control[] control = this.Controls.Find(value, true);
                    if (control.Length > 0)
                    {
                        if (control[0].GetType() == typeof(TextBox))
                        {
                            TextBox temp   = (TextBox)control[0];
                            string  option = MainV2.comPort.MAV.param[value].ToString();
                            temp.Text = option;
                        }
                        if (control[0].GetType() == typeof(NumericUpDown))
                        {
                            NumericUpDown temp   = (NumericUpDown)control[0];
                            string        option = MainV2.comPort.MAV.param[value].ToString();
                            temp.Text = option;
                        }
                        if (control[0].GetType() == typeof(CheckBox))
                        {
                            CheckBox temp   = (CheckBox)control[0];
                            string   option = MainV2.comPort.MAV.param[value].ToString();
                            temp.Checked = option == "1" ? true : false;
                        }
                        if (control[0].GetType() == typeof(MyTrackBar))
                        {
                            ArdupilotMega.Controls.MyTrackBar temp = (MyTrackBar)control[0];
                            string option = MainV2.comPort.MAV.param[value].ToString();
                            temp.Value = int.Parse(option);
                        }
                    }
                }

                HS1_REV.Checked = MainV2.comPort.MAV.param["HS1_REV"].ToString() == "-1";
                HS2_REV.Checked = MainV2.comPort.MAV.param["HS2_REV"].ToString() == "-1";
                HS3_REV.Checked = MainV2.comPort.MAV.param["HS3_REV"].ToString() == "-1";
                HS4_REV.Checked = MainV2.comPort.MAV.param["HS4_REV"].ToString() == "-1";
            }
            catch { }
            startup = false;
        }
        private void ConfigTradHeli_Load(object sender, EventArgs e)
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                this.Enabled = false;
                return;
            }
            else
            {
                this.Enabled = true;
            }

            if (MainV2.comPort.param["H_GYR_ENABLE"] == null)
            {
                this.Enabled = false;
                return;
            }

            timer.Tick += new EventHandler(timer_Tick);

            timer.Enabled  = true;
            timer.Interval = 100;
            timer.Start();

            startup = true;
            try
            {
                if (MainV2.comPort.param.ContainsKey("H_SWASH_TYPE"))
                {
                    CCPM.Checked         = MainV2.comPort.param["H_SWASH_TYPE"].ToString() == "0" ? true : false;
                    H_SWASH_TYPE.Checked = !CCPM.Checked;
                }

                foreach (string value in MainV2.comPort.param.Keys)
                {
                    if (value == "")
                    {
                        continue;
                    }

                    Control[] control = this.Controls.Find(value, true);
                    if (control.Length > 0)
                    {
                        if (control[0].GetType() == typeof(TextBox))
                        {
                            TextBox temp   = (TextBox)control[0];
                            string  option = MainV2.comPort.param[value].ToString();
                            temp.Text = option;
                        }
                        if (control[0].GetType() == typeof(NumericUpDown))
                        {
                            NumericUpDown temp   = (NumericUpDown)control[0];
                            string        option = MainV2.comPort.param[value].ToString();
                            temp.Text = option;
                        }
                        if (control[0].GetType() == typeof(CheckBox))
                        {
                            CheckBox temp   = (CheckBox)control[0];
                            string   option = MainV2.comPort.param[value].ToString();
                            temp.Checked = option == "1" ? true : false;
                        }
                        if (control[0].GetType() == typeof(MyTrackBar))
                        {
                            ArdupilotMega.Controls.MyTrackBar temp = (MyTrackBar)control[0];
                            string option = MainV2.comPort.param[value].ToString();
                            temp.Value = int.Parse(option);
                        }
                    }
                }

                HS1_REV.Checked = MainV2.comPort.param["HS1_REV"].ToString() == "-1";
                HS2_REV.Checked = MainV2.comPort.param["HS2_REV"].ToString() == "-1";
                HS3_REV.Checked = MainV2.comPort.param["HS3_REV"].ToString() == "-1";
                HS4_REV.Checked = MainV2.comPort.param["HS4_REV"].ToString() == "-1";
            }
            catch { }
            startup = false;
        }