//------------------------------------------------------- //Methods //public void SerializeRunData() //{ // Run run = new Run(); // run.StartTime = StartTime; // run.ElapsedTime = stopwatch.Elapsed.TotalSeconds; // run.Distance = Distance; // run.PaceGoal = PaceGoal; // run.PaceActual = PaceActual; // run.Locations = Locations; // //now serialize to json file // string output = JsonConvert.SerializeObject(run); // Console.WriteLine(output); //} public async Task StartRun() { while (!IsDone) { await GetElapsedTimeAsync(); await GetLocationAsync(); await SpeakNowRunnerPromptAsync(); } if (IsDone) { //get final stats DistanceInMiles += GPSLocation.CalcDistance( Locations[Locations.Count - 1], Locations[Locations.Count - 2]); PaceActual = (stopwatch.Elapsed.TotalSeconds / 60) / DistanceInMiles; DispElapsedTime = ($"{stopwatch.Elapsed.Minutes.ToString("0")}:{stopwatch.Elapsed.Seconds.ToString("00")}"); } }
public async Task GetLocationAsync() { if ((stopwatch.Elapsed.TotalSeconds / _nextGPSReading) >= 1.0) { GPSCoordinate coordinates = await GPSLocation.GetCoordinatesAsync(stopwatch.Elapsed.TotalSeconds); Locations.Add(coordinates); if (Locations.Count > 1) { DistanceInMiles += GPSLocation.CalcDistance(Locations[Locations.Count - 1], Locations[Locations.Count - 2]); if (DistanceInMiles > .3) { PaceActual = (stopwatch.Elapsed.TotalSeconds / 60) / DistanceInMiles; } } _nextGPSReading += _gpsIntervalInSec; } }