public ActionResult saveFlightData(string ip, int port, int perSecond, int numSeconds, string filename)
        {
            if (filename == "")
            {
                return(View("Error"));
            }
            WebSimulatorModel model = WebSimulatorModel.getInstance();

            if (!model.if_connected())
            {
                model.disconnect();
            }
            if (!model.connect(ip, port))
            {
                return(View("Error"));
            }
            model.saveModeOn();
            model.setFileName(filename);
            Tuple <double, double> position = model.getPosition();

            if (position == null)
            {
                model.disconnect();
                model.saveModeOff();
                return(View("Error"));
            }
            model.setFileName(filename);
            ViewBag.beginLon    = position.Item1;
            ViewBag.beginLat    = position.Item2;
            ViewBag.refreshRate = 1000 * perSecond;
            ViewBag.timeout     = (1000 * numSeconds) + 100; //give an extra tenth of a second
            return(View("SaveToFileView"));
        }
        public string getPosition()
        {
            WebSimulatorModel      model    = WebSimulatorModel.getInstance();
            Tuple <double, double> position = model.getPosition();

            if (position == null)
            {
                model.disconnect();
                return(ToXML("200,200")); //failure
            }
            return(ToXML(position.Item1.ToString() + "," + position.Item2.ToString()));
        }
        public ActionResult displayPosPerSec(string ip, int port, int sec)
        {
            WebSimulatorModel model = WebSimulatorModel.getInstance();

            if (!model.if_connected())
            {
                model.disconnect();
            }
            if (!model.connect(ip, port))
            {
                return(View("Error"));
            }
            Tuple <double, double> position = model.getPosition();

            if (position == null)
            {
                model.disconnect();
                return(View("Error"));
            }
            ViewBag.beginLon    = position.Item1;
            ViewBag.beginLat    = position.Item2;
            ViewBag.refreshRate = sec;
            return(View("FindRouteView"));
        }
        //gets current position of plane simulated of FlightGear and displays the position on the map
        public ActionResult displayPos(string ip, int port)
        {
            WebSimulatorModel model = WebSimulatorModel.getInstance();

            if (!model.if_connected())
            {
                model.disconnect();
            }
            if (!model.connect(ip, port))
            {
                return(View("Error"));
            }
            Tuple <double, double> position = model.getPosition();

            if (position == null)
            {
                model.disconnect();
                return(View("Error"));
            }
            //add lon and lat to the view beg in order to share it with the view.
            ViewBag.lon = position.Item1;
            ViewBag.lat = position.Item2;
            return(View("FindLocationView"));
        }