예제 #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (ikarus.IsOpen())
     {
         IkarusAutopilotConfig cfg    = ikarus.ReadConfigAutopilot();
         ServoInfo[]           servos = { cfg.servo_ctrl, cfg.servo_ail, cfg.servo_ele, cfg.servo_thr, cfg.servo_tail, cfg.servo_pan, cfg.servo_aux };
         valores = ikarus.ReadServos();
         for (int i = 0; i < servos.Length; i++)
         {
             if (i != 0 && i != 3)
             {
                 servos[i].center = (short)valores[i];
             }
         }
         ikarus.WriteConfigAutopilot(cfg);
     }
     else
     {
         if (me.Idioma == 0)
         {
             MessageBox.Show("Error abriendo conexión con Ikarus");
         }
         else
         {
             MessageBox.Show("Error opening conection with Ikarus");
         }
     }
 }
예제 #2
0
        public IkarusAutopilotConfig ReadConfigAutopilot()
        {
            IkarusAutopilotConfig cfg = new IkarusAutopilotConfig();

            byte[] buffer = Read(Comandos.AutoPilotConfig, 0, 0, cfg.size_bytes());
            cfg.FromByteArray(buffer);

            return(cfg);
        }
예제 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (ikarus.IsOpen())
     {
         IkarusAutopilotConfig cfg    = ikarus.ReadConfigAutopilot();
         ServoInfo[]           servos = { cfg.servo_ctrl, cfg.servo_ail, cfg.servo_ele, cfg.servo_thr, cfg.servo_tail, cfg.servo_pan, cfg.servo_aux };
         for (int i = 0; i < servos.Length; i++)
         {
             servos[i].min = (short)minimos[i];
             servos[i].max = (short)maximos[i];
             if (i == 0 || i == 3)// Thr
             {
                 servos[i].center = (short)((servos[i].max + servos[i].min) / 2);
             }
             else
             {
                 servos[i].center = (short)valores[i];
             }
         }
         ikarus.WriteConfigAutopilot(cfg);
         if (me.Idioma == 0)
         {
             MessageBox.Show("Calibración realizada!");
         }
         else
         {
             MessageBox.Show("Calibration done!");
         }
     }
     else
     {
         if (me.Idioma == 0)
         {
             MessageBox.Show("Error abriendo conexión con Ikarus");
         }
         else
         {
             MessageBox.Show("Error opening conection with Ikarus");
         }
     }
 }
예제 #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            FlightPlanUSB ikarus = new FlightPlanUSB();

            if (ikarus.IsOpen())
            {
                IkarusAutopilotConfig autocfg = ikarus.ReadConfigAutopilot();

                float total;
                float co_x = Math.Abs(x_max - x_offset);
                float co_y = Math.Abs(y_max - y_offset);

                autocfg.x_off = x_offset;
                autocfg.y_off = y_offset;

                if (autocfg.IR_cross_sensor == 0)
                {
                    if (autocfg.IR_cross_rev == 0)
                    {
                        total = co_x;
                    }
                    else
                    {
                        total = co_y;
                    }
                }
                else
                {
                    total = co_x + co_y;
                }
                autocfg.IR_max = total;
                ikarus.WriteConfigAutopilot(autocfg);
                ikarus.Close();
            }
            else
            {
                MessageBox.Show("No conectado!");
            }
            this.Close();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (planUSB.IsOpen())
            {
                //timer1.Enabled = false;
                if (firstTime)
                {
                    firstTime        = false;
                    config_autopilot = planUSB.ReadConfigAutopilot();
                    UpdateControls();

                    panel1.Enabled = true;

                    UpdateRegistry();
                }

                if (me.Idioma == 0)
                {
                    labelStatus.Text = "Conectado!";
                }
                else
                {
                    labelStatus.Text = "Connected!";
                }
                labelStatus.ForeColor = Color.Green;
            }
            else
            {
                if (me.Idioma == 0)
                {
                    labelStatus.Text = "No Conectado!";
                }
                else
                {
                    labelStatus.Text = "Not Connected!!";
                }
                labelStatus.ForeColor = Color.Red;
            }
        }
예제 #6
0
 public void WriteConfigAutopilot(IkarusAutopilotConfig cfg)
 {
     byte[] buffer = cfg.ToByteArray();
     Write(Comandos.AutoPilotConfig, 0, 0, buffer);
     Flush();
 }
