示例#1
0
    def unload(self, products, warehouse):
        if not self.is_waiting:
            counted_products = Counter(products)
            if not(self.warehouse == warehouse):
                self.move(warehouse)

            warehouse.addProducts(counted_products)
            OrderWriter.write([self.id, "U", warehouse.id, OrderWriter.products_to_string(counted_products)])
示例#2
0
    def deliver(self, order):
        if not self.is_waiting:
            self.products.subtract(order.products)
            # something for indicating the order is finished

            OrderWriter.write([
                self.id, "D", order.id,
                OrderWriter.products_to_string(order.products)
            ])
示例#3
0
    def unload(self, products, warehouse):
        if not self.is_waiting:
            counted_products = Counter(products)
            if not (self.warehouse == warehouse):
                self.move(warehouse)

            warehouse.addProducts(counted_products)
            OrderWriter.write([
                self.id, "U", warehouse.id,
                OrderWriter.products_to_string(counted_products)
            ])
示例#4
0
    def load(self, products, warehouse):
        if not self.is_waiting:
            counted_products = Counter(products)

            if not(self.warehouse == warehouse):
                self.move(warehouse)

            total_weight = 0
            for product in counted_products:
                total_weight += product.weight

            if total_weight <= self.max_load - self.current_load:
                warehouse.removeProducts(counted_products)
                OrderWriter.write([self.id, "L", warehouse.id, OrderWriter.products_to_string(counted_products)])
示例#5
0
    def load(self, products, warehouse):
        if not self.is_waiting:
            counted_products = Counter(products)

            if not (self.warehouse == warehouse):
                self.move(warehouse)

            total_weight = 0
            for product in counted_products:
                total_weight += product.weight

            if total_weight <= self.max_load - self.current_load:
                warehouse.removeProducts(counted_products)
                OrderWriter.write([
                    self.id, "L", warehouse.id,
                    OrderWriter.products_to_string(counted_products)
                ])
示例#6
0
    def deliver(self, order):
        if not self.is_waiting:
            self.products.subtract(order.products)
            # something for indicating the order is finished

            OrderWriter.write([self.id, "D", order.id, OrderWriter.products_to_string(order.products)])