Esempio n. 1
0
		elif no_move_time > 240:
			logging.debug('   @Wc_2 no move detected for 3 minutes, stop procedure')
			break
		else:
			time.sleep(0.1)


# Main Loop of the program
while True:
	if  WC2_OCCUPIED == False and gpio.is_wc2_door_closed() and gpio.is_wc2_motion_detected_by_PIR():
		# change state of the wc2 to occupied
		WC2_OCCUPIED = True
		gpio.wc2_led_occupied()
		# SEND REST
		detection_counter += 1
		logging.debug('#Main Thread |  change state of the wc2 (Free --> Occupied) | time:  %s | detection counter: %s', time.strftime("%H:%M:%S"), detection_counter)
		
		# start new thread
		start_thread = time.time()
		t = threading.Thread(target=wc2_worker, args=[])
		t.start()
		t.join()
		
		logging.debug('#Main Thread |  change state of the wc2 (Occupied --> Free) | thread total time(duration):  %.2f  \n\n\n', (time.time() - start_thread))
		GPIO.remove_event_detect(gpio.WC2_DOOR_sensor)
		gpio.wc2_led_free()
		# SEND REST
		WC2_OCCUPIED = False
	else:
		time.sleep(0.1)