public static Dictionary<DayOfWeek, int> Plots(Int16 carId)
        {
            Dictionary<DayOfWeek, int> plotsPerDay = new Dictionary<DayOfWeek, int>();
            plotsPerDay.Add(DayOfWeek.Monday, 0);
            plotsPerDay.Add(DayOfWeek.Tuesday, 0);
            plotsPerDay.Add(DayOfWeek.Wednesday, 0);
            plotsPerDay.Add(DayOfWeek.Thursday, 0);
            plotsPerDay.Add(DayOfWeek.Friday, 0);
            plotsPerDay.Add(DayOfWeek.Saturday, 0);
            plotsPerDay.Add(DayOfWeek.Sunday, 0);

            //Fetch all timestamps for all trips on car
            DBController dbc = new DBController();
            List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
            List<TemporalInformation> timestamps = new List<TemporalInformation>();
            foreach (Int64 tripId in tripIds) {
                timestamps = dbc.GetTimestampsByCarIdAndTripId(carId, tripId);
            }

            dbc.Close();

            foreach (TemporalInformation timestamp in timestamps) {
                plotsPerDay[timestamp.Timestamp.DayOfWeek] += 1;
            }

            return plotsPerDay;
        }
Exemplo n.º 2
0
        public static TimeSpan Duration(Int16 carId, Int64 tripId)
        {
            DBController dbc = new DBController();
            List<TemporalInformation> timestamps = dbc.GetTimestampsByCarIdAndTripId(carId, tripId);
            dbc.Close();

            return timestamps[timestamps.Count - 1].Timestamp - timestamps[0].Timestamp;
        }
Exemplo n.º 3
0
        public static void GetTimePlot(Int16 carId, Int64 tripId)
        {
            DBController dbc = new DBController();
            List<TemporalInformation> temporalData = dbc.GetTimestampsByCarIdAndTripId(carId, tripId);
            dbc.Close();

            List<TimeSpan> intervals = new List<TimeSpan>();

            for (int i = 1; i < temporalData.Count; i++) {
                TimeSpan interval = temporalData[i].Timestamp - temporalData[i - 1].Timestamp;
                intervals.Add(interval);
            }
        }
        public static Dictionary<DayOfWeek, Dictionary<int, TimeSpan>> TimePerHour(Int16 carId)
        {
            Dictionary<DayOfWeek, Dictionary<int, TimeSpan>> timePerHourPerWeekday = new Dictionary<DayOfWeek, Dictionary<int, TimeSpan>>();
            SetupDay(timePerHourPerWeekday, DayOfWeek.Monday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Tuesday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Wednesday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Thursday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Friday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Saturday);
            SetupDay(timePerHourPerWeekday, DayOfWeek.Sunday);

            DBController dbc = new DBController();
            List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
            dbc.Close();

            foreach (Int64 tripId in tripIds) {
                List<TemporalInformation> entries = dbc.GetTimestampsByCarIdAndTripId(carId, tripId);

                for (int i = 1; i < entries.Count; i++) {
                    timePerHourPerWeekday[entries[i].Timestamp.DayOfWeek][entries[i].Timestamp.Hour] += entries[i].SecondsToLag;
                }
            }
            return timePerHourPerWeekday;
        }