Exemplo n.º 1
0
 def enterElevator(self, distElevator):
     self.accept(self.elevatorDoneEvent, self.handleElevatorDone)
     self.elevator = Elevator.Elevator(self.fsm.getStateNamed('Elevator'),
                                       self.elevatorDoneEvent, distElevator)
     self.elevator.load()
     self.elevator.enter()
     base.localAvatar.cantLeaveGame = 1
Exemplo n.º 2
0
 def enterElevator(self, distElevator):
     self.accept(self.elevatorDoneEvent, self.handleElevatorDone)
     self.elevator = Elevator.Elevator(self.fsm.getStateNamed('Elevator'),
                                       self.elevatorDoneEvent, distElevator)
     self.elevator.load()
     self.elevator.enter()
     return None
     return None
Exemplo n.º 3
0
 def enterElevator(self, distElevator):
     assert (self.notify.debug('enterElevator()'))
     self.accept(self.elevatorDoneEvent, self.handleElevatorDone)
     self.elevator = Elevator.Elevator(self.fsm.getStateNamed("Elevator"),
                                       self.elevatorDoneEvent, distElevator)
     self.elevator.load()
     self.elevator.enter()
     # Disable leave to pay / set parent password
     base.localAvatar.cantLeaveGame = 1
     return
Exemplo n.º 4
0
    def add_request(self, _from, _to):
        print _to
        tmp = [int(x) for x in _to.split(',')]
        for __to in tmp:
            req = (_from, __to)

            self.info_list.append('from {} to {}'.format(_from, __to))
            Elevator.REQUESTS.append(req)

        self.from_entry.delete(0, END)
        self.to_entry.delete(0, END)

        self.text.configure(state='normal')
        self.text.delete("1.0", END)
        for item in self.info_list:
            self.text.insert("1.0", item+"\n")
        self.text.configure(state='disable')

        Elevator.call(_from, _to)
Exemplo n.º 5
0
    def __init__(self, n_floors, n_elevators, instruction_filename):
        self.elevators = []
        self.requests = []
        self.cleanup = False

        self.instruction_filename = instruction_filename

        self.tick_number = 0
        self.request_id = 0

        for _ in range(n_elevators): 
            self.elevators.append(Elevator(0))
Exemplo n.º 6
0
    def __init__(self, gpioController, config):
        self._gpioController  = gpioController
        self._config = config
        self._elevator = Elevator.Elevator(self._config, self._gpioController)
        self._gripper = Gripper.Gripper(self._gpioController, self._config)
        self._servoRotate = Servo.ServoDS3218_270(self._gpioController, self._config.servo_rotate.gpio)
        self._recordPlayer = RecordPlayer.RecordPlayer(self._gpioController, self._config.record_player.gpio_start, self._config.record_player.gpio_stop, self._config.record_player.gpio_light_barrier)

        self._lock = RLock()
        self._ready = False

        self.ROTATE_0 = self._config.servo_rotate.rotate_0
        self.ROTATE_180 = self._config.servo_rotate.rotate_180

        self.HOME_TO_BASE = self._config.elevator.home_to_base
        self.FLIPPED_DELTA = self._config.elevator.flipped_delta
Exemplo n.º 7
0
def testElevator(opMode, fileName):
    """ module to load data from file and run elevator for testing
    """
    if opMode.lower() != 'a' and opMode.lower() != 'b':
        raise Exception('Incorrect operation node ' + opMode +
                        '. a and b are the only valid modes.')
    else:
        try:
            with open(fileName, 'r') as openFl:
                for trips in openFl.read().splitlines():
                    elevator = Elevator.Elevator(opMode,
                                                 trips.split(':')[0],
                                                 trips.split(':')[1])
        except IOError:
            raise Exception('Could not read file:', openFl)
        except Exception as e:  # catch all errors
            raise Exception(traceback.format_exc())
Exemplo n.º 8
0
 def initialize(people,elevators):
     fileinput.close()
     file=fileinput.input("data.txt") # pull file with data on it
     # assign people to the array with each entry as a line in the file
     for i in file:
         people+=[re.split(',|\n',i)] # split each line at ',' and \n
         # split at \n causes blank element
         if len(people[fileinput.lineno()-1])==4: 
             people[fileinput.lineno()-1].pop(3) # removes blank element
     fileinput.close() # closes file to allow for rerun and rethread
     for i in range(len(people)):
         people[i][0]=float(people[i][0]) # float time
         people[i][1]=int(people[i][1]) # int floors
         people[i][2]=int(people[i][2])
     # if any elevators in list, remove and replace with new elevators
     for i in range(2,-1,-1):
         if i < len(elevators):
             elevators.pop(i)
     for i in range(3):
         elevators += [Elevator.Elevator(4+i,0,[],(width/2-58+43*i),\
                     height,dt,len(people)/people[len(people)-1][0])]
