Ejemplo n.º 1
0
 void UpdateMap(TripPoint point, bool updateCamera = true)
 {
     /*18
      * if (map == null)
      *  return;
      * //Get trail position or current potion to move car
      * var latlng = point == null
      *  ? viewModel?.CurrentPosition?.ToLatLng()
      *  : point.ToLatLng();
      * Activity?.RunOnUiThread(() =>
      * {
      *  UpdateCar(latlng);
      *  driveLine?.Remove();
      *  var polyOptions = new PolylineOptions();
      *
      *  if (allPoints == null)
      *  {
      *      allPoints = viewModel.CurrentTrip.Points.ToLatLngs();
      *  }
      *  else if (point != null)
      *  {
      *      allPoints.Add(point.ToLatLng());
      *  }
      *
      *  polyOptions.Add(allPoints.ToArray());
      *
      *  if (!driveLineColor.HasValue)
      *      driveLineColor = new Color(ContextCompat.GetColor(Activity, Resource.Color.recording_accent));
      *
      *  polyOptions.InvokeColor(driveLineColor.Value);
      *  driveLine = map.AddPolyline(polyOptions);
      *  if (updateCamera)
      *      UpdateCamera(latlng);
      * });*/
 }
        void SetupMap()
        {
            if (map == null)
            {
                return;
            }

            if (mapView.Width == 0)
            {
                mapView.PostDelayed(SetupMap, 500);
                return;
            }

            if (viewModel.CurrentTrip.HasSimulatedOBDData)
            {
                var activity = (BaseActivity)Activity;
                activity.SupportActionBar.Title = "Current Trip (Sim OBD)";
            }


            TripPoint start = null;

            if (viewModel.CurrentTrip.Points.Count != 0)
            {
                start = viewModel.CurrentTrip.Points[0];
            }

            UpdateMap(start, false);

            if (start != null)
            {
                UpdateCamera(carMarker.Position);
                AddStartMarker(start.ToLatLng());
            }
        }
Ejemplo n.º 3
0
        void UpdateMap(TripPoint point, bool updateCamera = true)
        {
            if (map == null)
                return;
            //Get trail position or current potion to move car
            var latlng = point == null
                ? viewModel?.CurrentPosition?.ToLatLng()
                : point.ToLatLng();
            Activity?.RunOnUiThread(() =>
            {
                UpdateCar(latlng);
                driveLine?.Remove();
                var polyOptions = new PolylineOptions();

                if (allPoints == null)
                {
                    allPoints = viewModel.CurrentTrip.Points.ToLatLngs();
                }
                else if (point != null)
                {
                    allPoints.Add(point.ToLatLng());
                }

                polyOptions.Add(allPoints.ToArray());

                if (!driveLineColor.HasValue)
                    driveLineColor = new Color(ContextCompat.GetColor(Activity, Resource.Color.recording_accent));

                polyOptions.InvokeColor(driveLineColor.Value);
                driveLine = map.AddPolyline(polyOptions);
                if (updateCamera)
                    UpdateCamera(latlng);
            });
        }
        public async Task <TripPoint> CreateItemAsync(TripPoint item)
        {
            string apiPath = $"api/trips/{item.TripId.ToString()}/trippoints";
            HttpResponseMessage response = await Client.PostAsJsonAsync <TripPoint>(apiPath, item);

            response.EnsureSuccessStatusCode();
            response.Content.Headers.ContentType.MediaType = "application/json";

            item = await response.Content.ReadAsAsync <TripPoint>();

            return(item);
        }
        public async Task <TripPoint> GetItemAsync(TripPoint item)
        {
            //Deviating implemetnation because of complxity of the nested API
            TripPoint           tripPoint = null;
            HttpResponseMessage response  = await Client.GetAsync($"/api/trips/{item.TripId}/trippoints/{item.Id}");

            if (response.IsSuccessStatusCode)
            {
                response.Content.Headers.ContentType.MediaType = "application/json";
                tripPoint = await response.Content.ReadAsAsync <TripPoint>();
            }
            return(tripPoint);
        }
Ejemplo n.º 6
0
        void UpdateTripStatistics(TripPoint point)
        {
            PastTripsDetailViewModel.CurrentPosition = point;
            labelOneTitle.Text = PastTripsDetailViewModel.FuelConsumptionUnits;
            labelOneValue.Text = PastTripsDetailViewModel.FuelConsumption;

            labelTwoTitle.Text = PastTripsDetailViewModel.DistanceUnits;
            labelTwoValue.Text = PastTripsDetailViewModel.Distance;

            labelThreeTitle.Text = "Elapsed Time";
            labelThreeValue.Text = PastTripsDetailViewModel.ElapsedTime;

            labelFourTitle.Text = PastTripsDetailViewModel.SpeedUnits;
            labelFourValue.Text = PastTripsDetailViewModel.Speed;
        }