예제 #7
0
        private void buttonFIN_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            FlightPlanUSB ikarus = new FlightPlanUSB();

            if (ikarus.IsOpen())
            {
                IkarusAutopilotConfig autocfg = ikarus.ReadConfigAutopilot();
                autocfg.x_off = off_r;
                autocfg.y_off = off_p;

                switch (position)
                {
                case 0:
                    autocfg.IR_cross_sensor = 0;
                    autocfg.IR_cross_rev    = 0;
                    autocfg.IR_pitch_rev    = 1;
                    autocfg.IR_roll_rev     = (byte)((position2 == 2) ? 0 : 1);
                    break;

                case 1:
                    autocfg.IR_cross_sensor = 1;
                    autocfg.IR_cross_rev    = 0;
                    autocfg.IR_pitch_rev    = 1;
                    autocfg.IR_roll_rev     = (byte)((position2 == 3) ? 1 : 0);
                    break;

                case 2:
                    autocfg.IR_cross_sensor = 0;
                    autocfg.IR_cross_rev    = 1;
                    autocfg.IR_pitch_rev    = 1;
                    autocfg.IR_roll_rev     = (byte)((position2 == 4) ? 1 : 0);
                    break;

                case 3:
                    autocfg.IR_cross_sensor = 1;
                    autocfg.IR_cross_rev    = 1;
                    autocfg.IR_pitch_rev    = 0;
                    autocfg.IR_roll_rev     = (byte)((position2 == 5) ? 1 : 0);
                    break;

                case 4:
                    autocfg.IR_cross_sensor = 0;
                    autocfg.IR_cross_rev    = 0;
                    autocfg.IR_pitch_rev    = 0;
                    autocfg.IR_roll_rev     = (byte)((position2 == 6) ? 1 : 0);
                    break;

                case 5:
                    autocfg.IR_cross_sensor = 1;
                    autocfg.IR_cross_rev    = 0;
                    autocfg.IR_pitch_rev    = 0;
                    autocfg.IR_roll_rev     = (byte)((position2 == 7) ? 0 : 1);
                    break;

                case 6:
                    autocfg.IR_cross_sensor = 0;
                    autocfg.IR_cross_rev    = 1;
                    autocfg.IR_pitch_rev    = 0;
                    autocfg.IR_roll_rev     = (byte)((position2 == 0) ? 0 : 1);
                    break;

                case 7:
                    autocfg.IR_cross_sensor = 1;
                    autocfg.IR_cross_rev    = 1;
                    autocfg.IR_pitch_rev    = 1;
                    autocfg.IR_roll_rev     = (byte)((position2 == 1) ? 0 : 1);
                    break;
                }

                ikarus.WriteConfigAutopilot(autocfg);
                ikarus.Close();
            }
            this.Close();
        }