Exemplo n.º 9
0
    def next_scenario(self):


        # Decide the elevator's next direction when it is IDLE
        if len(Elevator.REQUESTS) == 0 and len(Elevator.IN_ELEVATOR) == 0:
            Elevator.DIRECTION = Elevator.IDLE
        elif Elevator.DIRECTION == Elevator.IDLE:
            time.sleep(2)
            if Elevator.has_from_request_from_upper_floor():
                Elevator.DIRECTION = Elevator.UP
            elif Elevator.has_to_request_from_upper_floor():
                Elevator.DIRECTION = Elevator.UP
            elif Elevator.has_from_request_from_lower_floor():
                Elevator.DIRECTION = Elevator.DOWN
            elif Elevator.has_to_request_from_lower_floor():
                Elevator.DIRECTION = Elevator.DOWN

        Elevator.move()

        # Detect if there is anyone wanna embark the elevator on current floor
        if any([req for req in Elevator.REQUESTS if req[0] == Elevator.CURRENT_FLOOR]):
            temp = [req for req in Elevator.REQUESTS if req[0] == Elevator.CURRENT_FLOOR]
            Elevator.REQUESTS = [req for req in Elevator.REQUESTS if req not in temp]
            Elevator.DIRECTION = Elevator.IDLE
            if len(temp) > 0:
                for req in temp:
                    Elevator.IN_ELEVATOR.append(req)

        # Detect if there is anyone wanna disembark the elevator on current floor
        if any([req for req in Elevator.IN_ELEVATOR if req[1] == Elevator.CURRENT_FLOOR]):
            Elevator.DIRECTION = Elevator.IDLE
            Elevator.IN_ELEVATOR = \
                [req for req in Elevator.IN_ELEVATOR if req[1] != Elevator.CURRENT_FLOOR]

        self.set_indicator(Elevator.DIRECTION)
        self.set_right_canvas(Elevator.CURRENT_FLOOR)
        self.after(Ele.REFRESH_RATE, lambda: self.next_scenario())
Exemplo n.º 10
0
count = 2

# %%
ret = start(user, problem, count)
token = ret['token']
print('Token for %s is %s' % (user, token))

# %%
request = oncalls(token)

# %%
print(request)

# %%
requestList = []
elevatorList = [Elevator.Elevator(i) for i in range(2)]
callDict = {}

# %%
Update(request, elevatorList, callDict)

# %%
commandList = []
takenIds = []
for call in callDict.values():
    minDist = math.inf
    elevatorId = None
    for elevator in elevatorList:
        if len(elevator.passengers) > 0 or elevator.id in takenIds:
            continue
Exemplo n.º 11
0
#!/usr/bin/python
import getch
import Elevator as Elevator

print("DiskRobot")

diskElevator = Elevator.Steuerung()

diskElevator.info()

while True:
    print("\ncommands are:")
    print("   f = stepForward")
    print("   b = stepBackward")
    print("   c = calibrate")
    print("   i = info")
    print("   q = quit")
    command = raw_input("command:")

    #quit
    if command == "q":
        diskElevator.dispose()
        break

    #info
    if command == "i":
        diskElevator.info()

    #calibrate
    if command == "c":
        diskElevator.calibrate()
Exemplo n.º 12
0
if savestatus['stage'] == 1:
    save()
    print("As you walk down the hill the rocks beneath your feet collapse,\nyou fall a short distance but suffer no harm. There's just no going back")
    time.sleep(2)
    print("There is a small pond with water, do you want to drink?")
    des = input('Y/N ')
    while des not in "yYnN10" or des == '':
                    print("Invalid input.")
                    des = input('Y/N ')
    if des == 'Y' or des == 'y':
        print("\nThe water doesn't have any taste, but you feel refreshed.\n")
    time.sleep(2)
    print("You continue walking down the cave and stumble upon a bizarre elevator.\nIt is covered in vines, the chamber is illuminated by glowing mushrooms.")
    time.sleep(2)
    # Pending elevator implementation
    Elevator.daElevaturr()
    savestatus['stage'] = 2
    time.sleep(1)


#Puzzle elevator handling
while (savestatus['stage'] > 9 and savestatus['stage'] < 20) or savestatus['stage'] == 2:

    #Main elevator chamber
    if savestatus['stage'] == 2:
        lights = (savestatus['completed'] if savestatus['completed'] < 1 else savestatus['completed'] - 1) 
        print("There are %s button(s) glowing.\n" % (3 - lights))
        #Path to Luis' puzzle
        print("The 4th button is glowing." if savestatus['kpuzzle'] == 3 else "The 4th button is dark.")
        print("The 6th button is glowing." if savestatus['wpuzzle'] == 3 else "The 6th button is dark.")
        print("The 9th button is glowing." if savestatus['rtpuzzle'] == 3 else "The 9th button is dark.")
Exemplo n.º 13
0
from GlobalConfig import GlobalConfig

if __name__ == "__main__":

    config = GlobalConfig()

    with GlobalGPIO.GlobalGPIO() as gpio:
        gripper = Gripper.Gripper(gpio, config)
        gripper.release()
        # sleep(2)
        #   gripper.grip()
        #   sleep(2)
        #    gripper.release()

        elevator = Elevator.Elevator(config, gpio)

        elevator.gotoHome()

        HOME_TO_BASE = 100000
        FLIPPED_DELTA = 18000

        servo_rotate = Servo.ServoDS3218_270(gpio, 17)

        #  gripper.grip()

        ROTATE_0 = 185.5
        ROTATE_180 = 6

        # slowly
