def set_button_light(self, floor, lights, value): """ Sets a button light @input floor, lights, value """ if lights[floor] != -1: io.set_bit(lights[floor], value)
def open_door(self): """ Opens door and fires a thread with callback in x seconds """ self.set_button_light(self.currentFloor, OUTPUT.IN_LIGHTS, 0) io.set_bit(OUTPUT.DOOR_OPEN, 1) self.doorTimer.start()
def drive(self, speed=300): """ Finding direction and starts the elevator """ self.direction = self.find_direction() io.set_bit(OUTPUT.MOTORDIR, self.direction) io.write_analog(OUTPUT.MOTOR, 2048 + 4 * abs(config.SPEED)) self.moving = True
def drive(self, speed=300): """ Finding direction and starts the elevator """ self.direction = self.find_direction() io.set_bit(OUTPUT.MOTORDIR, self.direction) io.write_analog(OUTPUT.MOTOR, 2048+4*abs(config.SPEED)) self.moving = True
def lost_connection(self): """ Called when networkhandler lost connection """ for light in OUTPUT.UP_LIGHTS + OUTPUT.DOWN_LIGHTS: if light != -1: io.set_bit(light, 0) if self.orderQueue.has_orders(): self.orderQueue.delete_all_orders(exclude=ORDERDIR.IN)
def initialize_lights(self): """ Turn of all lights on the panel """ for light in OUTPUT.LIGHTS: if light != -1: io.set_bit(light, 0) for order in self.orderQueue.yield_orders(exclude=(None, )): self.set_button_light(order.floor, OUTPUT.IN_LIGHTS, 1)
def initialize_lights(self): """ Turn of all lights on the panel """ for light in OUTPUT.LIGHTS: if light != -1: io.set_bit(light, 0) for order in self.orderQueue.yield_orders(exclude=(None,)): self.set_button_light(order.floor, OUTPUT.IN_LIGHTS, 1)
def stop_elevator(self): """ Stops the elevator """ if not self.moving: return if self.direction == OUTPUT.MOTOR_UP: io.set_bit(OUTPUT.MOTORDIR, OUTPUT.MOTOR_DOWN) else: io.set_bit(OUTPUT.MOTORDIR, OUTPUT.MOTOR_UP) sleep(0.01) io.write_analog(OUTPUT.MOTOR, 2048) self.moving = False
def set_floor_indicator_light(self): """ Switching the floor indicators @input floor """ if self.currentFloor & 0x01: io.set_bit(OUTPUT.FLOOR_IND1, 1) else: io.set_bit(OUTPUT.FLOOR_IND1, 0) if self.currentFloor & 0x02: io.set_bit(OUTPUT.FLOOR_IND2, 1) else: io.set_bit(OUTPUT.FLOOR_IND2, 0)
def close_door(self): """ Closes door and checking if the elevator should drive """ io.set_bit(OUTPUT.DOOR_OPEN, 0) self.should_drive()