def update_vehicle_schedules(self, vehicle_statuses):
     for vehicle_id, vehicle_status in vehicle_statuses.items():
         if vehicle_id not in self.vehicle_schedules:
             self.vehicle_schedules[vehicle_id] = [vehicle_status.schedule]
         else:
             while self.vehicle_schedules[vehicle_id][
                     0].id != vehicle_status.schedule.id:
                 self.vehicle_schedules[vehicle_id].pop(0)
             dif_time = vehicle_status.schedule.period.start - self.vehicle_schedules[
                 vehicle_id][0].period.start
             self.vehicle_schedules[vehicle_id] = \
                 Schedule.get_shifted_schedules(self.vehicle_schedules[vehicle_id], dif_time)
 def update_user_schedules(self, user_statuses):
     for user_id, user_status in user_statuses.items():
         if user_id not in self.user_schedules:
             self.user_schedules[user_id] = [user_status.schedule]
         else:
             while self.user_schedules[user_id][
                     0].id != user_status.schedule.id:
                 self.user_schedules[user_id].pop(0)
             dif_time = user_status.schedule.period.start - self.user_schedules[
                 user_id][0].period.start
             self.user_schedules[user_id] = \
                 Schedule.get_shifted_schedules(self.user_schedules[user_id], dif_time)
Example #3
0
 def get_next_schedules(self, schedules, current_time):
     schedules.pop(0)
     dif_time = current_time - schedules[0].period.start
     schedules = Schedule.get_shifted_schedules(schedules, dif_time)
     self.status.schedule = schedules[0]
     return schedules