def create_async_sensor(condition,sensor_id, tipo, portas,db_get_sensor_type): #if (db_get_sensor_type(sensor_id) == None): # this.exit(); # try: if(tipo == "sr04"): id = "("+tipo+" #"+str(sensor_id)+"_e:"+portas["echo"]+"_t:"+portas["trigger"] + ") " try: srf04 = UltrasonicSensorFactory.createSensor("SRF04") srf04.changeSetup(int(portas["echo"]), int(portas["trigger"])) while (True): if (db_get_sensor_type(sensor_id) == None): exit() condition.acquire() srf04.setup() print id + " Capturando dados de distancia " distancia_cm = round(srf04.distance_in_cm(),2) gravar_dados_sensor((sensor_id, distancia_cm, "cm", "Distancia", datetime.datetime.now())) condition.notify() condition.release() time.sleep(SLEEPTIME_DISTANCIA) except Exception, e: pass#print e.getMessage() finally:
def create_async_sensor(condition, sensor_id, tipo, portas, db_get_sensor_type): #if (db_get_sensor_type(sensor_id) == None): # this.exit(); # try: if (tipo == "sr04"): id = "(" + tipo + " #" + str(sensor_id) + "_e:" + portas[ "echo"] + "_t:" + portas["trigger"] + ") " try: srf04 = UltrasonicSensorFactory.createSensor("SRF04") srf04.changeSetup(int(portas["echo"]), int(portas["trigger"])) while (True): if (db_get_sensor_type(sensor_id) == None): exit() condition.acquire() srf04.setup() print id + " Capturando dados de distancia " distancia_cm = round(srf04.distance_in_cm(), 2) gravar_dados_sensor( (sensor_id, distancia_cm, "cm", "Distancia", datetime.datetime.now())) condition.notify() condition.release() time.sleep(SLEEPTIME_DISTANCIA) except Exception, e: pass #print e.getMessage() finally:
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': ping = UltrasonicSensorFactory.createSensor("ParallaxPing") print ("Distance in cm:" + ping.distance_in_cm() + " cm") print ("Distance in inches:" + ping.distance_in_inches() + " in")
(sensor_id, distancia_cm, "cm", "Distancia", datetime.datetime.now())) condition.notify() condition.release() time.sleep(SLEEPTIME_DISTANCIA) except Exception, e: pass #print e.getMessage() finally: print id + 'Fim ' GPIO.cleanup() if (tipo == "sr05"): id = "(" + tipo + " #" + str(sensor_id) + "_e:" + portas[ "echo"] + "_t:" + portas["trigger"] + ") " try: srf05 = UltrasonicSensorFactory.createSensor("SRF05") srf05.changeSetup(int(portas["echo"]), int(portas["trigger"])) while (True): if (db_get_sensor_type(sensor_id) == None): exit() condition.acquire() srf05.setup() print id + "Capturando dados de distancia " distancia_cm = round(srf05.distance_in_cm(), 2) gravar_dados_sensor( (sensor_id, distancia_cm, "cm", "Distancia", datetime.datetime.now())) condition.notify() condition.release() time.sleep(SLEEPTIME_DISTANCIA)
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': srf04 = UltrasonicSensorFactory.createSensor("SRF04") print("Distance in cm:" + srf04.distance_in_cm() + " cm") print("Distance in inches:" + srf04.distance_in_inches() + " in")
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': ping = UltrasonicSensorFactory.createSensor("ParallaxPing") print("Distance in cm:" + ping.distance_in_cm() + " cm") print("Distance in inches:" + ping.distance_in_inches() + " in")
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': urm37 = UltrasonicSensorFactory.createSensor("URM37") print ("Distance in cm:" + urm37.distance_in_cm() + " cm") print ("Distance in inches:" + urm37.distance_in_inches() + " in")
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': srf04 = UltrasonicSensorFactory.createSensor("SRF04") print ("Distance in cm:" + srf04.distance_in_cm() + " cm") print ("Distance in inches:" + srf04.distance_in_inches() + " in")
''' Created on 11/02/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': hysrf05 = UltrasonicSensorFactory.createSensor("HYSRF05") print ("Distance in cm: " + str(hysrf05.distance_in_cm()) + " cm") print ("Distance in inches: " + str(hysrf05.distance_in_inches()) + " in")
''' Created on 18/03/2015 @author: Junior Mascarenhas ''' from concretefactory.ultrasonicSensorFactory import UltrasonicSensorFactory if __name__ == '__main__': urm37 = UltrasonicSensorFactory.createSensor("URM37") print("Distance in cm:" + urm37.distance_in_cm() + " cm") print("Distance in inches:" + urm37.distance_in_inches() + " in")