Beispiel #1
0
    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)
Beispiel #2
0
    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()
Beispiel #3
0
	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()
Beispiel #4
0
	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)
Beispiel #5
0
    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
Beispiel #6
0
	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
Beispiel #7
0
    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)
Beispiel #8
0
    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)
Beispiel #9
0
	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)
Beispiel #10
0
	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)
Beispiel #11
0
    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
Beispiel #12
0
	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
Beispiel #13
0
    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)
Beispiel #14
0
	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)
Beispiel #15
0
    def close_door(self):
        """
		Closes door and checking if the elevator should drive
		"""
        io.set_bit(OUTPUT.DOOR_OPEN, 0)
        self.should_drive()
Beispiel #16
0
	def close_door(self):
		"""
		Closes door and checking if the elevator should drive
		"""
		io.set_bit(OUTPUT.DOOR_OPEN, 0)
		self.should_drive()