Exemplo n.º 14
0
def create_graph(netlist_list, average_over_X_repeats, methods, type, standardOn=True):
    salt = str(randint(0,20000000))
    for net in netlist_list:
        filename = "netlist_" + str(net) +"_" + str(methods) + str(type) + "repeats_is_" + str(average_over_X_repeats) + "salt_is" + salt + ".png"
        textfilename = "netlist_" + str(net) +"_" + str(methods) + str(type) + "repeats_is_" + str(average_over_X_repeats) + "salt_is" + salt + ".txt"
        textfile = open(textfilename, 'w')
        fig, ax = plt.subplots()
        if "ppa" in methods and "elev" in type:
            ppa_results = [None]*average_over_X_repeats
        if "hill" in methods and "elev" in type:
            helev_results = [None]*average_over_X_repeats
        if "decrmut" in methods:
            decrmut_results = [None]*average_over_X_repeats
        if "hill" in methods and "ash" in type:
            ashclimber_results = [None]*average_over_X_repeats
        for method in methods:
            if method == "ppa" and type == "elev":
                #line length plot
                for k in range(average_over_X_repeats):
                    print("generation "+str(k))
                    print("repeat number", k, "of netlist", net)
                    ppa_results[k] = ppa.PPA_data(net)
                ppa_iteration_sizes = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    ppa_iteration_sizes[k] = len(ppa_results[k][0])-1
                ppa_average_lengths = [0]*min(ppa_iteration_sizes)
                for k in range(average_over_X_repeats):
                    for i in range(len(ppa_average_lengths)):
                        ppa_average_lengths[i] += ppa_results[k][0][i]
                ppa_iteration_sizes.sort()
                for k in range(len(ppa_average_lengths)):
                    print("ok")
                    if k == ppa_iteration_sizes[0]:
                        del ppa_iteration_sizes[0]
                        print(ppa_iteration_sizes)
                    ppa_average_lengths[k] = ppa_average_lengths[k]/len(ppa_iteration_sizes)
                ax.plot(ppa_average_lengths, 'b')

                # generation point plot
                ppa_generation_amount = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    ppa_generation_amount[k] = len(ppa_results[k][1])
                ppa_average_generation_points = [0]*max(ppa_generation_amount)
                for k in range(average_over_X_repeats):
                    for i in range(len(ppa_results[k][1])-1):
                        ppa_average_generation_points[i] += ppa_results[k][1][i]
                for i in range(len(ppa_average_generation_points)-1):
                    ppa_average_generation_points[i] = ppa_average_generation_points[i]/average_over_X_repeats
                for xc in ppa_average_generation_points:
                    ax.axvline(x=xc, color='g')

                #earliest/average first constraint satisfaction
                first_constraint_satisfaction_list = []
                for k in range(average_over_X_repeats):
                    first_constraint_satisfaction_list.append(ppa_results[k][2])
                # for earliest use min(...), for average use sum(...)/average_over..
                # ax.axhline(sum(first_constraint_satisfaction_list)/average_over_X_repeats, color='y')

                #data
                best_heights = []
                for k in range(average_over_X_repeats):
                    best_heights.append(ppa_results[k][4])
                best_lengths = []
                for k in range(average_over_X_repeats):
                    best_lengths.append(ppa_results[k][5])
                best_orders = []
                for k in range(average_over_X_repeats):
                    best_orders.append(ppa_results[k][3])
                combined_height_order = []
                for k in range(average_over_X_repeats):
                    combined_height_order.append([best_heights[k], best_orders[k]])
                #sort
                best_lengths, combined_height_order = (list(x) for x in zip(
                    *sorted(zip(best_lengths, combined_height_order),
                            key=lambda pair: pair[0])))
                ppa_first_csa = min(first_constraint_satisfaction_list)
                best_height = combined_height_order[0][0]
                best_order = combined_height_order[0][1]
                best_length = best_lengths[0]
                ppa_text = "for netlist " + str(net) + ", using the plant propagation algorithm + elevator, the constraint was first satisfied at " + str(ppa_first_csa) +"\n" + \
                "the best order is: " + str(best_order) + "\n" + \
                "the best height is: " + str(best_height) + "\n" + \
                "the best length is: " + str(best_length) + "\n"
                textfile.write(ppa_text)

            if method == "ppa" and type == "ash":
                #line length plot
                for k in range(average_over_X_repeats):
                    print("repeat number", k, "of netlist", net)
                    ppa_results[k] = ash.PPA_data(net)
                ppa_iteration_sizes = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    ppa_iteration_sizes[k] = len(ppa_results[k][0])-1
                ppa_average_lengths = [0]*min(ppa_iteration_sizes)
                for k in range(average_over_X_repeats):
                    for i in range(len(ppa_average_lengths)):
                        ppa_average_lengths[i] += ppa_results[k][0][i]
                ppa_iteration_sizes.sort()
                for k in range(len(ppa_average_lengths)):
                    print("ok")
                    if k == ppa_iteration_sizes[0]:
                        del ppa_iteration_sizes[0]
                        print(ppa_iteration_sizes)
                    ppa_average_lengths[k] = ppa_average_lengths[k]/len(ppa_iteration_sizes)
                ax.plot(ppa_average_lengths, 'b')

                # generation point plot
                ppa_generation_amount = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    ppa_generation_amount[k] = len(ppa_results[k][1])
                ppa_average_generation_points = [0]*max(ppa_generation_amount)
                for k in range(average_over_X_repeats):
                    for i in range(len(ppa_results[k][1])-1):
                        ppa_average_generation_points[i] += ppa_results[k][1][i]
                for i in range(len(ppa_average_generation_points)-1):
                    ppa_average_generation_points[i] = ppa_average_generation_points[i]/average_over_X_repeats
                for xc in ppa_average_generation_points:
                    ax.axvline(x=xc, color='g')

                #data
                best_lengths = []
                for k in range(average_over_X_repeats):
                    best_lengths.append(ppa_results[k][4])
                best_orders = []
                for k in range(average_over_X_repeats):
                    best_orders.append(ppa_results[k][3])
                #sort
                best_lengths, best_orders = (list(x) for x in zip(
                    *sorted(zip(best_lengths, best_orders),
                            key=lambda pair: pair[0])))
                best_order = best_orders[0]
                best_length = best_lengths[0]
                ppa_text = "for netlist " + str(net) + ", using the A star heatmap + plant propagation algorithm, \n" + \
                "the best order is: " + str(best_order) + "\n" + \
                "the best length is: " + str(best_length) + "\n"
                textfile.write(ppa_text)

            if method == "hill" and type == "elev":
                for k in range(average_over_X_repeats):
                    helev_results[k] = eh.hill_climber_data(net)
                # line length plot
                iteration_amount = len(helev_results[0][0])-1
                helev_average_lengths = [0]*iteration_amount
                for k in range(average_over_X_repeats):
                    for i in range(len(helev_results[k][0]) - 1):
                        helev_average_lengths[i] += helev_results[k][0][i]
                for k in range(len(helev_average_lengths)):
                    helev_average_lengths[k] = helev_average_lengths[k] / average_over_X_repeats
                ax.plot(helev_average_lengths)


                # earliest/average first constraint satisfaction
                first_constraint_satisfaction_list = []
                for k in range(average_over_X_repeats):
                    first_constraint_satisfaction_list.append(
                        helev_results[k][1])
                # for earliest use min(...), for average use sum(...)/average_over..
                #ax.axhline(sum(
                #    first_constraint_satisfaction_list) / average_over_X_repeats,
                #            color='g')

                # data possibilities
                best_heights = []
                for k in range(average_over_X_repeats):
                    best_heights.append(helev_results[k][3])
                best_lengths = []
                for k in range(average_over_X_repeats):
                    best_lengths.append(helev_results[k][4])
                best_orders = []
                for k in range(average_over_X_repeats):
                    best_orders.append(helev_results[k][2])
                combined_height_order = []
                for k in range(average_over_X_repeats):
                    combined_height_order.append(
                        [best_heights[k], best_orders[k]])
                # sort
                best_lengths, combined_height_order = (list(x) for x in zip(
                    *sorted(zip(best_lengths, combined_height_order),
                            key=lambda pair: pair[0])))
                helev_first_csa = min(first_constraint_satisfaction_list)
                best_height = combined_height_order[0][0]
                best_order = combined_height_order[0][1]
                best_length = best_lengths[0]
                helev_text = "for netlist " + str(
                    net) + ", using the hillclimber + elevator algorithm, the constraint was first satisfied at " + str(
                    helev_first_csa) + "\n" + \
                           "the best order is: " + str(best_order) + "\n" + \
                           "the best height is: " + str(best_height) + "\n" + \
                           "the best length is: " + str(best_length) + "\n"
                textfile.write(helev_text)


            if method == "hill" and type == "ash":
                for k in range(average_over_X_repeats):
                    ashclimber_results[k] = ash.hill_climber_data(net)
                    print("ok")
                # line length plot
                iteration_amount = len(ashclimber_results[0][0])-1
                ashclimber_average_lengths = [0]*iteration_amount
                for k in range(average_over_X_repeats):
                    for i in range(len(ashclimber_results[k][0]) - 1):
                        ashclimber_average_lengths[i] += ashclimber_results[k][0][i]
                for k in range(len(ashclimber_average_lengths)):
                    ashclimber_average_lengths[k] = ashclimber_average_lengths[k] / average_over_X_repeats
                ax.plot(ashclimber_average_lengths)


                # earliest/average first constraint satisfaction
                first_constraint_satisfaction_list = []
                for k in range(average_over_X_repeats):
                    first_constraint_satisfaction_list.append(
                        ashclimber_results[k][1])
                # for earliest use min(...), for average use sum(...)/average_over..
                #ax.axhline(sum(
                #    first_constraint_satisfaction_list) / average_over_X_repeats,
                #            color='g')

                # data possibilities
                best_lengths = []
                for k in range(average_over_X_repeats):
                    best_lengths.append(ashclimber_results[k][2])
                best_orders = []
                for k in range(average_over_X_repeats):
                    best_orders.append(ashclimber_results[k][1])
                # sort
                best_lengths, combined_height_order = (list(x) for x in zip(
                    *sorted(zip(best_lengths, best_orders),
                            key=lambda pair: pair[0])))
                best_order = best_orders[0]
                best_length = best_lengths[0]
                helev_text = "for netlist " + str(
                    net) + ", using the A star heatmap + hillclimber algorithm," + "\n" + \
                           "the best order is: " + str(best_order) + "\n" + \
                           "the best length is: " + str(best_length) + "\n"
                textfile.write(helev_text)


            if method == "decrmut":
                for k in range(average_over_X_repeats):
                    decrmut_results[k] = eh.decreasing_mutations(net)
                #line length plot
                decrmut_iteration_sizes = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    decrmut_iteration_sizes[k] = len(decrmut_results[k][0])-1
                decrmut_average_lengths = [0]*min(decrmut_iteration_sizes)
                for k in range(average_over_X_repeats):
                    for i in range(len(decrmut_average_lengths)):
                        decrmut_average_lengths[i] += decrmut_results[k][0][i]
                decrmut_iteration_sizes.sort()
                for k in range(len(decrmut_average_lengths)-0):
                    while k > decrmut_iteration_sizes[0]:
                        del decrmut_iteration_sizes[0]
                    decrmut_average_lengths[k] = decrmut_average_lengths[k]/len(decrmut_iteration_sizes)
                ax.plot(decrmut_average_lengths)

                # generation point plot
                decrmut_generation_amount = [0]*average_over_X_repeats
                for k in range(average_over_X_repeats):
                    decrmut_generation_amount[k] = len(decrmut_results[k][1])
                decrmut_average_generation_points = [0]*max(decrmut_generation_amount)
                for k in range(average_over_X_repeats):
                    for i in range(len(decrmut_results[k][1])-1):
                        decrmut_average_generation_points[i] += decrmut_results[k][1][i]
                for i in range(len(decrmut_average_generation_points)-1):
                    decrmut_average_generation_points[i] = decrmut_average_generation_points[i]/average_over_X_repeats
                #for xc in decrmut_average_generation_points:
                #    ax.axvline(x=xc, color='c')

                #earliest/average first constraint satisfaction
                first_constraint_satisfaction_list = []
                for k in range(average_over_X_repeats):
                    first_constraint_satisfaction_list.append(decrmut_results[k][2])
                # for earliest use min(...), for average use sum(...)/average_over..
                #ax.axhline(sum(first_constraint_satisfaction_list)/average_over_X_repeats, color='m')

                #data possibilities
                best_heights = []
                for k in range(average_over_X_repeats):
                    best_heights.append(decrmut_results[k][4])
                best_lengths = []
                for k in range(average_over_X_repeats):
                    best_lengths.append(decrmut_results[k][5])
                best_orders = []
                for k in range(average_over_X_repeats):
                    best_orders.append(decrmut_results[k][3])
                combined_height_order = []
                for k in range(average_over_X_repeats):
                    combined_height_order.append([best_heights[k], best_orders[k]])
                #sort
                best_lengths, combined_height_order = (list(x) for x in zip(
                    *sorted(zip(best_lengths, combined_height_order),
                            key=lambda pair: pair[0])))
                decrmut_first_csa = min(first_constraint_satisfaction_list)
                best_height = combined_height_order[0][0]
                best_order = combined_height_order[0][1]
                best_length = best_lengths[0]
                decrmut_text = "for netlist " + str(
                    net) + ", using the decreasing_mutations algorithm, the constraint was first satisfied at " + str(
                    decrmut_first_csa) + "\n" + \
                           "the best order is: " + str(best_order) + "\n" + \
                           "the best height is: " + str(best_height) + "\n" + \
                           "the best length is: " + str(best_length) + "\n"
                textfile.write(decrmut_text)
        if standardOn:
            standard_elevator_solution = el.return_value_elevator(net)
            ax.axhline(standard_elevator_solution[1], color='r')
            standard_solution = standard_elevator_solution[2]
            standard_solution_height = standard_elevator_solution[0]
            repAstarOrder_text = "for netlist " + str(
                net) + ", using the decreasing a* order algorithm" + "\n" + \
                                 "the resulting length is: " + str(
                standard_elevator_solution[1]) + "\n" + \
                                 "the resulting height is: " + str(
                standard_solution_height) + "\n" + \
                                 "the resulting wire order is: " + str(
                standard_solution) + "\n"
            textfile.write(repAstarOrder_text)
        plt.ylabel('length')
        plt.xlabel('iterations')
        fig.savefig(filename)
