public ActionResult display(string param1, int param2) { var model = InfoModel.Instance; // display flight info from file if (!ValidateIPv4(param1)) { string file = param1; int time = param2; model.ReadData(file); index = 0; double infoLength = model.FileContent.Length; //defining timeout double timeout = (infoLength / 4) * (double)time; Session["timeLoad"] = time; Session["timeout"] = timeout; return(View("loadFlightInfo")); } // desplay only current location. string ip = param1; int port = param2; Session["ip"] = ip; Session["port"] = port; // connect to simulator. SimulatorConnection.Instance(ip, port).Connect(); return(View("display")); }
// Returns an xml with the current location info. public string GetLocation() { var info = LocationInfo.Instance; info.Read(SimulatorConnection.Instance(Session["ip"].ToString(), int.Parse(Session["port"].ToString())).Read()); return(ToXml(info)); }
// Sampling the flight info from the simulator. public string GetSaveSample() { var info = LocationInfo.Instance; info.Read(SimulatorConnection.Instance(Session["ip"].ToString(), int.Parse(Session["port"].ToString())).Read()); InfoModel.Instance.SaveData(Session["file_save"].ToString(), new double[] { info.Lon, info.Lat, info.Rudder, info.Throttle }); return(ToXml(info)); }
// Sampling the flight info with no time limit. public ActionResult displayAndUpdate(string ip, int port, int time) { // connect to the simulator. SimulatorConnection.Instance(ip, port).Connect(); Session["ip"] = ip; Session["port"] = port; Session["time"] = time; return(View("displayAndUpdate")); }
// Saving the flight info samples to the requested file and showing the path. public ActionResult saveFlightInfo(string ip, int port, int time, int duration, string file) { InfoModel model = InfoModel.Instance; // connect to the simulator. SimulatorConnection.Instance(ip, port).Connect(); model.PrepareFile(file); Session["ip"] = ip; Session["port"] = port; Session["timeSave"] = time; Session["duration"] = duration; Session["file_save"] = file; return(View("saveFlightInfo")); }