Exemplo n.º 1
0
            public void Add(ITrip driverTrip, ExtractPersonalAndTripRecords module)
            {
                var chain     = driverTrip.TripChain;
                var driver    = chain.Person;
                var driverID  = driver.Id;
                int tripIndex = ComputeTripIndex(driverTrip, chain, driver, module);

                // Now that we have our index data see if it already exists
                for (int i = 0; i < _driverRecords.Count; i++)
                {
                    if (_driverRecords[i].DriverID == driverID && _driverRecords[i].DriverTripID == tripIndex)
                    {
                        _driverRecords[i] = new DriverTrip(_driverRecords[i]);
                        return;
                    }
                }
                // If it was not found we need to add a new record
                _driverRecords.Add(new DriverTrip(driverID, tripIndex, 1));
            }
Exemplo n.º 2
0
            public void CreateRecords(BlockingCollection <FacilitatePassengerRecord> queue, int householdID, ITrip passengerTrip, ExtractPersonalAndTripRecords module)
            {
                var chain           = passengerTrip.TripChain;
                var passenger       = chain.Person;
                var passengerId     = passenger.Id;
                var passengerTripId = ComputeTripIndex(passengerTrip, chain, passenger, module);

                foreach (var record in _driverRecords)
                {
                    queue.Add(new FacilitatePassengerRecord(householdID, passengerId, passengerTripId, record.DriverID, record.DriverTripID, record.Count));
                }
            }
Exemplo n.º 3
0
 private static int ComputeTripIndex(ITrip driverTrip, ITripChain chain, ITashaPerson driver, ExtractPersonalAndTripRecords module)
 {
     // If it is not a pure Home -> facilitate passenger -> home tour.
     if (chain.Trips.Count != 1)
     {
         // trips are 1 indexed
         var tripIndex = 1;
         foreach (var tc in driver.TripChains)
         {
             if (tc == chain)
             {
                 tripIndex += tc.Trips.IndexOf(driverTrip);
                 return(tripIndex);
             }
             else
             {
                 tripIndex += tc.Trips.Count;
             }
         }
         throw new XTMFRuntimeException(module, $"In {module.Name} a driver trip that had a real tour was found that was not in the driver's tours!");
     }
     return(-1);
 }