Example #1
0
        public const string SCENARIO_FILE = "~/App_Data/{0}.txt";           // The Path of the Secnario

        /// <summary>
        /// The displaySavedSimulation function gets as parameters a string filename and int time
        /// and returns the View which displays the simulation saved in the file with the filename name in the App_Data Folder
        /// Each Step In time Intervals.
        /// </summary>
        /// <param name="filename">string filename of the file to display.</param>
        /// <param name="time">int time intervals for the animation.</param>
        /// <returns>returns the View which displays the simulation saved in the file with the filename name in the App_Data Folder
        /// Each Step In time Intervals.</returns>
        public ActionResult displaySavedSimulation(string filename, int time)
        {
            if (Session["sc"] != null)
            {
                SimulatorCommunicator scs = Session["sc"] as SimulatorCommunicator;
                if (scs != null)
                {
                    scs.close();
                }
            }
            ViewBag.filename          = filename;
            ViewBag.time              = time;
            ViewBag.isSavedSimulation = true;
            return(View());
        }
Example #2
0
        /*public ActionResult display(string ip, int port)
         * {
         *  ViewBag.ip = ip;
         *  ViewBag.port = port;
         *  ViewBag.time = null;
         *  return View();
         * }*/

        /// <summary>
        /// The displayIP Function which gets as parameters a string ip, int port, int time.
        /// It returns the View Of the request.
        /// </summary>
        /// <param name="ip">string ip of the request.</param>
        /// <param name="port">int port of the request.</param>
        /// <param name="time">int time of the request.</param>
        /// <returns>The View Of the request.</returns>
        public ActionResult displayIP(string ip, int port, int?time)
        {
            if (Session["sc"] != null)
            {
                SimulatorCommunicator scs = Session["sc"] as SimulatorCommunicator;
                if (scs != null)
                {
                    scs.close();
                }
            }
            SimulatorCommunicator sc = new SimulatorCommunicator(ip, port);

            Session["sc"] = sc;
            ViewBag.time  = time;
            return(View());
        }
Example #3
0
 public string GetPlaneData()
 {
     if (Session["sc"] == null)
     {
         return(null);
     }
     else
     {
         SimulatorCommunicator sc = Session["sc"] as SimulatorCommunicator;
         if (sc == null)
         {
             return(null);
         }
         else
         {
             PlaneDataModel pdm = new PlaneDataModel(sc.GetLatitude(), sc.GetLongitude());
             return(ToXML(pdm));
         }
     }
 }
Example #4
0
        /// <summary>
        /// The save Function which handles the save request.
        /// It gets as parameters a string ip, int port, int time, int timer and string filename.
        /// And returns the View which saves the animation from the simulator which is in the IP ip
        /// and port port in the intervals time for timer seconds in a file in the App_Data Relative Folder
        /// with the name filename.
        /// </summary>
        /// <param name="ip">string ip</param>
        /// <param name="port">int port</param>
        /// <param name="time">int time</param>
        /// <param name="timer">int timer</param>
        /// <param name="filename">string filename</param>
        /// <returns>returns the View which saves the animation from the simulator which is in the IP ip
        /// and port port in the intervals time for timer seconds in a file in the App_Data Relative Folder
        /// with the name filename.</returns>
        public ActionResult save(string ip, int port, int time, int timer, string filename)
        {
            ViewBag.time     = time;
            ViewBag.timer    = timer;
            ViewBag.filename = filename;
            string filepath = System.Web.HttpContext.Current.Server.MapPath(String.Format(SCENARIO_FILE, filename));

            // System.IO.File.WriteAllText(filepath, "");
            if (Session["sc"] != null)
            {
                SimulatorCommunicator scs = Session["sc"] as SimulatorCommunicator;
                if (scs != null)
                {
                    scs.close();
                }
            }
            SimulatorCommunicator sc = new SimulatorCommunicator(ip, port);

            Session["sc"] = sc;

            return(View());
        }