public static Dictionary<DayOfWeek, double> AverageTripDistancePerDay()
        {
            Dictionary<DayOfWeek, double> distancePerDay = new Dictionary<DayOfWeek, double>();
            distancePerDay.Add(DayOfWeek.Monday, 0);
            distancePerDay.Add(DayOfWeek.Tuesday, 0);
            distancePerDay.Add(DayOfWeek.Wednesday, 0);
            distancePerDay.Add(DayOfWeek.Thursday, 0);
            distancePerDay.Add(DayOfWeek.Friday, 0);
            distancePerDay.Add(DayOfWeek.Saturday, 0);
            distancePerDay.Add(DayOfWeek.Sunday, 0);

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            Int64 tripCount = dbc.GetTripCount();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                Dictionary<DayOfWeek, double> carData = WeekdayStatistics.Distance(carId);
                foreach (KeyValuePair<DayOfWeek, double> entry in carData) {
                    distancePerDay[entry.Key] += entry.Value;
                }
            }

            foreach (KeyValuePair<DayOfWeek, double> day in distancePerDay) {
                distancePerDay[day.Key] /= tripCount;
            }

            return distancePerDay;
        }
        public static Dictionary<DayOfWeek, TimeSpan> AverageTripTimePerDay()
        {
            Dictionary<DayOfWeek, TimeSpan> timePerDay = new Dictionary<DayOfWeek, TimeSpan>();
            timePerDay.Add(DayOfWeek.Monday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Tuesday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Wednesday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Thursday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Friday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Saturday, new TimeSpan(0, 0, 0));
            timePerDay.Add(DayOfWeek.Sunday, new TimeSpan(0, 0, 0));

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            Int64 tripCount = dbc.GetTripCount();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                Dictionary<DayOfWeek, TimeSpan> carData = WeekdayStatistics.Time(carId);
                foreach (KeyValuePair<DayOfWeek, TimeSpan> entry in carData) {
                    timePerDay[entry.Key] += entry.Value;
                }
            }

            foreach (KeyValuePair<DayOfWeek, TimeSpan> day in timePerDay) {
                timePerDay[day.Key] = new TimeSpan(timePerDay[day.Key].Ticks / carIds.Count);
            }

            return timePerDay;
        }
Ejemplo n.º 3
0
        public static double AverageTotalDistance()
        {
            double totalDistance = 0;

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                totalDistance += CarStatistics.TotalDistance(carId);
            }

            return totalDistance / carIds.Count;
        }
Ejemplo n.º 4
0
        public static TimeSpan AverageTotalTime()
        {
            TimeSpan totalTime = new TimeSpan(0, 0, 0);

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                totalTime += CarStatistics.TotalTime(carId);
            }

            return new TimeSpan(totalTime.Ticks / carIds.Count);
        }
        public static double AveragePercentageDistanceAbove(double ignorableSpeed, TimeSpan ignorableTime, double ignorableDistance)
        {
            double totalDistanceAbove = 0;
            double totalDistanceBelow = 0;
            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();

            foreach (Int16 carId in carIds) {
                List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
                foreach (Int64 tripId in tripIds) {
                    totalDistanceAbove += SpeedingStatistics.DistanceAbove(carId, tripId, ignorableSpeed, ignorableTime, ignorableDistance);
                    totalDistanceBelow += SpeedingStatistics.DistanceBelow(carId, tripId, ignorableSpeed, ignorableTime, ignorableDistance);
                }
            }

            dbc.Close();
            return totalDistanceAbove / (totalDistanceAbove + totalDistanceBelow) * 100;
        }
        public static double AveragePercentageTimeAbove(double ignorableSpeed, TimeSpan ignorableTime, double ignorableDistance)
        {
            TimeSpan totalTimeAbove = new TimeSpan(0, 0, 0);
            TimeSpan totalTimeBelow = new TimeSpan(0, 0, 0);
            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();

            foreach (Int16 carId in carIds) {
                List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
                foreach (Int64 tripId in tripIds) {
                    totalTimeAbove += SpeedingStatistics.TimeAbove(carId, tripId, ignorableSpeed, ignorableTime, ignorableDistance);
                    totalTimeBelow += SpeedingStatistics.TimeBelow(carId, tripId, ignorableSpeed, ignorableTime, ignorableDistance);
                }
            }

            dbc.Close();
            return totalTimeAbove.Ticks / (totalTimeAbove.Ticks + totalTimeBelow.Ticks) * 100;
        }
        public static double AverageTripDistance()
        {
            double totalDistance = 0;

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            Int64 tripCount = dbc.GetTripCount();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                List<double> distancePerTrip = CarStatistics.DistancePerTrip(carId);
                foreach (double distance in distancePerTrip) {
                    totalDistance += distance;
                }
            }

            return totalDistance / tripCount;
        }
        public static TimeSpan AverageTripTime()
        {
            TimeSpan totalTime = new TimeSpan(0, 0, 0);

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();
            Int64 tripCount = dbc.GetTripCount();
            dbc.Close();

            foreach (Int16 carId in carIds) {
                List<TimeSpan> timePerTrip = CarStatistics.TimePerTrip(carId);
                foreach (TimeSpan time in timePerTrip) {
                    totalTime += time;
                }
            }

            return new TimeSpan(totalTime.Ticks / carIds.Count);
        }
        public static double AveragePercentageDistanceAboveInThreshold(double lowerPercentage, double upperPercentage, double ignorableSpeed, TimeSpan ignorableTime, double ignorableDistance)
        {
            List<double> percentages = new List<double>();

            DBController dbc = new DBController();
            List<Int16> carIds = dbc.GetCarIds();

            foreach (Int16 carId in carIds) {
                List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
                foreach (Int64 tripId in tripIds) {
                    percentages.Add(SpeedingStatistics.PercentageDistanceAboveInThreshold(carId, tripId, lowerPercentage, upperPercentage, ignorableSpeed, ignorableTime, ignorableDistance));
                }
            }

            double totalPercentage = 0;
            foreach (double percentage in percentages) {
                totalPercentage += percentage;
            }

            dbc.Close();
            return totalPercentage / percentages.Count;
        }