Exemplo n.º 1
0
	def run(self):
		while not self.stop:
			try:
				self.lrf.monitor_event.wait(1)
				if self.lrf.monitor_event.isSet():
					objects = self.lrf.check_for_obj()
					if objects != []:
						log.debug("LRF Detected Object(s): %s" % str(objects))
						events.triggerEvent('LRF Detected Object', objects)
						self.lrf.monitor_event.clear()
			except Exception as e:
				log.error("Recieved Exception in thread %s: %s" % (self.name, e))
		return
	def notify(self, return_code, msg):
		# Handel the messge
		if return_code == 'Micro Switch Triggered':
			log.debug("Micro switch depressed.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Start Button Pressed':
			log.info("Start Button depressed.")
			self.stop_program = True
			self.start_button_event.set()
		else:
			self.object = return_code
			self.msg = msg
			self.obj_detected.set()
	def notify(self, return_code, msg):
		# Handel the messge
		if return_code == 'Angle: ':
			# Angle returned
			log.debug("Current Angle: %s", msg[2:])
			self.angle = int(msg[2:])
			self.angle_got.set()
		elif return_code == 'Left':
			log.debug("Angle change completed in the LEFT direction.")
			if not self.passive:
				self.direction = 'Left'
				self.angle_reached.set()
			else:
				events.triggerEvent(return_code, msg)
		elif return_code == 'Right':
			log.debug("Angle change completed in the RIGHT direction.")
			if not self.passive:
				self.direction = 'Right'
				self.angle_reached.set()
			else:
				events.triggerEvent(return_code, msg)
		else:
			log.error("Error in handeling notifications.")
	def notify(self, return_code, msg):
		# Handel the messge
		if return_code == 'Left':
			log.debug("Antenna array indicates we are LEFT of the line.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Right':
			log.debug("Antenna array indicates we are RIGHT of the line.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Dead On':
			log.debug("Antenna array indicates we are DEAD ON the line.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'No Line':
			log.debug("Antenna array indicates NO LINE is detected.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'On Corner':
			log.debug("Antenna array indicates we are ON the CORNER.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Left Back':
			log.debug("Antenna array indicates the line is near the LEFT BACK of the robot.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Right Back':
			log.debug("Antenna array indicates the line is near the RIGHT BACK of the robot.")
			events.triggerEvent(return_code, msg)
		elif return_code == 'Right Front':
			log.debug("Antenna array indicates the line is near the RIGHT FRONT of the robot.")
			events.triggerEvent(return_code, msg)