예제 #8
0
        void AnalizaDatos()
        {
            cfg = ikarus.ReadConfigAutopilot();
            int numCanales;

            ConErrores      = false;
            textBox1.Text   = "";
            cfg.tipo_mezcla = (byte)Singleton.Mezclas.Normal;

            // Motor
            numCanales = canales[(int)Mandos.THR].getNumCanales();
            if (numCanales != 1)
            {
                ConErrores     = true;
                textBox1.Text += "El motor no puede tener " + numCanales + " canales" + Environment.NewLine;
            }
            else
            {
                cfg.thr_ch            = (byte)(canales[(int)Mandos.THR].getCanales()[0]);
                cfg.servo_thr.reverse = (byte)((canales[(int)Mandos.THR].getReverses()[0]) ? 1 : 0);

                textBox1.Text += "Rev THR " + canales[(int)Mandos.THR].getReverses()[0] + Environment.NewLine;
            }

            // Alerones
            numCanales = canales[(int)Mandos.AIL].getNumCanales();
            if (numCanales == 1)
            {
                cfg.ail_ch            = (byte)(canales[(int)Mandos.AIL].getCanales()[0]);
                cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0);

                textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine;
            }
            else if (numCanales != 2)
            {
                ConErrores     = true;
                textBox1.Text += "El motor no puede tener " + numCanales + " canales" + Environment.NewLine;
            }
            else if (canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE]))    // Elevon
            {
                cfg.ail_ch      = (byte)(canales[(int)Mandos.AIL].getCanales()[0]);
                cfg.ele_ch      = (byte)(canales[(int)Mandos.AIL].getCanales()[1]);
                cfg.tipo_mezcla = (byte)Singleton.Mezclas.Elevon;

                Solucion sol = new Solucion(canales[(int)Mandos.AIL], canales[(int)Mandos.ELE]);

                cfg.rev_mezcla        = (byte)(sol.rev_mix ? 1 : 0);
                cfg.servo_ail.reverse = (byte)(sol.rev_out1 ? 1 : 0);
                cfg.servo_ele.reverse = (byte)(sol.rev_out2 ? 1 : 0);

                textBox1.Text += "Elevon:" + Environment.NewLine;
                textBox1.Text += "REV Mix" + sol.rev_mix + Environment.NewLine;
                textBox1.Text += "REV Ail" + sol.rev_out1 + Environment.NewLine;
                textBox1.Text += "REV Ele" + sol.rev_out2 + Environment.NewLine;
            }
            else    // Es flaperon
            {
                cfg.ail_ch            = (byte)(canales[(int)Mandos.AIL].getCanales()[0]);
                cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0);
                cfg.aux_ch            = (byte)(canales[(int)Mandos.AIL].getCanales()[1]);
                cfg.servo_aux.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[1]) ? 1 : 0);
                cfg.CanalAuxMode      = (byte)(Singleton.ModoCanalAux.AIL2);

                textBox1.Text += "Flaperones" + Environment.NewLine;

                textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine;
                textBox1.Text += "Rev AUX " + canales[(int)Mandos.AIL].getReverses()[1] + Environment.NewLine;
            }

            // Elevador
            numCanales = canales[(int)Mandos.ELE].getNumCanales();
            if (numCanales == 1)
            {
                cfg.ele_ch            = (byte)(canales[(int)Mandos.ELE].getCanales()[0]);
                cfg.servo_ele.reverse = (byte)((canales[(int)Mandos.ELE].getReverses()[0]) ? 1 : 0);

                textBox1.Text += "Rev ELE " + canales[(int)Mandos.ELE].getReverses()[0] + Environment.NewLine;
            }
            else if (numCanales != 2)
            {
                ConErrores     = true;
                textBox1.Text += "El elevador no puede tener " + numCanales + " canales" + Environment.NewLine;
            }
            else if (canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL]))   // Es V-Tail
            {
                cfg.ele_ch      = (byte)(canales[(int)Mandos.ELE].getCanales()[0]);
                cfg.tail_ch     = (byte)(canales[(int)Mandos.ELE].getCanales()[1]);
                cfg.tipo_mezcla = (byte)Singleton.Mezclas.V_Tail;
                Solucion sol = new Solucion(canales[(int)Mandos.ELE], canales[(int)Mandos.TAIL]);

                cfg.rev_mezcla         = (byte)(sol.rev_mix ? 1 : 0);
                cfg.servo_ele.reverse  = (byte)(sol.rev_out1 ? 1 : 0);
                cfg.servo_tail.reverse = (byte)(sol.rev_out2 ? 1 : 0);

                textBox1.Text += "Elevon:" + Environment.NewLine;
                textBox1.Text += "REV Mix" + sol.rev_mix + Environment.NewLine;
                textBox1.Text += "REV Ele" + sol.rev_out1 + Environment.NewLine;
                textBox1.Text += "REV Tail" + sol.rev_out2 + Environment.NewLine;
            }
            else if (!canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE]))   // No es Elevon
            {
                ConErrores     = true;
                textBox1.Text += "Mezcla Elevador no reconocida" + Environment.NewLine;
            }

            // Cola
            numCanales = canales[(int)Mandos.TAIL].getNumCanales();
            if (numCanales == 1)
            {
                cfg.tail_ch            = (byte)(canales[(int)Mandos.TAIL].getCanales()[0]);
                cfg.servo_tail.reverse = (byte)((canales[(int)Mandos.TAIL].getReverses()[0]) ? 1 : 0);

                textBox1.Text += "Rev TAIL " + canales[(int)Mandos.TAIL].getReverses()[0] + Environment.NewLine;
            }
            else if (numCanales != 2)
            {
                ConErrores     = true;
                textBox1.Text += "La Cola no puede tener " + numCanales + " canales" + Environment.NewLine;
            }
            else if (!canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL]))   // Si no es V-Tail
            {
                ConErrores     = true;
                textBox1.Text += "Mezcla Cola no reconocida" + Environment.NewLine;
            }

            if (!ConErrores)
            {
                textBox1.Text += "OK" + Environment.NewLine;
            }
            else
            {
                textBox1.Text += "Errores!" + Environment.NewLine;
            }
        }
