/// <summary> /// Updates the information about this flight /// </summary> /// <param name="data">Flight object to update from</param> public void Update(Flight data) { if(data.Name == this._name) { this._destination = data._destination; this._altitude = data._altitude; this._location = data._location; this._speed = data._speed; } else { throw new Exception("FATAL: Flight objects do not match."); } }
/// <summary> /// Sets the target flight for this command /// </summary> /// <param name="flight">Flight object</param> public void SetFlight(ref Flight flight) { this._flight = flight; }
/// <summary> /// Fetch all flight data from the simulator /// </summary> /// <param name="capture">BrowserCapture object</param> /// <returns>Dictionary containing all flights and their data</returns> public Dictionary<string, Flight> FetchFlights(ref BrowserCapture capture) { Dictionary<string, Flight> flights = new Dictionary<string, Flight>(); // Get list of flights //JSArray rawFlts = new JSArray(capture.FetchRawJSVariable("G_objPlanes")); Dictionary<string, object> rawFlts = (Dictionary<string, object>)capture.FetchRawJSVariable("G_objPlanes"); // Parse into a list foreach(var flt in rawFlts) { // Get key (flight number) string flightNum = flt.Key; // Parse out flight data to ReadOnlyCollection ReadOnlyCollection<object> data = (ReadOnlyCollection<object>) flt.Value; // Convert values to proper types and add new flight to the array string aircraft = Convert.ToString(data[0]); int modelInd = Convert.ToInt32(data[1]); int x = Convert.ToInt32(data[2]); int y = Convert.ToInt32(data[3]); int z = Convert.ToInt32(data[4]); int hdg = Convert.ToInt32(data[5]); int spd = Convert.ToInt32(data[6]); int fltMode = Convert.ToInt32(data[7]); int hdgClr = Convert.ToInt32(data[8]); int altClr = Convert.ToInt32(data[9]); int spdClr = Convert.ToInt32(data[10]); string navClr = Convert.ToString(data[11]); int navClrId = Convert.ToInt32(data[12]); int dest = Convert.ToInt32(data[13]); int lr = Convert.ToInt32(data[14]); int timerSec = Convert.ToInt32(data[15]); char timerMode = Convert.ToChar(data[16]); int expedite = Convert.ToInt32(data[17]); bool conflict = Convert.ToBoolean(data[18]); Waypoint destination = this._env.Waypoints[dest]; Flight newFlt = new Flight( flightNum, this._models[modelInd], (FlightPhase) timerMode, ref destination, z, spd, hdg, x, y ); flights.Add(flightNum, newFlt); } return flights; }