예제 #1
0
        private static async void SendDeviceToCloudMessagesAsync()
        {
            double temperatura = 4;  // °C
            int    umidita     = 70; // %
            Random rand        = new Random();

            while (true)
            {
                double temperaturaAttuale = temperatura + rand.NextDouble() * 2 - 1;
                int    umiditaAttuale     = umidita + rand.Next(0, 20) - 10;

                var telemetria = new Telemetria
                {
                    Temperatura = temperaturaAttuale,
                    Umidita     = umiditaAttuale,
                    DataEvento  = DateTime.UtcNow
                };
                var messageString = JsonConvert.SerializeObject(telemetria);
                var message       = new Message(Encoding.ASCII.GetBytes(messageString));

                await deviceClient.SendEventAsync(message);

                Console.WriteLine("{0} > Sending message: {1}", DateTime.Now, messageString);

                Task.Delay(1000).Wait();
            }
        }
예제 #2
0
 public void Leggi(Telemetria telemetria)
 {
     if (telemetria.Temperatura > 10)
     {
         notificaAllarmi.NotificaTemperaturaTroppoAlta(telemetria.Temperatura);
     }
 }
        public void StoricizzaValoriTelemetriaDeveAggiungereCorrettamenteGliOggettiTelemetria()
        {
            //arrange

            DateTime datasalvataggio = DateTime.Now;

            datasalvataggio = new DateTime(datasalvataggio.Year, datasalvataggio.Month, datasalvataggio.Day, datasalvataggio.Hour, datasalvataggio.Minute, datasalvataggio.Second);
            Dispositivo dispositivo = new Dispositivo();

            dispositivo.Descrizione = "Dispositivo di test";

            Telemetria telemetria = new Telemetria();

            telemetria.DataSalvataggio = datasalvataggio;
            telemetria.DataEvento      = DateTime.Now.AddSeconds(-30);
            telemetria.Dispositivo     = dispositivo;
            StoricizzaValoriTelemetria storicizzavaloritelemetria = new StoricizzaValoriTelemetria();

            //act
            storicizzavaloritelemetria.Leggi(telemetria);

            //assert
            int numerorisultati;

            using (Contesto contesto = new Contesto())
            {
                numerorisultati = contesto.Set <Telemetria>().Where(telemet => telemet.DataSalvataggio == telemetria.DataSalvataggio).Count();
            }
            Assert.AreEqual(1, numerorisultati);
        }
예제 #4
0
        /*
         * Decodifica um payload do tipo TLM fazendo a conversão de uma lista de string para seu respectivo formato original
         */
        private Telemetria decoderTLM(string[] list)
        {
            Telemetria telemetria = new Telemetria();

            FieldFrame <double>   lat   = new FieldFrame <double>(INDEX.LAT, list, UNIT_FIELD.GRAU_SEXAGESIMAL);
            FieldFrame <double>   lng   = new FieldFrame <double>(INDEX.LNG, list, UNIT_FIELD.GRAU_SEXAGESIMAL);
            FieldFrame <Int32>    a_x   = new FieldFrame <Int32>(INDEX.ACCEL_X, list);
            FieldFrame <Int32>    a_y   = new FieldFrame <Int32>(INDEX.ACCEL_Y, list);
            FieldFrame <Int32>    a_z   = new FieldFrame <Int32>(INDEX.ACCEL_Z, list);
            FieldFrame <double>   g_x   = new FieldFrame <double>(INDEX.ACCEL_XG, list);
            FieldFrame <double>   g_y   = new FieldFrame <double>(INDEX.ACCEL_YG, list);
            FieldFrame <double>   g_z   = new FieldFrame <double>(INDEX.ACCEL_ZG, list);
            FieldFrame <Int32>    speed = new FieldFrame <Int32>(INDEX.SPEED, list);
            FieldFrame <UInt32>   level = new FieldFrame <UInt32>(INDEX.LEVEL, list);
            FieldFrame <bool>     bLCk  = new FieldFrame <bool>(INDEX.TRAVA, list);
            FieldFrame <DateTime> dt    = new FieldFrame <DateTime>(INDEX.TIME_STAMP_PL, list);

            telemetria.setPosition(lat.getVal(), lng.getVal());
            telemetria.setXYZ(a_x.getVal(), a_y.getVal(), a_z.getVal());
            telemetria.setXYZ_G(g_x.getVal(), g_y.getVal(), g_z.getVal());

            telemetria.Speed.Val  = speed.getVal();
            telemetria.Level.Val  = level.getVal();
            telemetria.StatusLock = bLCk.getVal();
            telemetria.DateTime   = dt.getVal();

            return(telemetria);
        }