예제 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            FlightPlanUSB fp = new FlightPlanUSB();

            if (fp.IsOpen())
            {
                IkarusBasicConfig basiccfg = new IkarusBasicConfig();
                basiccfg.LoadDefaults();

                basiccfg.LoadFromXmlString(global::UAVConsole.Properties.Resources.osd_config);

                basiccfg.videoPAL    = (byte)(1 - comboBoxVideoSystem.SelectedIndex);
                basiccfg.BaudRate    = (byte)comboBoxGPSBaudRate.SelectedIndex;
                basiccfg.Modo_PPM    = (byte)comboBoxModoPPM.SelectedIndex;
                basiccfg.PPM_Channel = (byte)(comboBoxCanalPPM.SelectedIndex + 4);

                TimeSpan rafa = TimeZone.CurrentTimeZone.GetUtcOffset(new DateTime());
                basiccfg.TimeZone = (sbyte)rafa.Hours;

                fp.WriteConfig(basiccfg);

                IkarusAutopilotConfig autocfg = new IkarusAutopilotConfig();
                autocfg.LoadDefaults();

                autocfg.LoadFromXmlString(global::UAVConsole.Properties.Resources.autopilot_config);

                autocfg.tipo_mezcla = (byte)comboBoxTipoMezcla.SelectedIndex;
                fp.WriteConfigAutopilot(autocfg);


                if (checkBoxActualizarHUDs.Checked)
                {
                    IkarusScreenConfig scr = new IkarusScreenConfig();
                    scr.LoadFromXmlString(global::UAVConsole.Properties.Resources.HUD1);
                    fp.WriteScreen(0, scr);     // HUD 0
                    scr.LoadFromXmlString(global::UAVConsole.Properties.Resources.HUD2);
                    fp.WriteScreen(1, scr);     // HUD 1
                    scr.LoadFromXmlString(global::UAVConsole.Properties.Resources.HUD3);
                    fp.WriteScreen(2, scr);     // HUD 2
                    scr.LoadFromXmlString(global::UAVConsole.Properties.Resources.Failsafe);
                    fp.WriteScreen(3, scr);     // FailSafe
                    scr.LoadFromXmlString(global::UAVConsole.Properties.Resources.Resumen);
                    fp.WriteScreen(4, scr);     // Resumen
                }

                if (checkBoxActualizarCharSet.Checked)
                {
                    MemoryStream stream = new MemoryStream(global::UAVConsole.Properties.Resources.Ikarus);
                    FileCharset  fc     = new FileCharset(new StreamReader(stream));
                    byte[]       buff;

                    for (int i = 0; i < 256; i++)
                    {
                        buff = fc.getChar((byte)i);
                        fp.WriteCharSet(i, buff);
                    }
                }

                fp.Close();

                if (me.Idioma == 0)
                {
                    MessageBox.Show("Realizado!");
                }
                else
                {
                    MessageBox.Show("Done!");
                }
                this.Close();
            }
            else
            if (me.Idioma == 0)
            {
                MessageBox.Show("No esta conectado!");
            }
            else
            {
                MessageBox.Show("Not connected!");
            }
        }
