Exemplo n.º 1
0
        /// <summary>
        /// Save sonars data to XML.
        /// </summary>
        /// <param name="sonarsData">Sonars data.</param>
        /// <param name="fileName">File path.</param>
        public static void SaveXML(DistanceSensorsList sonarsData, string fileName)
        {
            XmlSerializer writer = new XmlSerializer(typeof(DistanceSensorsList));

            using (StreamWriter file = new StreamWriter(fileName))
            {
                writer.Serialize(file, sonarsData);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save sonars data to CSV.
        /// </summary>
        /// <param name="sonarsData">Sonars data.</param>
        /// <param name="fileName">File path.</param>
        public static void SaveCSV(DistanceSensorsList sonarsData, string fileName)
        {
            using (StreamWriter writer = File.CreateText(fileName))
            {
                CsvWriter csv = new CsvWriter(writer);

                for (int degree = 0; degree < sonarsData.Count; degree++)
                {
                    csv.WriteField(degree);
                    csv.WriteField(sonarsData[degree].UltraSonic.ToString().Replace(",", "."));
                    csv.WriteField(sonarsData[degree].Infrared.ToString().Replace(",", "."));
                    csv.NextRecord();
                }
            }
        }