コード例 #1
0
        private async Task <IList <GetTripsResponse> > ShowTrips(GetDongleResponse dongle, LogBookManager logBookManager)
        {
            Console.WriteLine("Attempting to retreive the list of trips");
            var trips = await logBookManager.GetTrips(dongle.Id, start : DateTime.UtcNow.AddDays(-365));

            if (trips == null)
            {
                Console.WriteLine("No trips were found for this device.");
                return(null);
            }
            foreach (var trip in trips)
            {
                Console.WriteLine($"{trip.Id} - {trip.StartDisplay} to {trip.EndDisplay} at {trip.StartTimeUtc.ToLocalTime()}");
            }
            Console.Write("Choose a Trip (use 'all' for all):");
            var input = Console.ReadLine();

            if (string.Equals(input, "all", StringComparison.InvariantCultureIgnoreCase))
            {
                return(trips.ToList());
            }

            foreach (var t in trips)
            {
                if (t.Id.ToString().StartsWith(input))
                {
                    return(new List <GetTripsResponse>()
                    {
                        t
                    });
                }
            }
            return(null);
        }
コード例 #2
0
        public void ExportAlignedTripData(string filename, GetTripsResponse trip, GetDongleResponse dongle, AlignedTripData alignedTripData)
        {
            if (alignedTripData.AlignedDataPoints.Count <= 0)
            {
                return;
            }

            string fileTemplate      = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><name>{name}</name><description>{description}</description><Style id=\"lineColor\"><LineStyle><color>7dff0000</color><width>4</width></LineStyle><PolyStyle><color>7dff0000</color></PolyStyle></Style>{Placemarks}</Document></kml>";
            string placemarkTemplate = "<Placemark><styleUrl>#lineColor</styleUrl><LineString><extrude>1</extrude><tessellate>1</tessellate><coordinates>{LOCATIONS}</coordinates></LineString></Placemark>";

            var item = placemarkTemplate;
            var sb   = new StringBuilder();

            foreach (var a in alignedTripData.AlignedDataPoints.OrderBy(f => f.Timestamp))
            {
                if (a.Position != null && a.Position.Lat != 0 && a.Position.Lon != 0)
                {
                    sb.Append($"{a.Position?.Lon},{a.Position?.Lat},{a.Altitude}\n");
                }
            }
            item = item.Replace("{LOCATIONS}", sb.ToString());

            var full = fileTemplate.Replace("{name}", $"{trip.StartDisplay} to {trip.EndDisplay} at {trip.StartTimeUtc.ToLocalTime().ToString()}");

            full = full.Replace("{description}", $"Distance:{trip.DistanceKm.ToString("00.00")}km<br />Duration:{trip.Duration}<br />Start:{trip.StartDisplay} at {trip.StartTimeUtc.ToLocalTime()}<br />End:{trip.EndDisplay} at {trip.EndTimeUtc.ToLocalTime()}<br />Duration:{trip.Duration}<br />");
            full = full.Replace("{Placemarks}", item);

            System.IO.File.WriteAllText(filename, full);
        }
コード例 #3
0
ファイル: CSVExporter.cs プロジェクト: nothingmn/autopi.net
        public void ExportAlignedTripData(string filename, GetTripsResponse trip, GetDongleResponse dongle, AlignedTripData alignedTripData)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Timestamp,CoolantTemp,EngineLoad,FuelLevel,FuelRate,IntakeTemp,Lat,Lon,Altitude,RpiTemperature,Speed,Voltage,AccelerometerX,AccelerometerY,AccelerometerZ\r\n");
            foreach (var a in alignedTripData.AlignedDataPoints.OrderBy(f => f.Timestamp))
            {
                sb.Append($"{a.Timestamp},{a.CoolantTemp},{a.EngineLoad},{a.FuelLevel},{a.FuelRate},{a.IntakeTemp},{a.Position?.Lat},{a.Position?.Lon},{a.Altitude},{a.RpiTemperature},{a.Speed},{a.Voltage},{a.AccelerometerX},{a.AccelerometerY},{a.AccelerometerZ}\r\n");
            }

            System.IO.File.WriteAllText(filename, sb.ToString());
        }