Commit ac26b317 authored by Laurent Claustre's avatar Laurent Claustre

Merge branch '2-update-for-new-bvdata' into 'master'

profile_x/y as bytes

Closes #2

See merge request limagroup/bpm-web!5
parents 662561af 7acb373e
......@@ -8,17 +8,18 @@ import socket
import PyTango
import struct
import sys
import numpy
# patch socket module
socket.socket._bind = socket.socket.bind
def my_socket_bind(self, *args, **kwargs):
self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
return socket.socket._bind(self, *args, **kwargs)
except:
return
#socket.socket._bind = socket.socket.bind
#def my_socket_bind(self, *args, **kwargs):
# self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# try:
# return socket.socket._bind(self, *args, **kwargs)
# except:
# return
socket.socket.bind = my_socket_bind
#socket.socket.bind = my_socket_bind
HOMEPAGE_TITLE = "BPM Monitor"
......@@ -65,14 +66,6 @@ class BVWebserver:
def decode_bvdata(self,evt_bvdata):
"""Callback function from the subscribe_event on bvdata"""
def ListStrToListInt(list_str):
"""Due to the type of the profiles, they are pass as a string. This function is to convert them back"""
list_int_clean=list_str[1:len(list_str)-1].split(',')
list_tuples_int=[]
for i in range(0,len(list_int_clean)):
list_tuples_int.append(int(list_int_clean[i]))
return list_tuples_int
if self.event_counter==0: # To avoid the first subscribe_event callback which result in an error
print "Subscribing to bvdata push event..."
else:
......@@ -83,9 +76,10 @@ class BVWebserver:
(timestamp,framenb,
X,Y,I,maxI,roi_top_x,roi_top_y,
roi_size_getWidth,roi_size_getHeight,
fwhm_x,fwhm_y,list_int_profile_x,list_int_profile_y, jpegData) = struct.unpack(HEADER_FORMAT, bv_data)
profile_x=ListStrToListInt(list_int_profile_x)
profile_y=ListStrToListInt(list_int_profile_y)
fwhm_x,fwhm_y, prof_x, prof_y, jpegData) = struct.unpack(HEADER_FORMAT, bv_data)
profile_x = numpy.frombuffer(prof_x, dtype=numpy.int64).tolist()
profile_y = numpy.frombuffer(prof_y, dtype=numpy.int64).tolist()
self.cameras_running[camera_name][2] = {"framenb" : framenb, "X" : X, "Y" : Y, "I" : I, "fwhm_x" : fwhm_x, "fwhm_y" : fwhm_y, "jpegData" : jpegData, "profile_x" : profile_x, "profile_y" : profile_y}
except AttributeError, TypeError:
print "Subscribe event callback for ", self.cameras_running[camera_name][1], ". Just checking if camera server is alive."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment