コード例 #1
0
ファイル: Main.py プロジェクト: Mustang01/Elevator
    def __init__(self):
        # hardcode for now
        floors = 5
        # event for when the car moves to a different floor
        # one car for now, more to be added and this will change to a list
        self.car_1_floor_change = Event()

        #button descriptors, will be made to make all the elevator panel
        #buttons in the car.
        button_descriptor_list = []
        for x in range(floors):
            button_name = "button" + str(x)
            button_descriptor_list.append(
                Buttons.ButtonDescriptor(button_name, x))

        #make CallPanels for each floor
        self.call_panels = []
        for x in range(floors):
            call_panel_type = Panels.CallPanelType.ANYMIDDLEFLOOR
            #get the call panel type right, per the floor
            if (x == 0):
                call_panel_type = Panels.CallPanelType.BOTTOMFLOOR
            elif (x == floors - 1):
                call_panel_type = Panels.CallPanelType.TOPFLOOR
            call_panel = Panels.CallPanel(self.car_1_floor_change, x,
                                          call_panel_type)
            call_panel.call += self.elevator_call_received
            self.call_panels.append(call_panel)

        #make a new elevator panel, for the car
        self.elevator_panel = Panels.ElevatorPanel(button_descriptor_list,
                                                   self.car_1_floor_change)
        #make the elevator car
        self.elevator_car = ElevatorCar("Car 1", self.elevator_panel)
        self.elevator_car.floor_changed += self.car_floor_change