예제 #5
0
        public static void InviaMessaggio(Telemetria telemetria)
        {
            var context    = GlobalHost.ConnectionManager.GetHubContext <TelemetriaHub>();
            var nomeGruppo = String.Concat("dispositivo", telemetria.IdDispositivo);

            context.Clients.Group(nomeGruppo).riceviMessaggio(telemetria);
        }
예제 #6
0
        public bool encode(out PayLoad payload, Telemetria b)
        {
            payload = new PayLoad();

            payload.Append(b.Latitude);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.Longitude);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisX.Val.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisY.Val.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisZ.Val.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisX.Val_G.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisY.Val_G.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.AxisZ.Val_G.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.Speed.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.Level.Val);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(b.StatusLock);
            payload.Append(CONST_CHAR.SEPARATOR);
            payload.Append(Convert.ToString(b.getTimeStamp()));

            return(true);
        }
예제 #7
0
파일: Form1.cs 프로젝트: hjgqx996/gtracker
        /*
         * Atualiza as informacoes na tela sobre o sensor de nivel
         */
        void updatelevel()
        {
            Telemetria telemetria = trackerController.getTelemetria();

            if (telemetria == null)
            {
                lmin.Text = "---";
                lmax.Text = "---";
                lVal.Text = "---";

                levelBar.Maximum = 100;
                levelBar.Minimum = 0;
                levelBar.Value   = 0;
            }
            else
            {
                levelBar.Maximum = (int)telemetria.Level.Tol.Max;
                levelBar.Minimum = (int)telemetria.Level.Tol.Min;
                levelBar.Value   = (int)telemetria.Level.Val;

                lmin.Text = levelBar.Minimum.ToString();
                lmax.Text = levelBar.Maximum.ToString();
                lVal.Text = levelBar.Value.ToString();
            }
        }
예제 #8
0
파일: Form1.cs 프로젝트: hjgqx996/gtracker
        /*************************************************************************
        *                          CALL BACKS                                   *
        *************************************************************************/

        /*
         * Evento de recepcao de dados de telemetria
         *
         */
        private void onDataTelemetria(Telemetria telemetria)
        {
            // Atualiza o status da se esta dentro de alguma cerca
            layerFence.PointIsInsidePolygon(telemetria);

            // Atualiza lista de behaviors
            bTV.Behaviors = trackerController.getBehaviorFiltered(bTV.Filter);
        }
예제 #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Telemetria telemetria = db.Telemetrias.Find(id);

            db.Telemetrias.Remove(telemetria);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Telemetria telemetria = await db.Telemetrias.FindAsync(id);

            db.Telemetrias.Remove(telemetria);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #11
0
        public Telemetria Leggi(string messaggio)
        {
            Telemetria telemetria = JsonConvert.DeserializeObject <Telemetria>(messaggio);

            foreach (var lettoreTelemetria in lettoriTelemetria)
            {
                lettoreTelemetria.Leggi(telemetria);
            }
            return(telemetria);
        }
예제 #12
0
 public async Task EnviarTelemetria(Telemetria telemetria)
 {
     if (Client != null)
     {
         var json    = JsonConvert.SerializeObject(telemetria);
         var mensaje = new Microsoft.Azure.Devices.Client.Message(
             Encoding.ASCII.GetBytes(json));
         await Client.SendEventAsync(mensaje);
     }
 }
