Пример #1
0
def reg_test():
	register_device(get_local_ip('eth0'), gen_id_val())
Пример #2
0
    #since we can have up to 8 sensors, we check to all 8 ports
    values_dict = {}
    for n in range(0, 8):
        try:
            #print 'checking sensor on %s'%n
            values_dict[n] = device.getSensorValue(n)
        except:
            #print 'no sensor attached to port %s'%n
            values_dict[n] = 'N/A'

    return values_dict


if __name__ == '__main__':
    #get the id_val of the device
    dev_id = gen_id_val()
    device = connect_phidget()
    #We can use a timer thread for this.. just wanted to keep it simple for
    #my own sake.
    while True:
        sleep(3)
        device.setOutputState(0, 0)
        #getting the IP here, don't really need to do this after some recent updates
        ip_addy = get_local_ip('eth0')
        log_info('IP is: %s' % ip_addy)
        register_device(ip_addy, dev_id)
        sensor_data = check_sensors(device)
        log_info(sensor_data)
        response = put_value_change(dev_id, sensor_data, True)
        if response == 0:
            device.setOutputState(0, 1)
Пример #3
0
def reg_test():
    register_device(get_local_ip('eth0'), gen_id_val())
Пример #4
0
def check_sensors(device):
	#since we can have up to 8 sensors, we check to all 8 ports
	values_dict={}
	for n in range(0,8):
		try:
			#print 'checking sensor on %s'%n
			values_dict[n] = device.getSensorValue(n)
		except:
			#print 'no sensor attached to port %s'%n
			values_dict[n] = 'N/A'

	return values_dict

if __name__ == '__main__':
	#get the id_val of the device
	dev_id = gen_id_val()
	device = connect_phidget()
	#We can use a timer thread for this.. just wanted to keep it simple for
	#my own sake.
	while True:
		sleep(3)
		device.setOutputState(0,0)
		#getting the IP here, don't really need to do this after some recent updates
		ip_addy = get_local_ip('eth0')
		log_info('IP is: %s'%ip_addy)		
		register_device(ip_addy,dev_id)
		sensor_data = check_sensors(device)
		log_info(sensor_data)
		response = put_value_change(dev_id,sensor_data,True)
		if response == 0:
			device.setOutputState(0,1)