Exemple #1
0
 public AntTrackerDatosAntena ReadDatosAntena()
 {
      
     if (this.IsOpen())
     {
         AntTrackerDatosAntena datos = new AntTrackerDatosAntena();
         byte[] buff = Read(Comandos.ReadAntena, 0, 0, datos.size_bytes());
         datos.FromByteArray(buff);
         return datos;
     }
     else
         return null;
 }
Exemple #2
0
        public void RefreshInstruments()
        {
            if (modem != null)
            {
                me.planeState = modem.getTelemetry();
                if (me.planeState != null)
                {
                    medidorBaterias1.volts = me.planeState.v1;
                    medidorBaterias2.volts = me.planeState.v2;

                    if (me.SistemaMetrico == (int)Singleton.SistemasMetricos.Metrico)
                        instrumento_Altimeter1.Altitude = me.planeState.Alt;
                    else
                        instrumento_Altimeter1.Altitude = me.planeState.Alt*3.28f;
                    
                    instrumento_DirectionalGyro1.Value = me.planeState.Rumbo;

                    if (me.SistemaMetrico == (int)Singleton.SistemasMetricos.Metrico)
                        instrumento_VerticalSpeed1.Value=me.planeState.vertSpeed*100;
                    else
                        instrumento_VerticalSpeed1.Value = me.planeState.vertSpeed*328.0f;
                    
                    
                    instrumento_HorizonteArtificial.pitch = me.planeState.pitch;
                    instrumento_HorizonteArtificial.roll = me.planeState.roll;

                    if (me.SistemaMetrico == (int)Singleton.SistemasMetricos.Imperial)
                        dG808_AirSpeed1.Value = me.planeState.Knots;
                    else
                        dG808_AirSpeed1.Value = me.planeState.Knots * 1.852f;
     
                    medidorRSSI.valor = me.planeState.RSSI / 100.0f;
                    medidorRSSI.Invalidate();

                    // cambiar por planeWpt
                    mapControl1.plane.heading = me.planeState.Rumbo;
                    mapControl1.plane.Latitude = me.planeState.Lat;
                    mapControl1.plane.Longitude = me.planeState.Lon;
                    mapControl1.plane.Altitude = me.planeState.Alt;


                    if (checkBox2.Checked)
                    {
                        //if (DateTime.Now.Millisecond < 500)
                        if (DateTime.Now.Second %2  == 0)
                        
                        {
                            if (semaforo)
                            {
                                mapControl1.AddHistory();
                                semaforo = false;
                            }

                        }
                        else
                        {
                            if (!semaforo)
                            {
                                //mapControl1.AddHistory();
                                semaforo = true;
                            }

                        }
                    }
                    else
                        mapControl1.ClearHistory();
                   
                    me.HomeAlt = instrumento_Altimeter1.Calibration;
                    homeWpt.Altitude = me.HomeAlt;

                    // cambiar por targetWpt
                    mapControl1.target.Latitude = me.planeState.homeLat;
                    mapControl1.target.Longitude = me.planeState.homeLon;

                    if (antTracker != null)
                    {
                        antTracker.Send(me.planeState, homeWpt);
                        datosAntena = antTracker.datosAntena;
                        if (datosAntena != null)
                        {
                            medidorBaterias3.volts = datosAntena.v_bateria;
                            medidorBaterias3.valor = datosAntena.v_baterial_porcentaje / 100.0f;
                            medidorBaterias3.Invalidate();
                        }
                    }

                    if (checkBoxHomeRX.Checked == false)
                    {
                        if (datosAntena != null && datosAntena.tieneGPS!=0)
                        {
                            if (datosAntena.tienePOS != 0)
                            {
                                homeWpt.Latitude = datosAntena.lat;
                                homeWpt.Longitude = datosAntena.lon;
                            }
                        }
                        else
                        {
                            homeWpt.Latitude = me.HomeLat;
                            homeWpt.Longitude = me.HomeLon;
                        }
                    }
                    else if (me.planeState.WptIndex == -1)
                    {
                        homeWpt.Latitude = me.planeState.homeLat;
                        homeWpt.Longitude = me.planeState.homeLon;
                    }

                    if (me.planeState.WptIndex != -3)
                    {
                        mapControl1.home.Latitude = homeWpt.Latitude;
                        mapControl1.home.Longitude = homeWpt.Longitude;
                        //mapControl1.home = new WayPoint("CASA", homeWpt.Longitude, homeWpt.Latitude);
                        mapControl1.rumboHold = float.NaN;

                        try
                        {
                            if (me.planeState.WptIndex >= 0 && me.planeState.WptIndex < 32 &&
                                (me.planeState.WptIndex != last_wptid || last_wptid != numericUpDown2.Value))
                            {
                                last_wptid = (byte)me.planeState.WptIndex;
                                numericUpDown2.Tag = last_wptid;
                                numericUpDown2.Value = last_wptid;
                            }
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        //mapControl1.home = null;
                        mapControl1.rumboHold = (float)me.planeState.homeLon;
                    }

                    mapControl1.Invalidate();

                    if (me.enableUDPinout)
                        SenderUDP.SendInfo(me.NombrePiloto, me.portUDPinout);

                    led1.valid = me.planeState.lastrx;
                    led1.Invalidate();
                }
            }

            if (jthread != null)
            {
                try
                {
                    UpdateButtonCamera();
                    UpdateButtonAutopilot();
                    UpdateButtonHUD();
                    UpdateButtonRuta();

                    medidorBaterias4.volts = me.uplink_voltage;
                }
                catch (Exception) { }
            }
        }
Exemple #3
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();
            }

        }