Пример #1
0
 public IkarusCompleteConfig()
 {
     this.IkarusAutopilotConfig      = new IkarusAutopilotConfig();
     this.IkarusBasicConfig          = new IkarusBasicConfig();
     this.IkarusScreenConfig1        = new IkarusScreenConfig();
     this.IkarusScreenConfig2        = new IkarusScreenConfig();
     this.IkarusScreenConfig3        = new IkarusScreenConfig();
     this.IkarusScreenConfigFailSafe = new IkarusScreenConfig();
     this.IkarusScreenConfigResumen  = new IkarusScreenConfig();
     size_bytes();
 }
Пример #2
0
 public IkarusCompleteConfig()
 {
     this.IkarusAutopilotConfig = new IkarusAutopilotConfig();
     this.IkarusBasicConfig = new IkarusBasicConfig();
     this.IkarusScreenConfig1 = new IkarusScreenConfig();
     this.IkarusScreenConfig2 = new IkarusScreenConfig();
     this.IkarusScreenConfig3 = new IkarusScreenConfig();
     this.IkarusScreenConfigFailSafe = new IkarusScreenConfig();
     this.IkarusScreenConfigResumen = new IkarusScreenConfig();
     size_bytes();
 }
Пример #3
0
 public void WriteConfigAutopilot(IkarusAutopilotConfig cfg)
 {
     byte[] buffer = cfg.ToByteArray();
     Write(Comandos.AutoPilotConfig, 0, 0, buffer);
     Flush();
 }
Пример #4
0
        public IkarusAutopilotConfig ReadConfigAutopilot()
        {
            IkarusAutopilotConfig cfg = new IkarusAutopilotConfig();
          
            byte[] buffer = Read(Comandos.AutoPilotConfig, 0, 0, cfg.size_bytes());
            cfg.FromByteArray(buffer);

            return cfg;
        }
Пример #5
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;
            }
        }
Пример #6
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!");
        }
        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;
            }

        }