from Elevator import *
from Floor import *

#The requests are at the same time.
p1 = {'orig': 1, 'dest': 5 }
p2 = {'orig': 2, 'dest': 3 }
p3 = {'orig': 2, 'dest': 4 }
p4 = {'orig': 3, 'dest': 4 }
p5 = {'orig': 3, 'dest': 1 }
p6 = {'orig': 5, 'dest': 1 }

number_of_floors = 5
requests = [p1, p2, p3, p4, p5, p6]
groupings = {}
floors = []
elevator = Elevator(number_of_floors)

#Let us create arbitrary floors
#Assume we have 5 floors
for i in range(1, number_of_floors+1):
    floors.append(Floor(i))

#Register origin requests
for i in requests:
    floors[i['orig']-1].status = True
        
#Group destination requests
for i in requests:
    for key, value in i.items():
        groupings.setdefault(key, []).append(value)
Exemplo n.º 16
0
import sys, os

path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
sys.path.append(path + "/elevator")
sys.path.append(path)

import Elevator, States

elevator = Elevator.Elevator(States.Open())
elevator.close()
elevator.move()
elevator.stop()
elevator.open()

try:
    elevator.move()
except Elevator.IllegalStateTransition as err:
    print("can't change to state " + str(err) + " from state",
          elevator.get_state())

elevator.close()
elevator.move()