예제 #1
0
        static void TimerTask(Object obj)
        {
            AntTracker ant = (AntTracker)obj;

            if (ant.flag == 0)
            {
                ant.flag = 1;
                ant.tarea(ant);
                if (ant.terminate)
                {
                    ant.timer.Dispose();
                    ant.antenaTracker.Close();
                }
                ant.flag = 0;
            }
        }
예제 #2
0
        void tarea(AntTracker obj)
        {
            if (antenaTracker.IsOpen())
            {
                if (singleton.telemetria == Singleton.Telemetria.AntTracker)
                {
                    obj.packet = antenaTracker.ReadModem();
                }
                else if (obj.planeStateUpdated == true && CheckPlaneState(obj.planeState))
                {
                    datosAvion.lon = obj.planeState.Lon;
                    datosAvion.lat = obj.planeState.Lat;
                    datosAvion.alt = (short)obj.planeState.Alt;

                    datosAvion.home_lon = (float)obj.home.Longitude;
                    datosAvion.home_lat = (float)obj.home.Latitude;
                    datosAvion.home_alt = (short)obj.home.Altitude;
                    if (antenaTracker.WriteDatosAvion(datosAvion) != USBXpress.USBXpress.ReturnCodes.SI_SUCCESS)
                    {
                        antenaTracker.Close();
                    }
                    else
                    {
                        datosAntena = antenaTracker.ReadDatosAntena();
                    }
                }

                if (debugUpdated)
                {
                    antenaTracker.WriteDebugInfo(debug);
                    debugUpdated = false;
                }
            }
            else
            {
                antenaTracker = new AntenaTracker();
            }
        }