예제 #13
0
 public ActionResult Edit([Bind(Include = "ID,VueloID,Nombre,Valor")] Telemetria telemetria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(telemetria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.VueloID = new SelectList(db.Vuelos, "ID", "Nombre", telemetria.VueloID);
     return(View(telemetria));
 }
예제 #14
0
        public void Leggi(Telemetria telemetria)
        {
            using (Contesto contesto = new Contesto())
            {
                contesto.Set <Telemetria>().Add(telemetria);
                contesto.SaveChanges();
            }


            //throw new NotImplementedException();
        }
예제 #15
0
        public ActionResult Create([Bind(Include = "ID,VueloID,Nombre,Valor")] Telemetria telemetria)
        {
            if (ModelState.IsValid)
            {
                db.Telemetrias.Add(telemetria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.VueloID = new SelectList(db.Vuelos, "ID", "Nombre", telemetria.VueloID);
            return(View(telemetria));
        }
예제 #16
0
        public static void CargaInicial(IServiceProvider serviceProvider)
        {
            using (var context = new RallyDbContexto(serviceProvider.GetRequiredService <DbContextOptions <RallyDbContexto> >()))
            {
                var temporada = new Temporada
                {
                    Id   = 1,
                    Nome = "Temporada2020",
                    //temporada.DataInicio = DateTime.Now.AddDays(20); Inicia daqui a 20 dias
                    DataInicio = DateTime.Now
                };

                var equipe = new Equipe
                {
                    Id   = 1,
                    Nome = "Azul",
                    CodigoIdentificador = "AZL"
                };

                var pilotoPedro = new Piloto
                {
                    Id   = 1,
                    Nome = "Pedro"
                };


                var pilotoCarlos = new Piloto
                {
                    Id   = 2,
                    Nome = "Carlos"
                };

                equipe.AdicionarPiloto(pilotoPedro);
                equipe.AdicionarPiloto(pilotoCarlos);

                temporada.AdicionarEquipe(equipe);

                context.Temporadas.Add(temporada);
                context.SaveChanges();

                Telemetria telemetria = new Telemetria
                {
                    Id           = 1,
                    EquipeId     = equipe.Id,
                    Data         = DateTime.Now,
                    DataServidor = DateTime.Now
                };

                context.Telemetria.Add(telemetria);
                context.SaveChanges();
            }
        }
 public void Atualizar(Telemetria telemetria)
 {
     if (_rallyDbContexto.Entry(telemetria).State == Microsoft.EntityFrameworkCore.EntityState.Detached)
     {
         _rallyDbContexto.Attach(telemetria);
         _rallyDbContexto.Entry(telemetria).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     }
     else
     {
         _rallyDbContexto.Update(telemetria);
     }
     _rallyDbContexto.SaveChanges();
 }
예제 #18
0
        public async Task <IHttpActionResult> Post(Telemetria telemetria)
        {
            telemetria.DataSalvataggio = DateTime.UtcNow;
            using (var contesto = new Contesto())
            {
                contesto.Set <Telemetria>().Add(telemetria);
                await contesto.SaveChangesAsync();
            }

            TelemetriaHub.InviaMessaggio(telemetria);

            return(Ok(telemetria));
        }
        public void LeggiMessaggioDeveLeggereCorrettamenteValoriDiTemperaturaEUmidita()
        {
            //arrange
            string messaggio      = "{\"temperatura\": 4.5,\"umidita\": 75 }";
            var    leggiMessaggio = new LeggiMessaggio();

            //act
            Telemetria telemetria = leggiMessaggio.Leggi(messaggio);

            //assert
            Assert.AreEqual(4.5, telemetria.Temperatura);
            Assert.AreEqual(75, telemetria.Umidita);
        }
예제 #20
0
        public void Update(Telemetria telemetria)
        {
            if (_dbContext.Entry(telemetria).State == Microsoft.EntityFrameworkCore.EntityState.Detached)
            {
                _dbContext.Attach(telemetria);
                _dbContext.Entry(telemetria).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }
            else
            {
                _dbContext.Update(telemetria);
            }

            _dbContext.SaveChanges();
        }
예제 #21
0
        // GET: Telemetria/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Telemetria telemetria = await db.Telemetrias.FindAsync(id);

            if (telemetria == null)
            {
                return(HttpNotFound());
            }
            return(View(telemetria));
        }
예제 #22
0
        // GET: Telemetrias/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Telemetria telemetria = db.Telemetrias.Find(id);

            if (telemetria == null)
            {
                return(HttpNotFound());
            }
            return(View(telemetria));
        }
예제 #23
0
        // GET: Telemetria/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Telemetria telemetria = await db.Telemetrias.FindAsync(id);

            if (telemetria == null)
            {
                return(HttpNotFound());
            }
            ViewBag.VueloID = new SelectList(db.Vuelos, "VueloID", "Nombre", telemetria.VueloID);
            return(View(telemetria));
        }
        public void SeLaTemperaturaMaggioreDi10GradiNotificaAllarme()
        {
            //arrange
            var telemetria = new Telemetria {
                Temperatura = 10.5
            };
            var notificaAllarmi = Substitute.For <INotificaAllarmi>();
            var leggiMessaggio  = new VerificaAllarmiTemperatura(notificaAllarmi);

            //act
            leggiMessaggio.Leggi(telemetria);

            //assert
            notificaAllarmi.Received().NotificaTemperaturaTroppoAlta(10.5);
        }
