Beispiel #1
0
class Warehouse(object):
    # The simpy environment is our clock
    def __init__(self, env):
        self.clock = env
        self.floor = Floor(env)
        self.inventory = Inventory(env)
        self.robot_scheduler = RobotScheduler(env)
        self.order_control = OrderControl(env)


    def populateStock(self):
        for item in self.inventory.stock:
            random_sarea = random.choice(self.floor.shelfareas)

            random_shelf = random.choice(random_sarea.areacontents).getContents()
            random_shelf.addItem(item)
            item.changeShelf(random_shelf.getShelfNo())

    def robotRequest(self, robot, destination):
        robotlocation = robot.location

        # Calculate a path from the Robot's current location to requested
        # At some point make this so it doesn't go through Cells containing objects
        path = self.floor.getPath(robotlocation, destination)
        robot.setDestination(path)

        # Moving the robot to location
        # Running moveByOne multiple times to emulate ticks for time being)
        #print(f'Robot needs to move {len(path)} steps')
        for num in range(0, len(robot.getDestination())):
            robot.moveByOne()
        # print("Robot is now at: " + str(robot.getLocation()))

    # Sim Function
    def getItem(self, item):
        print("\nGrabbing Item: ", item, " at tick ", self.clock.now)
        yield self.clock.timeout(2)

    def findItemNameSim(self, item):
        print("Finding", item, "location at tick", self.clock.now)
        yield self.clock.timeout(1)

    def findShelfLocationSim(self, shelf):
        print(f'Finding {shelf} location at tick {self.clock.now}')
        yield self.clock.timeout(1)

    def robotRequestSim(self, robot, destination):
        path = self.floor.getPath(robot.location, destination)
        num_of_steps = len(path)
        print(f'Robot starts moving to location at tick {self.clock.now}')
        print(f'Robot needs to move {len(path)} steps')
        for num in range(0, len(path)):
            yield env.process(self.robotMoveSim(robot, path[num]))
        print(f'Robot is now at {destination}')
        yield self.clock.timeout(1)

    def robotMoveSim(self, robot, nextStep):
        #print(f'Robot moving to {nextStep} at tick {self.clock.now}')
        yield self.clock.timeout(1)

    def robotPickUpSim(self, robot, shelf):
        print(f'Robot picking up {shelf} at tick {self.clock.now}')
        yield self.clock.timeout(1)

    def robotPutDownSim(self, robot, shelf):
        print(f'Robot putting down {shelf} at tick {self.clock.now}')
        yield self.clock.timeout(1)

    def pickerTakeItemSim(self, item, shelf):
        print(f'Picker takes {item} off of shelf {shelf.shelfNumber} at tick {self.clock.now}')
        yield self.clock.timeout(2)