예제 #10
0
        private void button7_Click(object sender, EventArgs e)
        {
            FlightPlanUSB         planUSB          = new FlightPlanUSB();
            IkarusAutopilotConfig config_autopilot = planUSB.ReadConfigAutopilot();


            //config.PPM_Channel = comboBoxCtrlCH.SelectedIndex + 4;

            config_autopilot.ail_ch  = (byte)(comboAilCH.SelectedIndex - 1);
            config_autopilot.ele_ch  = (byte)(comboEleCH.SelectedIndex - 1);
            config_autopilot.thr_ch  = (byte)(comboThrCH.SelectedIndex - 1);
            config_autopilot.tail_ch = (byte)(comboTailCH.SelectedIndex - 1);
            config_autopilot.pan_ch  = (byte)(comboPanCH.SelectedIndex - 1);

            // SERVO CTRL
            //config_autopilot.servo_ctrl.min = (Int16)numericUpDownServoCTRLmin.Value;
            //config_autopilot.servo_ctrl.center = (Int16)numericUpDownServoCTRLcenter.Value;
            //config_autopilot.servo_ctrl.max = (Int16)numericUpDownServoCTRLmax.Value;
            //config_autopilot.servo_ctrl.reverse = checkBoxServoCTRLrev.Checked ? (byte)1 : (byte)0;

            // SERVO AIL
            config_autopilot.servo_ail.min     = (Int16)numericUpDownServoAILmin.Value;
            config_autopilot.servo_ail.center  = (Int16)numericUpDownServoAILcenter.Value;
            config_autopilot.servo_ail.max     = (Int16)numericUpDownServoAILmax.Value;
            config_autopilot.servo_ail.reverse = checkBoxServoAILrev.Checked ? (byte)1 : (byte)0;

            // SERVO ELE
            config_autopilot.servo_ele.min     = (Int16)numericUpDownServoELEmin.Value;
            config_autopilot.servo_ele.center  = (Int16)numericUpDownServoELEcenter.Value;
            config_autopilot.servo_ele.max     = (Int16)numericUpDownServoELEmax.Value;
            config_autopilot.servo_ele.reverse = checkBoxServoELErev.Checked ? (byte)1 : (byte)0;

            // SERVO THR
            config_autopilot.servo_thr.min     = (Int16)numericUpDownServoTHRmin.Value;
            config_autopilot.servo_thr.center  = (Int16)numericUpDownServoTHRcenter.Value;
            config_autopilot.servo_thr.max     = (Int16)numericUpDownServoTHRmax.Value;
            config_autopilot.servo_thr.reverse = checkBoxServoTHRrev.Checked ? (byte)1 : (byte)0;

            // SERVO TAIL
            config_autopilot.servo_tail.min     = (Int16)numericUpDownServoTAILmin.Value;
            config_autopilot.servo_tail.center  = (Int16)numericUpDownServoTAILcenter.Value;
            config_autopilot.servo_tail.max     = (Int16)numericUpDownServoTAILmax.Value;
            config_autopilot.servo_tail.reverse = checkBoxServoTAILrev.Checked ? (byte)1 : (byte)0;

            // SERVO PAN
            config_autopilot.servo_pan.min     = (Int16)numericUpDownServoPANmin.Value;
            config_autopilot.servo_pan.center  = (Int16)numericUpDownServoPANcenter.Value;
            config_autopilot.servo_pan.max     = (Int16)numericUpDownServoPANmax.Value;
            config_autopilot.servo_pan.reverse = checkBoxServoPANrev.Checked ? (byte)1 : (byte)0;

            config_autopilot.rev_mezcla = checkBoxMix1.Checked ? (byte)1 : (byte)0;

            switch (comboBoxTipoMezcla.SelectedIndex)
            {
            case (int)Singleton.Mezclas.Normal:
                if (comboTiltCH.SelectedIndex > 0)
                {
                    config_autopilot.tipo_mezcla       = (byte)Singleton.Mezclas.Normal;
                    config_autopilot.aux_ch            = (byte)(comboTiltCH.SelectedIndex - 1);
                    config_autopilot.servo_aux.min     = (Int16)numericUpDownServoTILTmin.Value;
                    config_autopilot.servo_aux.center  = (Int16)numericUpDownServoTILTcenter.Value;
                    config_autopilot.servo_aux.max     = (Int16)numericUpDownServoTILTmax.Value;
                    config_autopilot.servo_aux.reverse = checkBoxServoTILTrev.Checked ? (byte)1 : (byte)0;
                }
                else
                {
                }
                break;

            case (int)Singleton.Mezclas.Elevon:
                if (comboTiltCH.SelectedIndex > 0)
                {
                    config_autopilot.tipo_mezcla       = (byte)Singleton.Mezclas.Elevon;
                    config_autopilot.aux_ch            = (byte)(comboTiltCH.SelectedIndex - 1);
                    config_autopilot.servo_aux.min     = (Int16)numericUpDownServoTILTmin.Value;
                    config_autopilot.servo_aux.center  = (Int16)numericUpDownServoTILTcenter.Value;
                    config_autopilot.servo_aux.max     = (Int16)numericUpDownServoTILTmax.Value;
                    config_autopilot.servo_aux.reverse = checkBoxServoTILTrev.Checked ? (byte)1 : (byte)0;
                }
                else
                {
                }
                break;

            case (int)Singleton.Mezclas.V_Tail:
                if (comboTiltCH.SelectedIndex > 0)
                {
                    config_autopilot.tipo_mezcla = (byte)Singleton.Mezclas.V_Tail;

                    config_autopilot.aux_ch            = (byte)(comboTiltCH.SelectedIndex - 1);
                    config_autopilot.servo_aux.min     = (Int16)numericUpDownServoTILTmin.Value;
                    config_autopilot.servo_aux.center  = (Int16)numericUpDownServoTILTcenter.Value;
                    config_autopilot.servo_aux.max     = (Int16)numericUpDownServoTILTmax.Value;
                    config_autopilot.servo_aux.reverse = checkBoxServoTILTrev.Checked ? (byte)1 : (byte)0;
                }
                else
                {
                }
                break;

            case (int)Singleton.Mezclas.Flaperon:
                config_autopilot.tipo_mezcla  = (byte)Singleton.Mezclas.Normal;
                config_autopilot.CanalAuxMode = (byte)Singleton.ModoCanalAux.AIL2;

                config_autopilot.aux_ch            = (byte)(comboAil2CH.SelectedIndex - 1);
                config_autopilot.servo_aux.min     = (Int16)numericUpDownServoAIL2min.Value;
                config_autopilot.servo_aux.center  = (Int16)numericUpDownServoAIL2center.Value;
                config_autopilot.servo_aux.max     = (Int16)numericUpDownServoAIL2max.Value;
                config_autopilot.servo_aux.reverse = checkBoxServoAIL2rev.Checked ? (byte)1 : (byte)0;


                break;

            case (int)Singleton.Mezclas.Flaperon_Vtail:
                config_autopilot.tipo_mezcla  = (byte)Singleton.Mezclas.V_Tail;
                config_autopilot.CanalAuxMode = (byte)Singleton.ModoCanalAux.AIL2;

                config_autopilot.aux_ch            = (byte)(comboAil2CH.SelectedIndex - 1);
                config_autopilot.servo_aux.min     = (Int16)numericUpDownServoAIL2min.Value;
                config_autopilot.servo_aux.center  = (Int16)numericUpDownServoAIL2center.Value;
                config_autopilot.servo_aux.max     = (Int16)numericUpDownServoAIL2max.Value;
                config_autopilot.servo_aux.reverse = checkBoxServoAIL2rev.Checked ? (byte)1 : (byte)0;

                break;
            }

            /*
             *         switch (config_autopilot.tipo_mezcla)
             *         {
             *             case (byte)Singleton.Mezclas.Elevon:
             *                 checkBoxMix1.Checked = config_autopilot.pidRoll.rev != 0;
             *                 checkBoxMix2.Checked = config_autopilot.pidPitch.rev != 0;
             *                 break;
             *             case (byte)Singleton.Mezclas.V_Tail:
             *                 checkBoxMix1.Checked = config_autopilot.pidPitch.rev != 0;
             *                 checkBoxMix2.Checked = config_autopilot.pidTail.rev != 0;
             *                 break;
             *         }
             * */
            planUSB.WriteConfigAutopilot(config_autopilot);
            planUSB.Close();
        }
