Ejemplo n.º 1
0
        public string GetValuesFromServer()
        {
            // connect to server.
            CommandsServer commandsServer = CommandsServer.getInstance();

            commandsServer.connect();
            // request lon, lat, rudder and throttle values from server.
            double lon      = commandsServer.write("get position/longitude-deg");
            double lat      = commandsServer.write("get position/latitude-deg");
            double rudder   = commandsServer.write("get controls/flight/rudder");
            double throttle = commandsServer.write("get controls/engines/current-engine/throttle");

            // create a string of the values separated by spaces and return it as an XML.
            return(ToXML(lon.ToString() + " " + lat.ToString() + " " + rudder.ToString() + " " + throttle.ToString()));
        }
Ejemplo n.º 2
0
        public ActionResult LocationDisplay(string arg1, int arg2)
        {
            // connect to server.
            CommandsServer commandsServer = CommandsServer.getInstance();

            commandsServer.Ip   = arg1;
            commandsServer.Port = arg2;
            commandsServer.connect();
            // request values of lon, lat and pass through viewbag.
            double lon = commandsServer.write("get position/longitude-deg");
            double lat = commandsServer.write("get position/latitude-deg");

            ViewBag.Lon = lon;
            ViewBag.Lat = lat;
            return(View("~/Views/Map/LocationDisplay.cshtml"));
        }
Ejemplo n.º 3
0
        public ActionResult RouteDisplay(string arg1, int arg2, int arg3)
        {
            // connect to server.
            CommandsServer commandsServer = CommandsServer.getInstance();

            commandsServer.Ip   = arg1;
            commandsServer.Port = arg2;
            ViewBag.UpdateRate  = arg3;
            commandsServer.connect();
            // request initial lon, lat and pass through viewbag.
            double lon = commandsServer.write("get position/longitude-deg");
            double lat = commandsServer.write("get position/latitude-deg");

            ViewBag.FirstLon = lon;
            ViewBag.FirstLat = lat;
            return(View());
        }
Ejemplo n.º 4
0
        public string SaveValuesFromServer()
        {
            // connect to server.
            CommandsServer commandsServer = CommandsServer.getInstance();

            commandsServer.connect();
            // request lon, lat, rudder and throttle values from server.
            double lon      = commandsServer.write("get position/longitude-deg");
            double lat      = commandsServer.write("get position/latitude-deg");
            double rudder   = commandsServer.write("get controls/flight/rudder");
            double throttle = commandsServer.write("get controls/engines/current-engine/throttle");
            // create a string of the values separated by spaces.
            string values = lon.ToString() + " " + lat.ToString() + " " + rudder.ToString() + " " + throttle.ToString();

            // save the values string on the txt file.
            System.IO.File.AppendAllText(filePath, string.Format("{0}{1}", values, Environment.NewLine));
            // return the values string as an XML.
            return(ToXML(values));
        }
Ejemplo n.º 5
0
        public ActionResult RouteSave(string arg1, int arg2, int arg3, int arg4, string arg5)
        {
            // connect to server.
            CommandsServer commandsServer = CommandsServer.getInstance();

            commandsServer.Ip   = arg1;
            commandsServer.Port = arg2;
            commandsServer.connect();
            // pass update rate through viewbag.
            ViewBag.UpdateRate = arg3;
            ViewBag.TimeLimit  = arg4;
            // request initial lon, lat and pass through viewbag.
            double lon = commandsServer.write("get position/longitude-deg");
            double lat = commandsServer.write("get position/latitude-deg");

            ViewBag.FirstLon = lon;
            ViewBag.FirstLat = lat;
            // create a txt file to save the sampled location on and set it as a data member to access later.
            filePath = System.Web.HttpContext.Current.Server.MapPath(String.Format(SCENARIO_FILE, arg5));
            TextWriter file = new StreamWriter(filePath);

            file.Close();
            return(View());
        }