private void loadComunication()
        {
            Comunication comunication = comunicationControl.getComunication();

            if (comunication != null)
            {
                int indexHardware = -1;

                for (int i = 0; i < allHardwares.Count; i++)
                {
                    Hardware hd = (Hardware)allHardwares[i];
                    if (comunication.hardware.idHardware == hd.idHardware)
                    {
                        indexHardware = i;
                        break;
                    }
                }

                CBHardware.SelectedIndex = indexHardware;
                TBIp.Text     = comunication.ip;
                TBPort.Text   = comunication.port;
                TBEndDev.Text = comunication.endDev;

                idComunication = comunication.idComunication;
            }
        }
Exemple #2
0
        public Comunication getComunication()
        {
            Comunication comunication = null;

            OleDbCommand cmd = DBConnection.getInstance.getDbCommand();

            cmd.CommandText = "SELECT * FROM COMUNICATION";
            OleDbDataReader result = cmd.ExecuteReader();

            if (result.HasRows)
            {
                while (result.Read())
                {
                    comunication = new Comunication();
                    comunication.idComunication = result.GetInt32(0);
                    comunication.hardware       = hardwareControl.getHardware(result.GetInt32(1));
                    comunication.ip             = result.GetString(2);
                    comunication.port           = result.GetString(3);
                    comunication.endDev         = result.GetString(4);
                }
            }

            result.Close();

            return(comunication);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Character1Id,Character2Id")] Comunication comunication)
        {
            if (id != comunication.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comunication);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComunicationExists(comunication.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Character1Id"] = new SelectList(_context.Characters, "Id", "Name", comunication.Character1Id);
            ViewData["Character2Id"] = new SelectList(_context.Characters, "Id", "Name", comunication.Character2Id);
            return(View(comunication));
        }
Exemple #4
0
 public Player()
 {
     com = new USocket();
     InitializeComponent();
     ProcessIDText.Text = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
     Control.CheckForIllegalCrossThreadCalls = false;
     CheckForIllegalCrossThreadCalls         = false;
     iSendMsg = false;
 }
        public string getData()
        {
            //get all needed data from simulator
            Comunication info = Comunication.Instance;

            info.Lon      = info.read_from_simulator("get /position/longitude-deg\r\n");
            info.Lat      = info.read_from_simulator("get /position/latitude-deg\r\n");
            info.Throttle = info.read_from_simulator("get /controls/engines/current-engine/throttle\r\n");
            info.Rudder   = info.read_from_simulator("get /controls/flight/rudder\r\n");
            return(ToXml(info));
        }
        public ActionResult save(string ip, int port, int refreshRate, int timeout, string fileName)
        {
            Comunication info = Comunication.Instance;

            info.IP   = ip;
            info.Port = port;
            info.Connect();
            Session["refreshRate"] = refreshRate;
            Session["timeout"]     = timeout;
            info.FilePath          = AppDomain.CurrentDomain.BaseDirectory + fileName + ".csv";
            //return view of save
            return(View("~/Views/Main/save.cshtml"));
        }
Exemple #7
0
        public RedirectToRouteResult EmailConfirmation()
        {
            string userGUID = Request["userGUID"].ToString();

            if (Comunication.activateUser(userGUID))
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Error", "Shared"));
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Character1Id,Character2Id")] Comunication comunication)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comunication);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Character1Id"] = new SelectList(_context.Characters, "Id", "Name", comunication.Character1Id);
            ViewData["Character2Id"] = new SelectList(_context.Characters, "Id", "Name", comunication.Character2Id);
            return(View(comunication));
        }
        private string ToXml(Comunication info)
        {
            //Initiate XML stuff
            StringBuilder     sb       = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            XmlWriter         writer   = XmlWriter.Create(sb, settings);

            writer.WriteStartDocument();

            info.ToXml(writer);

            writer.WriteEndDocument();
            writer.Flush();
            return(sb.ToString());
        }
        public ActionResult Agregar(Comunication c)
        {
            if (c.contacto == 0)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
            if (c.comentario == null)
            {
                c.comentario = "";
            }
            Comunicacion nueva = comc.Agregar(new Comunicacion()
            {
                comentario = c.comentario, fecha = DateTime.Today, tipo = c.tipo
            }, c.contacto);
            string fecha = nueva.fecha.ToString().Substring(0, 10);

            return(Json(new { success = true, data = nueva, fecha }, JsonRequestBehavior.AllowGet));
        }
        public string getDataFromFile()
        {
            //get data from file until last data
            if (index == (data.Length - 1))
            {
                index--;
            }
            Comunication info = Comunication.Instance;

            string[] x = data[index].Split(',');
            //set all data in info and send to XML.
            info.Lon      = x[0];
            info.Lat      = x[1];
            info.Throttle = x[2];
            info.Rudder   = x[3];
            index++;
            return(ToXml(info));
        }
        public ActionResult display(string ip, int port, int refreshRate = 0)
        {
            IPAddress    ipAdress;
            Comunication info = Comunication.Instance;

            //check its an ip and make the display for it
            if (IPAddress.TryParse(ip, out ipAdress))
            {
                //connect to simulator from getting data
                info.IP   = ip;
                info.Port = port;
                info.Connect();
                if (refreshRate == 0)
                {
                    //return view fo display with 2 parameters
                    return(View("~/Views/Main/display2params.cshtml"));
                }
                else
                {
                    Session["refreshRate"] = refreshRate;
                }
                //returnes view of 3 parameters with refresh rate
                return(View("~/Views/Main/display.cshtml"));
            }
            //in case its the display of file name and rate
            else
            {
                //set indexer fo data to the start of the array
                index = 0;
                //file name is first parameter ('ip')
                info.FilePath = AppDomain.CurrentDomain.BaseDirectory + ip + ".csv";
                data          = System.IO.File.ReadAllLines(info.FilePath);
                //refresh rate is the second parameter ('port')
                Session["refreshRate"] = port;
                //number of data
                Session["data"] = data.Length;
                //return view of display from file
                return(View("~/Views/Main/displayFromFile.cshtml"));
            }
        }