예제 #11
0
        private void button5_Click(object sender, EventArgs e)
        {
            FlightPlanUSB         planUSB          = new FlightPlanUSB();
            IkarusAutopilotConfig config_autopilot = planUSB.ReadConfigAutopilot();
            IkarusBasicConfig     config           = planUSB.ReadConfig();

            planUSB.Close();
            try
            {
                comboBoxCtrlCH.SelectedIndex = (byte)(config.PPM_Channel + 1);

                comboAilCH.SelectedIndex  = (byte)(config_autopilot.ail_ch + 1);
                comboEleCH.SelectedIndex  = (byte)(config_autopilot.ele_ch + 1);
                comboThrCH.SelectedIndex  = (byte)(config_autopilot.thr_ch + 1);
                comboTailCH.SelectedIndex = (byte)(config_autopilot.tail_ch + 1);
                comboPanCH.SelectedIndex  = (byte)(config_autopilot.pan_ch + 1);

                // SERVO CTRL
                numericUpDownServoCTRLmin.Value    = (decimal)config_autopilot.servo_ctrl.min;
                numericUpDownServoCTRLcenter.Value = (decimal)config_autopilot.servo_ctrl.center;
                numericUpDownServoCTRLmax.Value    = (decimal)config_autopilot.servo_ctrl.max;
                checkBoxServoCTRLrev.Checked       = config_autopilot.servo_ctrl.reverse != 0;

                // SERVO AIL
                numericUpDownServoAILmin.Value    = (decimal)config_autopilot.servo_ail.min;
                numericUpDownServoAILcenter.Value = (decimal)config_autopilot.servo_ail.center;
                numericUpDownServoAILmax.Value    = (decimal)config_autopilot.servo_ail.max;
                checkBoxServoAILrev.Checked       = config_autopilot.servo_ail.reverse != 0;

                // SERVO ELE
                numericUpDownServoELEmin.Value    = (decimal)config_autopilot.servo_ele.min;
                numericUpDownServoELEcenter.Value = (decimal)config_autopilot.servo_ele.center;
                numericUpDownServoELEmax.Value    = (decimal)config_autopilot.servo_ele.max;
                checkBoxServoELErev.Checked       = config_autopilot.servo_ele.reverse != 0;

                // SERVO THR
                numericUpDownServoTHRmin.Value    = (decimal)config_autopilot.servo_thr.min;
                numericUpDownServoTHRcenter.Value = (decimal)config_autopilot.servo_thr.center;
                numericUpDownServoTHRmax.Value    = (decimal)config_autopilot.servo_thr.max;
                checkBoxServoTHRrev.Checked       = config_autopilot.servo_thr.reverse != 0;

                // SERVO TAIL
                numericUpDownServoTAILmin.Value    = (decimal)config_autopilot.servo_tail.min;
                numericUpDownServoTAILcenter.Value = (decimal)config_autopilot.servo_tail.center;
                numericUpDownServoTAILmax.Value    = (decimal)config_autopilot.servo_tail.max;
                checkBoxServoTAILrev.Checked       = config_autopilot.servo_tail.reverse != 0;

                // SERVO PAN
                numericUpDownServoPANmin.Value    = (decimal)config_autopilot.servo_pan.min;
                numericUpDownServoPANcenter.Value = (decimal)config_autopilot.servo_pan.center;
                numericUpDownServoPANmax.Value    = (decimal)config_autopilot.servo_pan.max;
                checkBoxServoPANrev.Checked       = config_autopilot.servo_pan.reverse != 0;


                // Mezclas...

                checkBoxMix1.Checked = (config_autopilot.rev_mezcla != 0);



                switch (config_autopilot.tipo_mezcla)
                {
                case (byte)Singleton.Mezclas.Normal:
                    if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.AIL2)
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Flaperon;

                        comboAil2CH.SelectedIndex          = (byte)(config_autopilot.aux_ch + 1);
                        numericUpDownServoAIL2min.Value    = (decimal)config_autopilot.servo_aux.min;
                        numericUpDownServoAIL2center.Value = (decimal)config_autopilot.servo_aux.center;
                        numericUpDownServoAIL2max.Value    = (decimal)config_autopilot.servo_aux.max;
                        checkBoxServoAIL2rev.Checked       = config_autopilot.servo_aux.reverse != 0;
                    }
                    else if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.TILT)
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Normal;

                        comboTiltCH.SelectedIndex          = (byte)(config_autopilot.aux_ch + 1);
                        numericUpDownServoTILTmin.Value    = (decimal)config_autopilot.servo_aux.min;
                        numericUpDownServoTILTcenter.Value = (decimal)config_autopilot.servo_aux.center;
                        numericUpDownServoTILTmax.Value    = (decimal)config_autopilot.servo_aux.max;
                        checkBoxServoTILTrev.Checked       = config_autopilot.servo_aux.reverse != 0;
                    }
                    else
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Normal;
                    }
                    break;

                case (byte)Singleton.Mezclas.Elevon:

                    if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.AIL2)
                    {
                        MessageBox.Show("Elevon & Flaperon???");
                        //comboAil2CH.SelectedIndex = (byte)(config_autopilot.aux_ch + 1);
                    }
                    else if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.TILT)
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Elevon;

                        comboTiltCH.SelectedIndex          = (byte)(config_autopilot.aux_ch + 1);
                        numericUpDownServoTILTmin.Value    = (decimal)config_autopilot.servo_aux.min;
                        numericUpDownServoTILTcenter.Value = (decimal)config_autopilot.servo_aux.center;
                        numericUpDownServoTILTmax.Value    = (decimal)config_autopilot.servo_aux.max;
                        checkBoxServoTILTrev.Checked       = config_autopilot.servo_aux.reverse != 0;
                    }
                    else
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Elevon;
                    }
                    break;

                case (byte)Singleton.Mezclas.V_Tail:

                    if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.AIL2)
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.Flaperon_Vtail;

                        comboAil2CH.SelectedIndex          = (byte)(config_autopilot.aux_ch + 1);
                        numericUpDownServoAIL2min.Value    = (decimal)config_autopilot.servo_aux.min;
                        numericUpDownServoAIL2center.Value = (decimal)config_autopilot.servo_aux.center;
                        numericUpDownServoAIL2max.Value    = (decimal)config_autopilot.servo_aux.max;
                        checkBoxServoAIL2rev.Checked       = config_autopilot.servo_aux.reverse != 0;
                    }
                    else if (config_autopilot.CanalAuxMode == (int)Singleton.ModoCanalAux.TILT)
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.V_Tail;

                        comboTiltCH.SelectedIndex          = (byte)(config_autopilot.aux_ch + 1);
                        numericUpDownServoTILTmin.Value    = (decimal)config_autopilot.servo_aux.min;
                        numericUpDownServoTILTcenter.Value = (decimal)config_autopilot.servo_aux.center;
                        numericUpDownServoTILTmax.Value    = (decimal)config_autopilot.servo_aux.max;
                        checkBoxServoTILTrev.Checked       = config_autopilot.servo_aux.reverse != 0;
                    }
                    else
                    {
                        comboBoxTipoMezcla.SelectedIndex = (int)Singleton.Mezclas.V_Tail;
                    }

                    break;
                }
            }
            catch (Exception) { }

            // Valores de los PID a memorizar....
            try
            {
                me.uplink_pid_ail_P  = config_autopilot.pidRoll.P;
                me.uplink_pid_ail_I  = config_autopilot.pidRoll.I;
                me.uplink_pid_ail_D  = config_autopilot.pidRoll.D;
                me.uplink_pid_ail_IL = config_autopilot.pidRoll.ILim;
                me.uplink_pid_ail_DL = config_autopilot.pidRoll.DriveLim;

                me.uplink_pid_ele_P  = config_autopilot.pidPitch.P;
                me.uplink_pid_ele_I  = config_autopilot.pidPitch.I;
                me.uplink_pid_ele_D  = config_autopilot.pidPitch.D;
                me.uplink_pid_ele_IL = config_autopilot.pidPitch.ILim;
                me.uplink_pid_ele_DL = config_autopilot.pidPitch.DriveLim;

                me.uplink_pid_thr_P  = config_autopilot.pidMotor.P;
                me.uplink_pid_thr_I  = config_autopilot.pidMotor.I;
                me.uplink_pid_thr_D  = config_autopilot.pidMotor.D;
                me.uplink_pid_thr_IL = config_autopilot.pidMotor.ILim;
                me.uplink_pid_thr_DL = config_autopilot.pidMotor.DriveLim;

                me.uplink_pid_tail_P  = config_autopilot.pidTail.P;
                me.uplink_pid_tail_I  = config_autopilot.pidTail.I;
                me.uplink_pid_tail_D  = config_autopilot.pidTail.D;
                me.uplink_pid_tail_IL = config_autopilot.pidTail.ILim;
                me.uplink_pid_tail_DL = config_autopilot.pidTail.DriveLim;

                me.uplink_IR_offX    = config_autopilot.x_off;
                me.uplink_IR_offY    = config_autopilot.y_off;
                me.uplink_IR_gain    = config_autopilot.IR_max;
                me.uplink_rumbo_ail  = config_autopilot.Rumbo_Ail;
                me.uplink_altura_ele = config_autopilot.Altitud_Ele;

                me.uplink_IR_rev_P     = config_autopilot.IR_pitch_rev != 0;
                me.uplink_IR_rev_R     = config_autopilot.IR_roll_rev != 0;
                me.uplink_IR_cross     = config_autopilot.IR_cross_sensor != 0;
                me.uplink_IR_rev_cross = config_autopilot.IR_cross_rev != 0;
            }
            catch (Exception) { }
        }