예제 #25
0
파일: Form1.cs 프로젝트: hjgqx996/gtracker
        /**
         * Verifica se o veiculo se encontra dentro da cerca para liberacao da trava
         */
        private void lckMng()
        {
            Telemetria telemetria = trackerController.getTelemetria();

            if (telemetria != null)
            {
                if (telemetria.IsInsideOfFence())
                {
                    trackerController.lockVehicle(lockVehicle);
                }
                else
                {
                    trackerController.lockVehicle(true);
                }
            }
        }
예제 #26
0
        public async void EnviarTelemetria_Clicked(object sender, EventArgs e)
        {
            EnviarTelemetria.IsEnabled = false;

            for (int i = 1; i < 6; i++)
            {
                var bateria   = ServicioBateria.ObtenerBateriaActual();
                var ubicacion = await ServicioUbicacion.ObtenerUbicacionActual();

                if (bateria != null)
                {
                    Bateria.Text = bateria.Porcentaje.ToString();
                    Status.Text  = bateria.Status;
                    Fuente.Text  = bateria.Fuente;
                }

                if (ubicacion != null)
                {
                    Latitud.Text  = ubicacion.Latitud.ToString();
                    Longitud.Text = ubicacion.Longitud.ToString();
                }

                if (bateria != null && ubicacion != null)
                {
                    var telemetria = new Telemetria()
                    {
                        Bateria   = bateria,
                        Ubicacion = ubicacion,
                        Fecha     = DateTime.UtcNow
                    };

                    EnviarTelemetria.Text = $"Enviando dato {i}...";
                    await hub.EnviarTelemetria(telemetria);

                    EnviarTelemetria.Text = $"Dato {i} enviado!!";
                }

                await Task.Delay(15000);
            }

            await DisplayAlert("IoTHub", "Mensajes enviados al hub", "OK");

            EnviarTelemetria.IsEnabled = true;
        }
예제 #27
0
파일: Form1.cs 프로젝트: hjgqx996/gtracker
        /*
         * Atualiza as informacoes na tela sobre a trava
         */
        void updateStatusLock()
        {
            Telemetria telemetria = trackerController.getTelemetria();

            if (telemetria == null)
            {
                labelStatusLock.BackColor = Color.Gray;
                labelStatusLock.Text      = "---";
            }
            else if (telemetria.StatusLock)
            {
                labelStatusLock.BackColor = Color.Red;
                labelStatusLock.Text      = "LOCK";
            }
            else
            {
                labelStatusLock.BackColor = Color.Green;
                labelStatusLock.Text      = "UNLOCK";
            }
        }