Ejemplo n.º 7
0
        static void AddTripDetails(Trip trip, int id, double lat, double lng, DateTime timestamp)
        {
            var pt = new TripPoint
            {
                TripId            = id.ToString(),
                Sequence          = id,
                Latitude          = lat,
                Longitude         = lng,
                RecordedTimeStamp = timestamp,
                EngineLoad        = _random.Next(25, 75),
                EngineFuelRate    = _random.Next(19, 25),
                Speed             = _random.Next(30, 60),
                MassFlowRate      = _random.Next(50, 100),
                HasOBDData        = true
            };

            trip.Points.Add(pt);
        }
Ejemplo n.º 8
0
        public async Task SendTripPointToIOTHub(string tripId, string userId, TripPoint tripDataPoint)
        {
            //Note: Each individual trip point is being serialized separately so that it can be sent over as an individual message
            //This is the expected format by the IOT Hub\ML
            var settings = new JsonSerializerSettings {
                ContractResolver = new CustomContractResolver()
            };
            var tripDataPointBlob = JsonConvert.SerializeObject(tripDataPoint, settings);

            var tripBlob = JsonConvert.SerializeObject(
                new
            {
                TripId = tripId,
                UserId = userId
            });

            tripBlob = tripBlob.TrimEnd('}');
            string packagedBlob = $"{tripBlob},\"TripDataPoint\":{tripDataPointBlob}}}";

            if (!CrossConnectivity.Current.IsConnected)
            {
                //If there is no network connection, save in buffer and try again
                Logger.Instance.WriteLine("Unable to push data to IOT Hub - no network connection.");
                await AddTripPointToBuffer(packagedBlob);

                return;
            }

            try
            {
                await iotHub.SendEvent(packagedBlob);
            }
            catch (Exception e)
            {
                //An exception will be thrown if the data isn't received by the IOT Hub; store data in buffer and try again
                Logger.Instance.WriteLine("Unable to send data to IOT Hub: " + e.Message);
                AddTripPointToBuffer(packagedBlob);
            }
        }
Ejemplo n.º 9
0
        public TableAdjustment EditTripPoint(LatticeData <TripPoint, TripPoint> latticeData,
                                             TripPoint tripripPointRow)
        {
            TripPoint tripPoint = _context.TripPoints
                                  .FirstOrDefault(x => x.TripId == tripripPointRow.TripId &&
                                                  x.StationOrder == tripripPointRow.StationOrder);

            ;
            if (tripPoint == null)
            {
                tripPoint = new TripPoint()
                {
                    TripId       = tripripPointRow.TripId,
                    StationOrder = tripripPointRow.StationOrder
                };
                _context.TripPoints.Add(tripPoint);
            }

            try
            {
                tripPoint.DepartureTime = tripripPointRow.DepartureTime;
                tripPoint.ArrivalTime   = tripripPointRow.ArrivalTime;

                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(latticeData.Adjust(x => x
                                          .Message(LatticeMessage.User("failure", "Editing", $"Save exception: {e.Message}"))
                                          ));
            }
            return(latticeData.Adjust(x => x
                                      .UpdateRow(tripripPointRow)
                                      .Message(LatticeMessage.User("success", "Editing", "TripPoint saved"))
                                      ));
        }
