Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DBController dbc = new DBController();

            List<Trip> trips = dbc.GetAllTrips();

               for(int i = 0; i > trips.Count; i++) {
                GPSFactUpdater.UpdateRawGPS((Int16)trips[i].CarId, trips[i].TripId);
                List<Fact> facts = new List<Fact>();
                facts = dbc.GetFactsByTripId(trips[i].TripId);

                trips[i] = TripFactUpdater.UpdateTripWithCountsAndIntervals(trips[i], facts, dbc);
                dbc.UpdateTripFactWithCounts(trips[i]);
                dbc.UpdateTripFactWithIntervals(trips[i]);
            }

            /*
            List<Trip> trips = dbc.GetTripsByCarId(34);
            Console.WriteLine("AverageTripPercentage:");
            Console.WriteLine(UserProfile.AverageTripPercentage(trips).ToString());
            Console.WriteLine("AverageMetricPercentage:");
            UserProfile.print(UserProfile.AverageMetricPercentage(trips));
            Console.WriteLine("AverageMetricNormalized:");
            UserProfile.print(UserProfile.AverageMetricNormalized(trips));
            Console.WriteLine("AverageMetricDegree:");
            UserProfile.print(UserProfile.AverageMetricDegree(trips));

            Console.WriteLine("CorrelationMatrix:");
            Double[,] matrix = MetricCorrelation.getCorrelationMatrix(trips);
            MetricCorrelation.printMatrix(matrix);
            */
            Console.WriteLine("Aaaaand its done");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void Update(Int16 CarId)
        {
            DBController dbc = new DBController();
            List<Int64> tripIds = dbc.GetTripIdsByCarId(CarId);
            foreach (Int64 tripId in tripIds) {
                List<Fact> facts = dbc.GetFactsByTripId(tripId);
                dbc.UpdateGPSFactWithMeasures(UpdatedFacts(facts));
            }

            dbc.Close();
        }
Ejemplo n.º 3
0
        public static void Update(Int16 carId)
        {
            DBController dbc = new DBController();
            List<Int64> tripIds = dbc.GetTripIdsByCarId(carId);
            List<Fact> facts;
            Trip trip;
            Int64 previousTripId = 0;
            DateTime previousEndTimestamp = new DateTime();

            for (int i = 0; i < tripIds.Count; i++) {
                trip = dbc.GetTripByTripId(tripIds[i]);
                facts = dbc.GetFactsByTripId(tripIds[i]);

                //If a previous trip exists, save ID and the time passed between them
                if (i > 0) {
                    trip.PreviousTripId = previousTripId;
                    trip.SecondsToLag = MeasureCalculator.SecondsToLag(facts[0].Temporal.Timestamp, previousEndTimestamp);
                }

                //Remember variables for next iteration
                previousTripId = trip.TripId;
                previousEndTimestamp = trip.EndTemporal.Timestamp;

                Console.WriteLine("Updating car {0}, trip {1} ({2} facts)", carId, trip.TripId, facts.Count);
                trip = UpdateTrip(trip, facts, dbc);
                trip.OptimalScore = FinalScore.CalculateOptimalScore(trip);
                List<double> fullscores = FinalScore.CalculateTripScores(trip);

                trip.RoadTypeScore = fullscores[0];
                trip.CriticalTimeScore = fullscores[1];
                trip.SpeedingScore = fullscores[2];
                trip.AccelerationScore = fullscores[3];
                trip.BrakeScore = fullscores[4];
                trip.JerkScore = fullscores[5];
                trip.TripScore = fullscores[6];
                dbc.UpdateTripFactWithMeasures(trip);
            }

            dbc.Close();
        }