Beispiel #1
0
        public IkarusBasicConfig ReadConfig()
        {
            IkarusBasicConfig cfg = new IkarusBasicConfig();

            byte[] buffer = Read(Comandos.IkarusConfig, 0, 0, cfg.size_bytes());
            cfg.FromByteArray(buffer);
            return(cfg);
        }
Beispiel #2
0
        public void WriteConfig(IkarusBasicConfig cfg)
        {
            byte[] buffer = cfg.ToByteArray();

            Write(Comandos.IkarusConfig, 0, 0, buffer);
            Flush();
            RemoteIkarus(1, 0);
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            lock (this)
            {
                if (planUSB.IsOpen())
                {
                    //timer1.Enabled = false;
                    if (firstTime)
                    {
                        firstTime = false;
                        sconfig   = planUSB.ReadConfig();
                        planUSB.Close();


                        panel1.Enabled = true;

                        UpdateControles();
                    }
                    else
                    {
                        planUSB.Close();
                    }
                    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;
                }
            }
        }
Beispiel #4
0
        private void button5_Click(object sender, EventArgs e)
        {
            FlightPlanUSB ikarus = new FlightPlanUSB();

            if (ikarus.IsOpen())
            {
                float v1, v2;
                if (float.TryParse(textBoxMotorI1.Text, out v1) && float.TryParse(textBoxMotorI2.Text, out v2))
                {
                    float gain = (float)(numericUpDownMotorI1.Value - numericUpDownMotorI2.Value) / (v1 - v2);
                    //float offset = -(float)numericUpDownMotorI1.Value - gain * float.Parse(textBoxMotorI1.Text);
                    float             offset = float.Parse(textBoxMotorI1.Text) - (float)numericUpDownMotorI1.Value / gain;
                    IkarusBasicConfig cfg    = ikarus.ReadConfig();
                    cfg.sensorI_gain   = gain;
                    cfg.sensorI_offset = offset;
                    ikarus.WriteConfig(cfg);
                    if (me.Idioma == 0)
                    {
                        MessageBox.Show("Valores guardados correctamente");
                    }
                    else
                    {
                        MessageBox.Show("Values saved sucesfully");
                    }
                }
                else if (me.Idioma == 0)
                {
                    MessageBox.Show("Error en los valores capturados");
                }
                else
                {
                    MessageBox.Show("Error in captured values");
                }
                ikarus.Close();
            }
            else if (me.Idioma == 0)
            {
                MessageBox.Show("Error abriendo disp USB");
            }
            else
            {
                MessageBox.Show("Error opening USB device!");
            }
            ikarus.Close();
        }
Beispiel #5
0
        private void button12_Click(object sender, EventArgs e)
        {
            FlightPlanUSB planUSB = new FlightPlanUSB();

            if (planUSB.IsOpen())
            {
                WayPoint wpt = planUSB.ReadGPS();
                if (wpt != null)
                {
                    Singleton.GetInstance().HomeLat = (float)wpt.Latitude;
                    Singleton.GetInstance().HomeLon = (float)wpt.Longitude;
                    Singleton.GetInstance().HomeAlt = (float)wpt.Altitude;

                    mapControl1.home.Latitude  = wpt.Latitude;
                    mapControl1.home.Longitude = wpt.Longitude;
                    mapControl1.Invalidate();
                }
                else
                {
                    IkarusBasicConfig cfg = planUSB.ReadConfig();

                    Singleton.GetInstance().HomeLat = (float)cfg.HomeLat;
                    Singleton.GetInstance().HomeLon = (float)cfg.HomeLon;
                    Singleton.GetInstance().HomeAlt = (float)cfg.HomeAltitude;

                    mapControl1.home.Latitude  = cfg.HomeLat;
                    mapControl1.home.Longitude = cfg.HomeLon;
                    mapControl1.Invalidate();
                }
                planUSB.Close();
            }
            else if (me.Idioma == 0)
            {
                MessageBox.Show("No se puede conectar!");
            }
            else
            {
                MessageBox.Show("Cannot connect!");
            }
        }
Beispiel #6
0
        private void buttonFIN_Click(object sender, EventArgs e)
        {
            FlightPlanUSB ikarus = new FlightPlanUSB();

            if (ikarus.IsOpen())
            {
                IkarusBasicConfig cfg = ikarus.ReadConfig();
                cfg.rssi_min = (float)numericUpDownRSSImin.Value;
                cfg.rssi_max = (float)numericUpDownRSSImax.Value;
                ikarus.WriteConfig(cfg);

                ikarus.Close();
            }
            else if (me.Idioma == 0)
            {
                MessageBox.Show("Error abriendo disp USB");
            }
            else
            {
                MessageBox.Show("Error opening USB device!");
            }
            this.Close();
        }
        private void button6_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            if (planUSB.IsOpen())
            {
                sconfig = planUSB.ReadConfig();
                UpdateControles();
            }
            else
            {
                if (me.Idioma == (int)Singleton.Idiomas.Spanish)
                {
                    MessageBox.Show("No puedo conectar con Ikarus OSD");
                }
                else
                {
                    MessageBox.Show("Cannot connect with Ikarus OSD");
                }
            }

            timer1.Enabled = true;
        }
        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!");
            }
        }
Beispiel #9
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) { }
        }