/// <summary> /// return current fight detail /// </summary> /// <returns></returns> public string GetCurrentFlightDetails() { lock (lockQueue) { //if quque empty or simulation is over, reload data if (fileInfo == null || fileInfo.Count == 0) { LoadFileData(); } FlightDetails currentData = fileInfo.Dequeue(); //return flight data as xml node StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); XmlWriter writer = XmlWriter.Create(sb, settings); writer.WriteStartDocument(); writer.WriteStartElement("infos"); currentData.ToXml(writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); return(sb.ToString()); } }
/// <summary> /// create new FlightDetails with current values from our simulator /// </summary> /// <returns></returns> public string GetValues() { double lat = GetLat(); double lon = GetLon(); double throttle = GetThrottle(); double rudder = GetRudder(); FlightDetails flightDetails = new FlightDetails(lon, lat, throttle, rudder); //notify listeners this.PropertyChanged?.Invoke(this, new FlightDetailsEventArgs(flightDetails)); //create xml node of flight detail StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); XmlWriter writer = XmlWriter.Create(sb, settings); writer.WriteStartDocument(); writer.WriteStartElement("infos"); flightDetails.ToXml(writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); return(sb.ToString()); }