예제 #28
0
        static Telemetria createTelemetriaData()
        {
            Telemetria b = new Telemetria();

            if (TrackerController.TrackerCtrl.anyRoute() &&
                TrackerController.TrackerCtrl.Routes[0].MapRoute.Points.Count > count_publish)
            {
                Random      rnd = new Random();
                PointLatLng p   = TrackerController.TrackerCtrl.Routes[0].MapRoute.Points[count_publish++];

                b.setPosition(AsGrauSexagesimal(p.Lat) * 100, AsGrauSexagesimal(p.Lng) * 100);
                b.setXYZ(rnd.Next(0, 4), rnd.Next(0, 4095), rnd.Next(0, 4095));
                b.setXYZ_G(rnd.Next(-120, 120) / 100.0, rnd.Next(-120, 120) / 100.0, rnd.Next(-120, 120) / 100.0);
                b.setSpeed(rnd.Next(40, 120));
                b.setLevel(rnd.Next(5000, 32000));
                b.DateTime = DateTime.Now;
            }

            return(b);
        }
예제 #29
0
파일: Form1.cs 프로젝트: hjgqx996/gtracker
        /*
         * Atualiza as informacoes na tela sobre a cerca virtual
         */
        void updateStatusFence()
        {
            Telemetria telemetria = trackerController.getTelemetria();

            if (telemetria == null)
            {
                lFence.BackColor   = Color.Gray;
                btn_unlock.Enabled = false;
            }
            else if (telemetria.IsInsideOfFence())
            {
                lFence.BackColor   = Color.Green;
                btn_unlock.Enabled = true;
            }
            else
            {
                lFence.BackColor   = Color.Red;
                btn_unlock.Enabled = false;
            }
        }
예제 #30
0
        internal bool PointIsInsidePolygon(Telemetria data)
        {
            bool ret = false;

            if (data != null)
            {
                PointLatLng p = new PointLatLng(data.Latitude, data.Longitude);

                int i = 0;

                foreach (GMapPolygon poly in mapOverlay.Polygons)
                {
                    data.setInsideOfFence(i++, poly.IsInside(p));

                    if (data.IsInsideOfFence())
                    {
                        ret = true;
                    }
                }
            }

            return(ret);
        }