예제 #3
0
        public FormIkarusMain()
        {

            InitializeComponent();


            if (me.SistemaMetrico == (int)Singleton.SistemasMetricos.Metrico)
                instrumento_Altimeter1.Calibration = me.HomeAlt;
            else
                instrumento_Altimeter1.Calibration = me.HomeAlt * 3.28f;

            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
        
            debug_values = new float[5, 5]{{me.uplink_pid_ele_P, me.uplink_pid_ele_I, me.uplink_pid_ele_D, me.uplink_pid_ele_IL, me.uplink_pid_ele_DL},
                {me.uplink_pid_ail_P , me.uplink_pid_ail_I, me.uplink_pid_ail_D, me.uplink_pid_ail_IL, me.uplink_pid_ail_DL},
                {me.uplink_pid_tail_P, me.uplink_pid_tail_I, me.uplink_pid_tail_D, me.uplink_pid_tail_IL, me.uplink_pid_tail_DL},
                {me.uplink_pid_thr_P, me.uplink_pid_thr_I, me.uplink_pid_thr_D, me.uplink_pid_thr_IL, me.uplink_pid_thr_DL },
                {me.uplink_IR_offX, me.uplink_IR_offY, me.uplink_IR_gain, me.uplink_rumbo_ail, me.uplink_altura_ele}};

            comboBox3.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
           
            comboBox1.SelectedIndex = 0;
            this.planeWpt = new WayPoint("Avion", me.HomeLon, me.HomeLat, global::UAVConsole.Properties.Resources.plane3);
            this.planeWpt.icon.MakeTransparent(Color.White);
            this.planeWpt.heading = 0;
            this.targetWpt = new WayPoint("Avion", me.HomeLon, me.HomeLat);
            this.homeWpt = new WayPoint("Home", me.HomeLon, me.HomeLat);

            mapControl1.plane = this.planeWpt;
            mapControl1.target = this.targetWpt;
            mapControl1.ruta = me.Ruta;

            medidorBaterias1.num_cells = me.cells1;
            medidorBaterias2.num_cells = me.cells2;


            try
            {
                filters = new Filters();
            }
            catch (Exception)
            {
            }

            if (filters != null && filters.VideoInputDevices.Count > 0)
            {
                foreach (Filter f in filters.VideoInputDevices)
                {
                    if (f.Name.Equals(me.videoCaptureStr))
                    {
                        capture = new Capture(f, null, false);
                        break;
                    }
                }

                if (capture != null)
                {
                    foreach (Source vs in capture.VideoSources)
                    {
                        if (vs.ToString().Contains("omposi")) // Video Composite
                        {
                            capture.VideoSource = vs;
                            break;
                        }
                    }
                   
                    if (me.videosystem == Singleton.VideoSystem.PAL)
                    {
                        capture.dxUtils.VideoStandard = DShowNET.AnalogVideoStandard.PAL_B;
                        try
                        {
                            capture.FrameRate = 25; 
                            capture.FrameSize = new Size(720, 576);
                            capture.PreviewFrameSize = new Size(720, 576);

                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        capture.dxUtils.VideoStandard = DShowNET.AnalogVideoStandard.NTSC_M;
                        try
                        {
                            capture.FrameRate = 30;
                            capture.FrameSize = new Size(720, 480);
                        }
                        catch (Exception) { }
                    }
                    capture.AllowSampleGrabber = true;
                    capture.PreviewWindow = panel1;
                    capture.FrameEvent2 += new Capture.HeFrame(CaptureDone);
                    capture.GrapImg();
                    //capture.ShowPropertyPage(1, this);
                }
            }

            if (me.enableAntTrack)
            {
                antTracker = new AntTracker();
                medidorBaterias3.Enabled = true;
                medidorBaterias3.AutoCalculate = false;
                label6.Enabled = true;
                knob_anttracker.Visible = true;
                knob_anttracker.Manual = false;
                medidorRSSI.Height = 97;
            }
            else
            {
                knob_anttracker.Visible = false;
                medidorRSSI.Height = 137;
            }

            if (me.telemetria == Singleton.Telemetria.Video)
            {
                modem = new ModemVideo();
            }
            else if (me.telemetria == Singleton.Telemetria.XBEE)
                modem = new ModemXbee(me.commPort, me.commBps);
            else if (me.telemetria == Singleton.Telemetria.AntTracker)
                modem = new ModemAntTracker(antTracker);

            if (me.telemetria != Singleton.Telemetria.None)
                modem.listeners += RefreshInstruments;

            if (me.moduloTX == Singleton.ModuloControl.Uplink)
            {
                if (jthread == null)
                    jthread = new JoystickThread(this);

                decimal altura = (decimal)(me.HomeAlt + 100);

                if (altura < numericUpDown1.Minimum)
                    altura = numericUpDown1.Minimum;
                else if (altura > numericUpDown1.Maximum)
                    altura = numericUpDown1.Maximum;

                numericUpDown1.Value = altura;

                label7.Enabled = true;
                medidorBaterias4.Enabled = true;
                medidorBaterias4.volts_max = me.uplinkVmax;
                medidorBaterias4.volts_min = me.uplinkVmin;
            }
            else
            {
                splitContainer1.SplitterDistance+=panel4.Height;
                panel5.Location = panel4.Location;
                panel6.Location = new Point(panel6.Location.X, panel5.Location.Y);
                panel4.Visible = false;
                
            }

            if (me.enableUDPinout)
            {
                if (this.sender == null)
                    this.sender = new SenderUDP(me.portUDPinout);
                this.sender.listeners += TeamRefresh;
            }
            else
            {
                comboBoxTeam.Visible = false;
                button6.Visible = false;
                button7.Visible = false;
                //panel8.Width -= 56;
            }

            if (me.enableWebServer)
            {
                this.KmlWebServer = new MyWebServer(me.portWebServer);
            }

            timer1.Enabled = true;
        }
예제 #4
0
        public FormIkarusMain()
        {
            InitializeComponent();


            if (me.SistemaMetrico == (int)Singleton.SistemasMetricos.Metrico)
            {
                instrumento_Altimeter1.Calibration = me.HomeAlt;
            }
            else
            {
                instrumento_Altimeter1.Calibration = me.HomeAlt * 3.28f;
            }

            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            debug_values = new float[5, 5] {
                { me.uplink_pid_ele_P, me.uplink_pid_ele_I, me.uplink_pid_ele_D, me.uplink_pid_ele_IL, me.uplink_pid_ele_DL },
                { me.uplink_pid_ail_P, me.uplink_pid_ail_I, me.uplink_pid_ail_D, me.uplink_pid_ail_IL, me.uplink_pid_ail_DL },
                { me.uplink_pid_tail_P, me.uplink_pid_tail_I, me.uplink_pid_tail_D, me.uplink_pid_tail_IL, me.uplink_pid_tail_DL },
                { me.uplink_pid_thr_P, me.uplink_pid_thr_I, me.uplink_pid_thr_D, me.uplink_pid_thr_IL, me.uplink_pid_thr_DL },
                { me.uplink_IR_offX, me.uplink_IR_offY, me.uplink_IR_gain, me.uplink_rumbo_ail, me.uplink_altura_ele }
            };

            comboBox3.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;

            comboBox1.SelectedIndex = 0;
            this.planeWpt           = new WayPoint("Avion", me.HomeLon, me.HomeLat, global::UAVConsole.Properties.Resources.plane3);
            this.planeWpt.icon.MakeTransparent(Color.White);
            this.planeWpt.heading = 0;
            this.targetWpt        = new WayPoint("Avion", me.HomeLon, me.HomeLat);
            this.homeWpt          = new WayPoint("Home", me.HomeLon, me.HomeLat);

            mapControl1.plane  = this.planeWpt;
            mapControl1.target = this.targetWpt;
            mapControl1.ruta   = me.Ruta;

            medidorBaterias1.num_cells = me.cells1;
            medidorBaterias2.num_cells = me.cells2;


            try
            {
                filters = new Filters();
            }
            catch (Exception)
            {
            }

            if (filters != null && filters.VideoInputDevices.Count > 0)
            {
                foreach (Filter f in filters.VideoInputDevices)
                {
                    if (f.Name.Equals(me.videoCaptureStr))
                    {
                        capture = new Capture(f, null, false);
                        break;
                    }
                }

                if (capture != null)
                {
                    foreach (Source vs in capture.VideoSources)
                    {
                        if (vs.ToString().Contains("omposi")) // Video Composite
                        {
                            capture.VideoSource = vs;
                            break;
                        }
                    }

                    if (me.videosystem == Singleton.VideoSystem.PAL)
                    {
                        capture.dxUtils.VideoStandard = DShowNET.AnalogVideoStandard.PAL_B;
                        try
                        {
                            capture.FrameRate        = 25;
                            capture.FrameSize        = new Size(720, 576);
                            capture.PreviewFrameSize = new Size(720, 576);
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        capture.dxUtils.VideoStandard = DShowNET.AnalogVideoStandard.NTSC_M;
                        try
                        {
                            capture.FrameRate = 30;
                            capture.FrameSize = new Size(720, 480);
                        }
                        catch (Exception) { }
                    }
                    capture.AllowSampleGrabber = true;
                    capture.PreviewWindow      = panel1;
                    capture.FrameEvent2       += new Capture.HeFrame(CaptureDone);
                    capture.GrapImg();
                    //capture.ShowPropertyPage(1, this);
                }
            }

            if (me.enableAntTrack)
            {
                antTracker = new AntTracker();
                medidorBaterias3.Enabled       = true;
                medidorBaterias3.AutoCalculate = false;
                label6.Enabled          = true;
                knob_anttracker.Visible = true;
                knob_anttracker.Manual  = false;
                medidorRSSI.Height      = 97;
            }
            else
            {
                knob_anttracker.Visible = false;
                medidorRSSI.Height      = 137;
            }

            if (me.telemetria == Singleton.Telemetria.Video)
            {
                modem = new ModemVideo();
            }
            else if (me.telemetria == Singleton.Telemetria.XBEE)
            {
                modem = new ModemXbee(me.commPort, me.commBps);
            }
            else if (me.telemetria == Singleton.Telemetria.AntTracker)
            {
                modem = new ModemAntTracker(antTracker);
            }

            if (me.telemetria != Singleton.Telemetria.None)
            {
                modem.listeners += RefreshInstruments;
            }

            if (me.moduloTX == Singleton.ModuloControl.Uplink)
            {
                if (jthread == null)
                {
                    jthread = new JoystickThread(this);
                }

                decimal altura = (decimal)(me.HomeAlt + 100);

                if (altura < numericUpDown1.Minimum)
                {
                    altura = numericUpDown1.Minimum;
                }
                else if (altura > numericUpDown1.Maximum)
                {
                    altura = numericUpDown1.Maximum;
                }

                numericUpDown1.Value = altura;

                label7.Enabled             = true;
                medidorBaterias4.Enabled   = true;
                medidorBaterias4.volts_max = me.uplinkVmax;
                medidorBaterias4.volts_min = me.uplinkVmin;
            }
            else
            {
                splitContainer1.SplitterDistance += panel4.Height;
                panel5.Location = panel4.Location;
                panel6.Location = new Point(panel6.Location.X, panel5.Location.Y);
                panel4.Visible  = false;
            }

            if (me.enableUDPinout)
            {
                if (this.sender == null)
                {
                    this.sender = new SenderUDP(me.portUDPinout);
                }
                this.sender.listeners += TeamRefresh;
            }
            else
            {
                comboBoxTeam.Visible = false;
                button6.Visible      = false;
                button7.Visible      = false;
                //panel8.Width -= 56;
            }

            if (me.enableWebServer)
            {
                this.KmlWebServer = new MyWebServer(me.portWebServer);
            }

            timer1.Enabled = true;
        }
예제 #5
0
        void tarea(AntTracker obj)
        {
            if (antenaTracker.IsOpen())
            {
                if (singleton.telemetria == Singleton.Telemetria.AntTracker)
                {
                    obj.packet = antenaTracker.ReadModem();
                }
                else if (obj.planeStateUpdated == true && CheckPlaneState(obj.planeState))
                {
                    datosAvion.lon = obj.planeState.Lon;
                    datosAvion.lat = obj.planeState.Lat;
                    datosAvion.alt = (short)obj.planeState.Alt;

                    datosAvion.home_lon = (float)obj.home.Longitude;
                    datosAvion.home_lat = (float)obj.home.Latitude;
                    datosAvion.home_alt = (short)obj.home.Altitude;
                    if (antenaTracker.WriteDatosAvion(datosAvion) != USBXpress.USBXpress.ReturnCodes.SI_SUCCESS)
                    {
                        antenaTracker.Close();
                    }
                    else
                        datosAntena = antenaTracker.ReadDatosAntena();
                   
                }

                if (debugUpdated)
                {
                    antenaTracker.WriteDebugInfo(debug);
                    debugUpdated = false;
                }
            }
            else
            {
                antenaTracker = new AntenaTracker();
            }

        }