Example #1
0
def start_listening_server(port, tcp, udp):

    #create the context
    context = zmq.Context()

    #create the socket
    talker = context.socket(zmq.REP)
    if tcp:
        talker.bind('tcp://*:%s' % port)
    if udp:
        talker.bind('udp://*:%s' % port)
    count = 0
    while True:
        msg = talker.recv()
        #recive_dict = json.loads(msg)

        #device_checkin(msg)
        #print json.loads(msg)
        return_val = device_checkin(json.loads(msg))
        post_value_change(json.loads(msg))
        #talker.send('okay')
        #print msg
        if return_val == 0:
            talker.send('_data_put')
        else:
            talker.send(return_val)
        count += 1
        print count
Example #2
0
def start_listening_server(port, tcp, udp):
	
	#create the context
	context = zmq.Context()
	
	#create the socket
	talker = context.socket(zmq.REP)	
	if tcp:
		talker.bind('tcp://*:%s'%port)
	if udp:
		talker.bind('udp://*:%s'%port)
	count = 0
	while True:
		msg = talker.recv()
		#recive_dict = json.loads(msg)
		
		#device_checkin(msg)
		#print json.loads(msg)
		return_val = device_checkin(json.loads(msg))
		post_value_change(json.loads(msg))
		#talker.send('okay')
		#print msg
		if return_val == 0:
			talker.send('_data_put')
		else:
			talker.send(return_val)
		count +=1
		print count
Example #3
0
    def start_listening_server(port, tcp, udp):

        #create the context
        context = zmq.Context()

        #create the socket
        talker = context.socket(zmq.REP)
        if tcp:
            talker.bind('tcp://*:%s' % port)
        if udp:
            talker.bind('udp://*:%s' % port)
        while True:
            msg = talker.recv()
            #recive_dict = json.loads(msg)

            device_checkin(msg)
            post_value_change(msg)
            talker.send('_data_put')
Example #4
0
	def start_listening_server(port, tcp, udp):

        	#create the context
       		context = zmq.Context()

        	#create the socket
        	talker = context.socket(zmq.REP)
        	if tcp:
                	talker.bind('tcp://*:%s'%port)
        	if udp:
                	talker.bind('udp://*:%s'%port)
        	while True:
                	msg = talker.recv()
                	#recive_dict = json.loads(msg)

                	device_checkin(msg)
                	post_value_change(msg)
                	talker.send('_data_put')
Example #5
0
def value_change():	
	if request.headers['Content-Type'] == 'application/json':
		#We will post the value change here, using
		#the database interface file that has been written				
		json_struct = request.json
		#print json_struct
		#print json.loads(json_struct)
		return_val = device_checkin(json_struct)
		post_value_change(json_struct)
		#print json_struct
		#device_checkin(json_struct)
		if return_val == 0:
			return '_data_put'
		else:
			return return_val
	else:
		return '_data_fail'