예제 #31
0
        public void FromRegistry()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath);
            if (key != null)
            {
                try
                {
                    this.GoogleMapsCookie = (string)key.GetValue("GoogleMapsCookie");
                    this.HomeLon = float.Parse(key.GetValue("HomeLon").ToString(),CultureInfo.InvariantCulture);
                    this.HomeLat = float.Parse(key.GetValue("HomeLat").ToString(), CultureInfo.InvariantCulture);
                    this.HomeAlt = float.Parse(key.GetValue("HomeAlt").ToString(), CultureInfo.InvariantCulture);

                    this.videoCaptureStr = (string)key.GetValue("VideoCaptureStr");
                    this.telemetria = (Telemetria)key.GetValue("Telemetry");
                    this.videosystem = (VideoSystem)key.GetValue("VideoSystem");
                    this.commPort = (string)key.GetValue("CommPort");
                    this.commBps = (int)key.GetValue("CommBauds");
                    this.CacheMapsPath = (string)key.GetValue("CacheMapsPath");
                    this.FlightLogPath = (string)key.GetValue("FlightLogPath");
                    this.cells1 = (int)key.GetValue("CellCount1");
                    this.cells2 = (int)key.GetValue("CellCount2");


                    this.moduloTX = (Singleton.ModuloControl)(int)key.GetValue("ModuloTX");

                    try
                    {
                        for (int i = 0; i < servo_ch.Length; i++)
                        {
                            this.servo_min[i] = (int)key.GetValue("ServoMin" + i);
                            this.servo_center[i] = (int)key.GetValue("ServoCenter" + i);
                            this.servo_max[i] = (int)key.GetValue("ServoMax" + i);
                            this.servo_rev[i] = (int)key.GetValue("ServoRev" + i) == 1;
                            this.servo_ch[i] = (byte)((int)key.GetValue("ServoCh" + i));
                        }

                        for (int i = 0; i < 16; i++)
                        {
                            this.joy_buttons[i] = (byte)((int)key.GetValue("JoyButtom" + i));
                        }

                        this.tipo_mezcla = (Mezclas)key.GetValue("TipoMezcla");
                        //      this.tipo_control = (ModoControl)key.GetValue("TipoControl");
                        this.rev_mix = (int)key.GetValue("rev_mix") == 1;
                        this.rev_flap = (int)key.GetValue("rev_flap") == 1;
                        this.full_flap = float.Parse(key.GetValue("full_flap").ToString());
                        this.step_flap = float.Parse(key.GetValue("step_flap").ToString());

                        this.pantilt_speed = float.Parse(key.GetValue("pantilt_speed").ToString());
                        this.enable_axis = (int)key.GetValue("AXISenable") == 1;
                        this.enable_pan = (int)key.GetValue("PANenable") == 1;
                        this.enable_tilt = (int)key.GetValue("TILTenable") == 1;

                        this.enable_headtrack = (int)key.GetValue("enable_headtrack") == 1;
                        object pepe = key.GetValue("headtrack_panCh");
                        this.headtrack_panCh = (byte)((int)key.GetValue("headtrack_panCh"));
                        this.headtrack_tiltCh = (byte)((int)key.GetValue("headtrack_tiltCh"));

                        this.uplinkVmax = float.Parse(key.GetValue("uplinkVmax").ToString(), CultureInfo.InvariantCulture);
                        this.uplinkVmin = float.Parse(key.GetValue("uplinkVmin").ToString(), CultureInfo.InvariantCulture);
                        this.uplinkValarm = float.Parse(key.GetValue("uplinkValarm").ToString(), CultureInfo.InvariantCulture);
                        this.uplinkLipo = (int)key.GetValue("uplinkLipo") == 1;
                        this.uplinkNumCells = (int)key.GetValue("uplinkNumCells");

                        this.useEmisora = (int)key.GetValue("useEmisora") == 1;
                        this.txNumCanales = (byte)((int)key.GetValue("txNumCanales")); ;
                        this.txPeriodo = (int)key.GetValue("txPeriodo"); ;
                        this.txSeparador = (int)key.GetValue("txSeparador");
                        this.txPolarity = (int)key.GetValue("txPolarity") == 1;
                    }
                    catch (Exception) { };
                    //Configuracion joystick

                    try
                    {

                        this.Idioma = (int)key.GetValue("Language");
                        this.SistemaMetrico = (int)key.GetValue("SistemaMetrico");
                    }
                    catch (Exception) { }

                    this.NombrePiloto = key.GetValue("NombrePiloto").ToString();
                    
                    this.portUDPinout = (int)key.GetValue("portUDPinout");
                    this.portWebServer = (int)key.GetValue("portWebServer");

                    this.enableWebServer = (int)key.GetValue("enableWebServer") == 1;
                    this.enableUDPinout = (int)key.GetValue("enableUDPinout") == 1;

                    try
                    {
                        this.AlarmAltitude_enabled = (int)key.GetValue("AlarmAltitude_enabled") == 1;
                        this.AlarmAltitude = float.Parse(key.GetValue("AlarmAltitude").ToString(), CultureInfo.InvariantCulture);

                        this.AlarmAscenso_enabled = (int)key.GetValue("AlarmAscenso_enabled") == 1;
                        this.AlarmAscenso = float.Parse(key.GetValue("AlarmAscenso").ToString(), CultureInfo.InvariantCulture);

                        this.AlarmCellVoltage_enabled = (int)key.GetValue("AlarmCellVoltage_enabled") == 1;
                        this.AlarmCellVoltage = float.Parse(key.GetValue("AlarmCellVoltage").ToString(), CultureInfo.InvariantCulture);

                        this.AlarmDistance_enabled = (int)key.GetValue("AlarmDistance_enabled") == 1;
                        this.AlarmDistance = float.Parse(key.GetValue("AlarmDistance").ToString(), CultureInfo.InvariantCulture);

                        this.AlarmFastDescentRate_enabled = (int)key.GetValue("AlarmFastDescentRate_enabled") == 1;
                        this.AlarmFastDescentRate = float.Parse(key.GetValue("AlarmFastDescentRate").ToString(), CultureInfo.InvariantCulture);
                    }
                    catch (Exception) { };

                    try
                    {
                        this.enableAntTrack = (int)key.GetValue("enableAntTrack") == 1;
                        this.enableCasaAntTrack = (int)key.GetValue("enaleCasaAntTrack")==1;
                    
                    } catch (Exception){};

                    try
                    {
                        for (int i = 0; i < asignaciones.Length; i++)
                        {
                            this.asignaciones[i] = (int)key.GetValue("TeclaAsignada" + i);
                        }
                    }
                    catch (Exception) { };

                    try
                    {
                        // Uplink debug values
                        this.uplink_pid_ail_P = float.Parse(key.GetValue("uplink_pid_ail_P").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ail_I = float.Parse(key.GetValue("uplink_pid_ail_I").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ail_D = float.Parse(key.GetValue("uplink_pid_ail_D").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ail_IL = float.Parse(key.GetValue("uplink_pid_ail_IL").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ail_DL = float.Parse(key.GetValue("uplink_pid_ail_DL").ToString(), CultureInfo.InvariantCulture);

                        this.uplink_pid_ele_P = float.Parse(key.GetValue("uplink_pid_ele_P").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ele_I = float.Parse(key.GetValue("uplink_pid_ele_I").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ele_D = float.Parse(key.GetValue("uplink_pid_ele_D").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ele_IL = float.Parse(key.GetValue("uplink_pid_ele_IL").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_ele_DL = float.Parse(key.GetValue("uplink_pid_ele_DL").ToString(), CultureInfo.InvariantCulture);

                        this.uplink_pid_thr_P = float.Parse(key.GetValue("uplink_pid_thr_P").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_thr_I = float.Parse(key.GetValue("uplink_pid_thr_I").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_thr_D = float.Parse(key.GetValue("uplink_pid_thr_D").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_thr_IL = float.Parse(key.GetValue("uplink_pid_thr_IL").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_thr_DL = float.Parse(key.GetValue("uplink_pid_thr_DL").ToString(), CultureInfo.InvariantCulture);

                        this.uplink_pid_tail_P = float.Parse(key.GetValue("uplink_pid_tail_P").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_tail_I = float.Parse(key.GetValue("uplink_pid_tail_I").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_tail_D = float.Parse(key.GetValue("uplink_pid_tail_D").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_tail_IL = float.Parse(key.GetValue("uplink_pid_tail_IL").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_pid_tail_DL = float.Parse(key.GetValue("uplink_pid_tail_DL").ToString(), CultureInfo.InvariantCulture);

                        this.uplink_IR_offX = float.Parse(key.GetValue("uplink_IR_offX").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_IR_offY = float.Parse(key.GetValue("uplink_IR_offY").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_IR_gain = float.Parse(key.GetValue("uplink_IR_gain").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_rumbo_ail = float.Parse(key.GetValue("uplink_rumbo_ail").ToString(), CultureInfo.InvariantCulture);
                        this.uplink_altura_ele = float.Parse(key.GetValue("uplink_altura_ele").ToString(), CultureInfo.InvariantCulture);

                        this.uplink_IR_rev_P = (int)key.GetValue("uplink_IR_rev_P") == 1;
                        this.uplink_IR_rev_R = (int)key.GetValue("uplink_IR_rev_R") == 1;
                        this.uplink_IR_cross = (int)key.GetValue("uplink_IR_cross") == 1;
                        this.uplink_IR_rev_cross = (int)key.GetValue("uplink_IR_rev_cross")==1;
                    }
                    catch (Exception) { };

                    this.PicturePath = (string)key.GetValue("PicturePath", "C:\\Fotos");
                    this.VideosPath = (string)key.GetValue("VideosPath", "C:\\Videos");

                    try
                    {
                        this.trocearVideo = (int)key.GetValue("trocearVideo") == 1;
                        this.trocearTamMB = (int)key.GetValue("trocearTamMB");
                        this.calidadVideo = (int)key.GetValue("calidadVideo");
                        this.fpsVideo = (int)key.GetValue("fpsVideo");
                    }
                    catch (Exception) { };
                }
                catch (Exception)
                {
                }        
            }
            else
                Registry.CurrentUser.CreateSubKey(registryPath);

        }
예제 #32
0
        protected Singleton()
        {
            asignaciones = new int[Enum.GetNames(typeof(EventosJoy)).Length - 1];
            Ruta = new List<WayPoint>();
            
            commPort = "";
            videoCaptureStr = "";
            HomeLon = -6.0345f;
            HomeLat = 37.2342f;
            HomeAlt = 100.0f;
            telemetria = Telemetria.Video;
            videosystem = VideoSystem.PAL;
            
            this.NombrePiloto = "Ikarus";
            this.enableUDPinout = false;
            this.enableWebServer = false;
            this.portWebServer = 8080;
            this.portUDPinout = 9500;

            this.Idioma = 0;    // Español
            this.SistemaMetrico = 0; // Metrico
   
            this.servo_ch = new byte[8];
            this.servo_min = new int[servo_ch.Length];
            this.servo_center = new int[servo_ch.Length];
            this.servo_max = new int[servo_ch.Length];
            this.servo_rev = new bool[servo_ch.Length];
         

            for (int i = 0; i < servo_ch.Length; i++)
            {
                this.servo_min[i] = 1000;
                this.servo_center[i] = 1500;
                this.servo_max[i] = 2000;
                this.servo_rev[i] = false;
                this.servo_ch[i] = (byte)i;
            }

            this.joy_buttons = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                this.joy_buttons[i] = 0;
            }
            this.tipo_mezcla = Mezclas.Normal;
          //  this.tipo_control = ModoControl.MODO_MODEM;
            this.rev_mix = false;
            this.rev_flap = false;
            this.full_flap = 1.0f;
            this.step_flap = 0.1f;

            this.pantilt_speed = 1.0f;

            this.AlarmAltitude_enabled = false;
            this.AlarmAscenso_enabled = false;
            this.AlarmCellVoltage_enabled = false;
            this.AlarmDistance_enabled = false;
            this.AlarmFastDescentRate_enabled = false;

            this.AlarmAltitude = 80.0f;
            this.AlarmAscenso = 5.0f;
            this.AlarmCellVoltage = 3.5f;
            this.AlarmDistance = 1000.0f;
            this.AlarmFastDescentRate = 10.0f;

            this.enable_headtrack = false;
            this.headtrack_panCh = 0;
            this.headtrack_tiltCh = 1;

            this.uplinkVmax = 12.6f;
            this.uplinkVmin = 9.6f;
            this.uplinkValarm = 10.0f;
            this.uplinkLipo = true;
            this.uplinkNumCells = 3;

            this.enableAntTrack = false;
            this.enableCasaAntTrack = false;

            this.useEmisora = true;
            this.txNumCanales = 8;
            this.txPeriodo = 20000;
            this.txSeparador = 400;
            this.txPolarity = false;

            // Uplink debug values
            this.uplink_pid_ail_P=0.02f;
            this.uplink_pid_ail_I=0.0f;
            this.uplink_pid_ail_D=0.0f;
            this.uplink_pid_ail_IL=0.0f;
            this.uplink_pid_ail_DL=1.0f;

            this.uplink_pid_ele_P=0.02f;
            this.uplink_pid_ele_I=0.0f;
            this.uplink_pid_ele_D=0.0f;
            this.uplink_pid_ele_IL=0.0f;
            this.uplink_pid_ele_DL=1.0f;

            this.uplink_pid_thr_P=0.02f;
            this.uplink_pid_thr_I=0.0f;
            this.uplink_pid_thr_D=0.0f;
            this.uplink_pid_thr_IL=0.0f;
            this.uplink_pid_thr_DL=1.0f;

            this.uplink_pid_tail_P=0.02f;
            this.uplink_pid_tail_I=0.0f;
            this.uplink_pid_tail_D=0.0f;
            this.uplink_pid_tail_IL=0.0f;
            this.uplink_pid_tail_DL=1.0f;

            this.uplink_IR_offX=1.66f;
            this.uplink_IR_offY = 1.66f;
            this.uplink_IR_gain = 1.14f;
            this.uplink_rumbo_ail = 20.0f;
            this.uplink_altura_ele = 10.0f;

            this.uplink_IR_rev_P = false;
            this.uplink_IR_rev_R = false;
            this.uplink_IR_cross = false;
            this.uplink_IR_rev_cross = false;

            this.trocearVideo = false;
            this.trocearTamMB = 1024;
            this.calidadVideo = 50;
            this.fpsVideo = 15;


            FromRegistry();
        }