예제 #1
0
        private void GenerateDepartureEvent(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity)
        {
            var startDate     = EternalEntitySet[vehicleEntity].startDate;
            var serviceDate   = DateTime.ParseExact(startDate, "yyyyMMdd", CultureInfo.InvariantCulture);
            var routeId       = EphemeralEntitySet[vehicleEntity].routeId;
            var tripId        = EphemeralEntitySet[vehicleEntity].tripId;
            var stopId        = EternalEntitySet[vehicleEntity].stopId;
            var stopSequence  = EternalEntitySet[vehicleEntity].stopSequence;
            var vehicleId     = vehicleEntity.VehicleId;
            var vehicleLabel  = vehicleEntity.VehicleLabel;
            var eventType     = EventType.DEP;
            var actualTime    = EphemeralEntitySet[vehicleEntity].vehicletimeStamp;
            var fileTimestamp = EphemeralEntitySet[vehicleEntity].fileTimestamp;
            var directionId   = EphemeralEntitySet[vehicleEntity].directionId;
            var newEvent      = new Event(serviceDate,
                                          routeId,
                                          tripId,
                                          stopId,
                                          stopSequence,
                                          vehicleId,
                                          vehicleLabel,
                                          eventType,
                                          actualTime,
                                          fileTimestamp,
                                          directionId);
            var eventString = newEvent.ToString();

            EternalEntitySet[vehicleEntity].departure = 1;
            Log.Info(eventString);
            eventQueue.Enqueue(newEvent);
        }
예제 #2
0
        /// <summary>
        /// It updates the entities in the eternal eneity set with the new values.
        /// Update will depend on the update type that is supplied.
        /// If update type is 1, we completely remove that entity from the set.
        /// If update type is 0, we update that entity with new value.
        /// </summary>
        /// <param name="EphemeralEntitySet"></param>
        /// <param name="vehicleEntity"></param>
        /// <param name="updateType"></param>
        private void UpdateEternalEntitySet(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity, int updateType)
        {
            switch (updateType)
            {
            case 1:
                EternalEntitySet.Remove(vehicleEntity);
                return;

            case 0:
                var e = new Entity(EphemeralEntitySet[vehicleEntity]);
                EternalEntitySet[vehicleEntity] = e;
                break;
            }
        }
예제 #3
0
        private void ProcessStopSequenceChange(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity)
        {
            var currentStatus = EphemeralEntitySet[vehicleEntity].currentStopStatus;

            GenerateDepartureEvent(EphemeralEntitySet, vehicleEntity);
            if (EternalEntitySet[vehicleEntity].departure == 1 && EternalEntitySet[vehicleEntity].arrival == 1)
            {
                UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 1);
            }
            if (VehiclePosition.VehicleStopStatus.StoppedAt.ToString().Equals(currentStatus, StringComparison.OrdinalIgnoreCase))
            {
                UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 0);
                GenerateArrivalEvent(vehicleEntity);
            }
        }
예제 #4
0
 private void ProcessStopStatusChange(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity)
 {
     if (EternalEntitySet[vehicleEntity].departure != 1)
     {
         GenerateDepartureEvent(EphemeralEntitySet, vehicleEntity);
         if (EternalEntitySet[vehicleEntity].departure == 1 && EternalEntitySet[vehicleEntity].arrival == 1)
         {
             UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 1);
         }
     }
 }
예제 #5
0
 private void ProcessTripChange(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity)
 {
     UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 0);
 }
        private void ProcessStopSequenceChange(Dictionary <VehicleEntity, Entity> EphemeralEntitySet, VehicleEntity vehicleEntity)
        {
            var currentStatus = EphemeralEntitySet[vehicleEntity].currentStopStatus;

            GenerateDepartureEvent(EphemeralEntitySet, vehicleEntity);
            if (EternalEntitySet[vehicleEntity].departure == 1 && EternalEntitySet[vehicleEntity].arrival == 1)
            {
                UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 1);
            }
            if (VehicleCurrentStopStatus.STOPPED_AT.ToString().Equals(currentStatus))
            {
                UpdateEternalEntitySet(EphemeralEntitySet, vehicleEntity, 0);
                GenerateArrivalEvent(vehicleEntity);
            }
        }