def checkoutCompletedRoom(self, room, assignment_type): # Print checkout on console print "[DatabaseHandler]: Checking out room " + str(room.room_id_) + ", cleaning subtask " + str(assignment_type)\ + ", out of " + str(room.open_cleaning_tasks_) # Add entry into the log log_item = database_classes.LogItem() log_item.room_id_ = room.room_id_ log_item.cleaning_task_ = assignment_type log_item.battery_usage_ = 0 log_item.cleaned_surface_area_ = 0 log_item.date_and_time_ = datetime.now() log_item.found_dirtspots_ = 0 log_item.found_trashcans_ = 0 log_item.log_week_and_day_ = [self.getTodaysWeekType(), self.getTodaysWeekDay()] log_item.room_issues_ = [] log_item.status_ = 0 log_item.trolley_capacity_ = 0 log_item.used_water_amount_ = 0 self.database_.addLogEntry(log_item) # Remove assignment from the room's open assignment list room.open_cleaning_tasks_.remove(assignment_type) # Save current datetime as timestamp for the specified assignment room.room_cleaning_datestamps_[assignment_type + 1] = datetime.now() # Save all changes to the database self.applyChangesToDatabase()
def getLogListFromLogDict(self, dict_settings): log_item_list = [] for log_key in dict_settings: log_item = database_classes.LogItem() log_item.cleaned_surface_area_ = dict_settings.get(log_key).get( "cleaned_surface_area") log_item.cleaning_task_ = dict_settings.get(log_key).get( "cleaning_task") log_item.date_and_time_ = self.stringToDatetime( dict_settings.get(log_key).get("date_and_time")) log_item.found_dirtspots_ = dict_settings.get(log_key).get( "found_dirtspots") log_item.found_trashcans_ = dict_settings.get(log_key).get( "found_trashcans") log_item.log_week_and_day_ = dict_settings.get(log_key).get( "week_and_day") log_item.room_id_ = dict_settings.get(log_key).get("room_id") log_item.status_ = dict_settings.get(log_key).get("status") log_item.trolley_capacity_ = dict_settings.get(log_key).get( "trolley_capacity") log_item.used_water_amount_ = dict_settings.get(log_key).get( "used_water_amount") log_item.battery_usage_ = dict_settings.get(log_key).get( "battery_usage") log_item_list.append(log_item) return log_item_list
def addLogEntry(self, room_id, status, cleaning_task, found_dirtspots, found_trashcans, cleaned_surface_area, room_issues, used_water_amount, battery_usage): new_entry = database_classes.LogItem() new_entry.room_id_ = room_id new_entry.log_week_and_day_ = [self.getTodaysWeekType(), self.getTodaysWeekDay()] new_entry.date_and_time_ = datetime.datetime.now() new_entry.status_ = status new_entry.cleaning_task_ = cleaning_task new_entry.found_dirtspots_ = found_dirtspots new_entry.found_trashcans_ = found_trashcans new_entry.cleaned_surface_area_ = cleaned_surface_area new_entry.room_issues_ = room_issues new_entry.used_water_amount_ = used_water_amount new_entry.battery_usage_ = battery_usage self.database_.addLogEntry(new_entry)