Ejemplo n.º 10
0
        public TableAdjustment EditTripPoint(LatticeData <TripPoint, TripPointForRow> latticeData,
                                             TripPointForRow tripPointRow, int tripId)
        {
            TripPoint tripPoint;

            if (tripPointRow.TripId == 0)
            {
                tripPoint = new TripPoint()
                {
                    TripId       = tripId,
                    StationOrder = _context.TripPoints.Where(x => x.TripId == tripId).Select(x => x.StationOrder)
                                   .DefaultIfEmpty(0).Max() + 1
                };
                int routeId = _context.Trips.FirstOrDefault(t => t.TripId == tripId).RouteId;
                if (_context.RoutePoints.Where(rp => rp.RouteId == routeId)
                    .Any(rp => rp.StationOrder == tripPoint.StationOrder))
                {
                    _context.TripPoints.Add(tripPoint);
                }
                else
                {
                    return(latticeData.Adjust(x => x
                                              .Message(LatticeMessage.User("failure", "Editing",
                                                                           "There are not more stationsin the route"))
                                              ));
                }
            }
            else
            {
                tripPoint = _context.TripPoints
                            .FirstOrDefault(x => x.TripId == tripId && x.StationOrder == tripPointRow.StationOrder);
            }

            Delay delay = tripPoint.Delay;

            if (tripPointRow.DelayinMinutes.HasValue && tripPointRow.DelayinMinutes != 0)
            {
                if (delay != null)
                {
                    delay.MinutesDelaySpan = tripPointRow.DelayinMinutes.Value;
                }
                else
                {
                    tripPoint.Delay = new Delay()
                    {
                        TripPoint        = tripPoint,
                        MinutesDelaySpan = tripPointRow.DelayinMinutes.Value
                    };
                }
            }
            else
            {
                if (delay != null)
                {
                    _context.Delays.Remove(delay);
                }
            }

            if (tripPointRow.DepartureTime.HasValue &&
                tripPointRow.ArrivalTime.HasValue &&
                tripPointRow.DepartureTime < tripPointRow.ArrivalTime)
            {
                return(latticeData.Adjust(x => x
                                          .Message(LatticeMessage.User("failure", "Editing",
                                                                       "Depatrure time can not be less then ArrivialTime"))
                                          ));
            }

            if (tripPoint.StationOrder > 1 &&
                tripPointRow.ArrivalTime.HasValue)
            {
                TripPoint previousPoint = _context.TripPoints
                                          .FirstOrDefault(x => x.TripId == tripId && x.StationOrder == tripPoint.StationOrder - 1);
                if (previousPoint != null && tripPointRow.ArrivalTime < previousPoint.DepartureTime)
                {
                    return(latticeData.Adjust(x => x
                                              .Message(LatticeMessage.User("failure", "Editing",
                                                                           "Arrivial time less then previous departure"))
                                              ));
                }
            }

            try
            {
                tripPoint.DepartureTime = tripPointRow.DepartureTime;
                tripPoint.ArrivalTime   = tripPointRow.ArrivalTime;
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(latticeData.Adjust(x => x
                                          .Message(LatticeMessage.User("failure", "Editing", $"Save exception: {e.Message}"))
                                          ));
            }

            tripPointRow.TripId = tripPoint.TripId;
            var mpd = latticeData.Configuration.MapRange(latticeData.Source.Where(tp =>
                                                                                  tp.TripId == tripPoint.TripId && tp.StationOrder == tripPoint.StationOrder));

            return(latticeData.Adjust(x => x.Update(mpd)
                                      .Message(LatticeMessage.User("success", "Editing", "TripPoint saved"))
                                      ));
        }
 public Task <bool> DeleteItemAsync(TripPoint item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        //// GET api/<controller>?email=aaa    Get all points of trip by tourist email
        public List <TripPoint> Get(string email)
        {
            TripPoint point = new TripPoint();

            return(point.GetAllPointsFromSQL(email));
        }
Ejemplo n.º 13
0
        async void Geolocator_PositionChanged(object sender, PositionEventArgs e)
        {
            // Only update the route if we are meant to be recording coordinates
            if (IsRecording)
            {
                var userLocation = e.Position;

                TripPoint previous    = null;
                double    newDistance = 0;
                if (CurrentTrip.Points.Count > 1)
                {
                    previous    = CurrentTrip.Points[CurrentTrip.Points.Count - 1];
                    newDistance = DistanceUtils.CalculateDistance(userLocation.Latitude,
                                                                  userLocation.Longitude, previous.Latitude, previous.Longitude);

                    if (newDistance > 4) // if more than 4 miles then gps is off don't use
                    {
                        return;
                    }
                }

                var point = new TripPoint
                {
                    TripId            = CurrentTrip.Id,
                    RecordedTimeStamp = DateTime.UtcNow,
                    Latitude          = userLocation.Latitude,
                    Longitude         = userLocation.Longitude,
                    Sequence          = CurrentTrip.Points.Count,
                    Speed             = -255,
                    RPM = -255,
                    ShortTermFuelBank        = -255,
                    LongTermFuelBank         = -255,
                    ThrottlePosition         = -255,
                    RelativeThrottlePosition = -255,
                    Runtime = -255,
                    DistanceWithMalfunctionLight = -255,
                    EngineLoad     = -255,
                    MassFlowRate   = -255,
                    EngineFuelRate = -255,
                    VIN            = "-255"
                };

                //Add OBD data
                if (obdDataProcessor != null)
                {
                    point.HasSimulatedOBDData = obdDataProcessor.IsObdDeviceSimulated;
                }
                await AddOBDDataToPoint(point);

                CurrentTrip.Points.Add(point);

                try
                {
                    if (obdDataProcessor != null)
                    {
                        //Push the trip data packaged with the OBD data to the IOT Hub
                        obdDataProcessor.SendTripPointToIOTHub(CurrentTrip.Id, CurrentTrip.UserId, point);
                    }
                }
                catch (Exception ex)
                {
                    //29 Logger.Instance.Report(ex);
                }

                if (CurrentTrip.Points.Count > 1 && previous != null)
                {
                    CurrentTrip.Distance += newDistance;
                    Distance              = CurrentTrip.TotalDistanceNoUnits;

                    //calculate gas usage
                    var timeDif1 = point.RecordedTimeStamp - previous.RecordedTimeStamp;
                    CurrentTrip.FuelUsed += fuelConsumptionRate * 0.00002236413 * timeDif1.TotalSeconds;
                    if (CurrentTrip.FuelUsed == 0)
                    {
                        FuelConsumption = "N/A";
                    }
                    else
                    {
                        //30 FuelConsumption = Settings.MetricUnits ? (CurrentTrip.FuelUsed * 3.7854).ToString("N2") : CurrentTrip.FuelUsed.ToString("N2");
                        FuelConsumption = CurrentTrip.FuelUsed.ToString("N2");
                    }
                }
                else
                {
                    CurrentTrip.FuelUsed = 0;
                    FuelConsumption      = "N/A";
                }

                var timeDif = point.RecordedTimeStamp - CurrentTrip.RecordedTimeStamp;

                //track seconds, minutes, then hours
                if (timeDif.TotalMinutes < 1)
                {
                    ElapsedTime = $"{timeDif.Seconds}s";
                }
                else if (timeDif.TotalHours < 1)
                {
                    ElapsedTime = $"{timeDif.Minutes}m {timeDif.Seconds}s";
                }
                else
                {
                    ElapsedTime = $"{(int)timeDif.TotalHours}h {timeDif.Minutes}m {timeDif.Seconds}s";
                }

                if (point.EngineLoad != -255)
                {
                    EngineLoad = $"{(int)point.EngineLoad}%";
                }

                /*31
                 * FuelConsumptionUnits = Settings.MetricUnits ? "Liters" : "Gallons";
                 * DistanceUnits = Settings.MetricDistance ? "Kilometers" : "Miles";
                 */
                FuelConsumptionUnits = "Gallons";
                DistanceUnits        = "Miles";

                OnPropertyChanged("Stats");
            }

            CurrentPosition = e.Position;
        }
        public async Task CreateTripPoints()
        {
            try
            {
                CurrentTripPoints = new List <TripPoint>();
                DateTime dateTime = DateTime.UtcNow;
                Vin      v        = new Vin()
                {
                    String = string.Empty, Valid = false
                };

                foreach (var tps in TripPointSourceInfo)
                {
                    TripPoint _tripPoint = new TripPoint()
                    {
                        Id                           = Guid.NewGuid().ToString(),
                        TripId                       = new Guid(CurrentTrip.Id),
                        Latitude                     = Convert.ToDouble(tps.Lat),
                        Longitude                    = Convert.ToDouble(tps.Lon),
                        Speed                        = Convert.ToDouble(tps.Speed),
                        RecordedTimeStamp            = Convert.ToDateTime(tps.Recordedtimestamp),
                        Sequence                     = Convert.ToInt32(tps.Sequence),
                        Rpm                          = Convert.ToDouble(tps.Enginerpm),
                        ShortTermFuelBank            = Convert.ToDouble(tps.Shorttermfuelbank),
                        LongTermFuelBank             = Convert.ToDouble(tps.Longtermfuelbank),
                        ThrottlePosition             = Convert.ToDouble(tps.Throttleposition),
                        RelativeThrottlePosition     = Convert.ToDouble(tps.Relativethrottleposition),
                        Runtime                      = Convert.ToDouble(tps.Runtime),
                        DistanceWithMalfunctionLight = Convert.ToDouble(tps.Distancewithmil),
                        EngineLoad                   = Convert.ToDouble(tps.Engineload),
                        //MassFlowRate = Convert.ToDouble(tps.Mafflowrate),
                        EngineFuelRate = Convert.ToDouble(tps.Enginefuelrate),
                        Vin            = v,
                        CreatedAt      = dateTime.AddTicks(-1 * dateTime.Ticks % 10000),
                        UpdatedAt      = dateTime.AddTicks(-1 * dateTime.Ticks % 10000)
                    };
                    CurrentTripPoints.Add(_tripPoint);
                }

                //Update Time Stamps to current date and times before sending to IOT Hub
                UpdateTripPointTimeStamps(CurrentTrip);
                foreach (TripPoint tripPoint in CurrentTripPoints)
                {
                    try
                    {
                        await tripPointStore.CreateItemAsync(tripPoint);
                    }
                    catch (Exception)
                    {
                        throw new Exception($"Could not update Trip Time Stamps from Samples at {DateTime.Now.ToString()}.");
                    }

                    //Console.WriteLine($"Processing Sequence No: {tripPoint.Sequence} on Thread : {Thread.CurrentThread.ManagedThreadId}");
                }

                //Parallel.ForEach(CurrentTripPoints, tripPoint =>
                //{
                //    tripPointStore.CreateItemAsync(tripPoint);
                //    Console.WriteLine($"Processing Sequence No: {tripPoint.Sequence} on Thread : {Thread.CurrentThread.ManagedThreadId}");

                //});

                //Console.WriteLine("TripPoint Processing Completed");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Could not create/update Trip Points. For more detail see: {ex.Message}.");
            }
        }
Ejemplo n.º 15
0
        async Task AddOBDDataToPoint(TripPoint point)
        {
            //Read data from the OBD device
            point.HasOBDData = false;
            Dictionary <string, string> obdData = null;

            if (obdDataProcessor != null)
            {
                obdData = await obdDataProcessor.ReadOBDData();
            }

            if (obdData != null)
            {
                double speed = -255,
                       rpm   = -255,
                       efr   = -255,
                       el    = -255,
                       stfb  = -255,
                       ltfb  = -255,
                       fr    = -255,
                       tp    = -255,
                       rt    = -255,
                       dis   = -255,
                       rtp   = -255;
                var vin      = String.Empty;

                if (obdData.ContainsKey("el") && !string.IsNullOrWhiteSpace(obdData["el"]))
                {
                    if (!double.TryParse(obdData["el"], out el))
                    {
                        el = -255;
                    }
                }
                if (obdData.ContainsKey("stfb"))
                {
                    double.TryParse(obdData["stfb"], out stfb);
                }
                if (obdData.ContainsKey("ltfb"))
                {
                    double.TryParse(obdData["ltfb"], out ltfb);
                }
                if (obdData.ContainsKey("fr"))
                {
                    double.TryParse(obdData["fr"], out fr);
                    if (fr != -255)
                    {
                        fuelConsumptionRate = fr;
                    }
                }
                if (obdData.ContainsKey("tp"))
                {
                    double.TryParse(obdData["tp"], out tp);
                }
                if (obdData.ContainsKey("rt"))
                {
                    double.TryParse(obdData["rt"], out rt);
                }
                if (obdData.ContainsKey("dis"))
                {
                    double.TryParse(obdData["dis"], out dis);
                }
                if (obdData.ContainsKey("rtp"))
                {
                    double.TryParse(obdData["rtp"], out rtp);
                }
                if (obdData.ContainsKey("spd"))
                {
                    double.TryParse(obdData["spd"], out speed);
                }
                if (obdData.ContainsKey("rpm"))
                {
                    double.TryParse(obdData["rpm"], out rpm);
                }
                if (obdData.ContainsKey("efr") && !string.IsNullOrWhiteSpace(obdData["efr"]))
                {
                    if (!double.TryParse(obdData["efr"], out efr))
                    {
                        efr = -255;
                    }
                }
                else
                {
                    efr = -255;
                }
                if (obdData.ContainsKey("vin"))
                {
                    vin = obdData["vin"];
                }

                point.EngineLoad                   = el;
                point.ShortTermFuelBank            = stfb;
                point.LongTermFuelBank             = ltfb;
                point.MassFlowRate                 = fr;
                point.ThrottlePosition             = tp;
                point.Runtime                      = rt;
                point.DistanceWithMalfunctionLight = dis;
                point.RelativeThrottlePosition     = rtp;
                point.Speed          = speed;
                point.RPM            = rpm;
                point.EngineFuelRate = efr;
                point.VIN            = vin;

#if DEBUG
                foreach (var kvp in obdData)
                {
                    //28 Logger.Instance.Track($"{kvp.Key} {kvp.Value}");
                }
#endif

                point.HasOBDData = true;
            }
        }
Ejemplo n.º 16
0
 public static CLLocationCoordinate2D ToCoordinate(this TripPoint point)
 {
     return(new CLLocationCoordinate2D(point.Latitude, point.Longitude));
 }
Ejemplo n.º 17
0
        async private Task StartStreaming()
        {
            while (true)
            {
                TripPoint previous    = null;
                double    newDistance = 0;
                if (CurrentTrip.Points.Count > 1)
                {
                    previous = CurrentTrip.Points[CurrentTrip.Points.Count - 1];
                    //newDistance = DistanceUtils.CalculateDistance(userLocation.Latitude,
                    //    userLocation.Longitude, previous.Latitude, previous.Longitude);

                    //if (newDistance > 4) // if more than 4 miles then gps is off don't use
                    //    return;
                }

                var point = new TripPoint
                {
                    TripId            = CurrentTrip.Id,
                    RecordedTimeStamp = DateTime.UtcNow,
                    //Latitude = userLocation.Latitude,
                    //Longitude = userLocation.Longitude,
                    Sequence                     = CurrentTrip.Points.Count,
                    Speed                        = -255,
                    RPM                          = -255,
                    ShortTermFuelBank            = -255,
                    LongTermFuelBank             = -255,
                    ThrottlePosition             = -255,
                    RelativeThrottlePosition     = -255,
                    Runtime                      = -255,
                    DistanceWithMalfunctionLight = -255,
                    EngineLoad                   = -255,
                    MassFlowRate                 = -255,
                    EngineFuelRate               = -255,
                    VIN                          = "-255"
                };
                AddOBDDataToPoint(point);

                if (point.RPM > 0)
                {
                    CurrentTrip.Points.Add(point);
                    EventHubRepository.SendToCloudMessagesAsync(new Infrastructure.Models.IoTMessage
                    {
                        Speed             = point.Speed,
                        RPM               = point.RPM,
                        TripId            = point.TripId,
                        RecordedTimeStamp = point.RecordedTimeStamp,
                        FuelConsumption   = FuelConsumption,
                        ElapsedTime       = ElapsedTime
                    });

                    if (CurrentTrip.Points.Count > 1 && previous != null)
                    {
                        RPM   = point.RPM;
                        Speed = point.Speed;
                        CurrentTrip.Distance += newDistance;
                        Distance              = CurrentTrip.TotalDistanceNoUnits;

                        //calculate gas usage
                        var timeDif1 = point.RecordedTimeStamp - previous.RecordedTimeStamp;
                        CurrentTrip.FuelUsed += fuelConsumptionRate * 0.00002236413 * timeDif1.TotalSeconds;
                        if (CurrentTrip.FuelUsed == 0)
                        {
                            FuelConsumption = "N/A";
                        }
                        else
                        {
                            FuelConsumption = (CurrentTrip.FuelUsed * 3.7854).ToString("N2");
                        }
                    }
                    else
                    {
                        CurrentTrip.FuelUsed = 0;
                        FuelConsumption      = "N/A";
                    }

                    var timeDif = point.RecordedTimeStamp - CurrentTrip.RecordedTimeStamp;

                    //track seconds, minutes, then hours
                    if (timeDif.TotalMinutes < 1)
                    {
                        ElapsedTime = $"{timeDif.Seconds}s";
                    }
                    else if (timeDif.TotalHours < 1)
                    {
                        ElapsedTime = $"{timeDif.Minutes}m {timeDif.Seconds}s";
                    }
                    else
                    {
                        ElapsedTime = $"{(int)timeDif.TotalHours}h {timeDif.Minutes}m {timeDif.Seconds}s";
                    }

                    if (point.EngineLoad != -255)
                    {
                        EngineLoad = $"{(int)point.EngineLoad}%";
                    }

                    FuelConsumptionUnits = "Gallons";
                    DistanceUnits        = "Kilometers";
                }
                await Task.Delay(1000);
            }
        }
Ejemplo n.º 18
0
        public List <TripPoint> PutPoint(List <TripPoint> tripPoints)
        {
            TripPoint point = new TripPoint();

            return(point.AddTripToTourist(tripPoints));
        }
Ejemplo n.º 19
0
 public static LatLng ToLatLng(this TripPoint point) => new LatLng(point.Latitude, point.Longitude);