def motor_event_callback(*args, **kwargs): # logging.getLogger('HWR').debug('[MOTOR CALLBACK]') # logging.getLogger("HWR").debug(kwargs) # logging.getLogger("HWR").debug(args) signal = kwargs['signal'] sender = str(kwargs['sender'].__class__).split('.')[0] motors_info = Utils.get_centring_motors_info() motors_info.update(Utils.get_light_state_and_intensity()) motors_info['pixelsPerMm'] = mxcube.diffractometer.get_pixels_per_mm() aux = {} for pos in mxcube.diffractometer.savedCentredPos: aux.update({pos['posId']: pos}) # sending all motors position/status, and the current centred positions msg = {'Signal': signal, 'Message': signal, 'Motors': motors_info, 'CentredPositions': aux, 'Data': args[0] if len(args) == 1 else args} # logging.getLogger('HWR').debug('[MOTOR CALLBACK] ' + str(msg)) try: socketio.emit('Motors', msg, namespace='/hwr') except Exception: logging.getLogger("HWR").error('error sending message: %s' + str(msg))
def motor_event_callback(*args, **kwargs): # logging.getLogger('HWR').debug('[MOTOR CALLBACK]') # logging.getLogger("HWR").debug(kwargs) # logging.getLogger("HWR").debug(args) signal = kwargs['signal'] sender = str(kwargs['sender'].__class__).split('.')[0] motors_info = Utils.get_centring_motors_info() motors_info.update(Utils.get_light_state_and_intensity()) motors_info['pixelsPerMm'] = mxcube.diffractometer.get_pixels_per_mm() aux = {} for pos in mxcube.diffractometer.savedCentredPos: aux.update({pos['posId']: pos}) # sending all motors position/status, and the current centred positions msg = {'Signal': signal, 'Message': signal, 'Motors': motors_info, 'CentredPositions': aux, 'Data': args[0] if len(args) == 1 else args} # logging.getLogger('HWR').debug('[MOTOR CALLBACK] ' + str(msg)) try: socketio.emit('Motors', msg, namespace='/hwr') except Exception: logging.getLogger("HWR").error('error sending message: %s' + str(msg))
def get_movables_state(): ret = Utils.get_centring_motors_info() ret.update(Utils.get_light_state_and_intensity()) resp = jsonify(ret) resp.status_code = 200 return resp
def get_movables_state(): ret = Utils.get_centring_motors_info() ret.update(Utils.get_light_state_and_intensity()) resp = jsonify(ret) resp.status_code = 200 return resp
def get_movables_state(): ret = {} for movable in ['Phi', 'Focus', 'PhiZ', 'PhiY','Sampx', 'Sampy', 'Zoom']: ret.update(Utils.get_movable_state_and_position(movable)) ret.update(Utils.get_light_state_and_intensity()) resp = jsonify(ret) resp.status_code = 200 return resp
def get_status_of_id(id): """ Get position and status of the given element :parameter id: moveable to get its status, 'Phi', 'Focus', 'PhiZ', 'PhiY', 'Zoom', 'BackLightSwitch','BackLight','FrontLightSwitch', 'FrontLight','Sampx', 'Sampy' :response Content-type: application/json, {motorname: {'Status': status, 'position': position} } :statuscode: 200: no error :statuscode: 409: error """ if 'Light' in id: ret = Utils.get_light_state_and_intensity() else: ret = Utils.get_movable_state_and_position(id) if ret: resp = jsonify(ret) resp.status_code = 200 return resp else: return Response(status=409)
def get_status_of_id(elem_id): """ Get position and status of the given element :parameter id: moveable to get its status, 'Phi', 'Focus', 'PhiZ', 'PhiY', 'Zoom', 'BackLightSwitch','BackLight','FrontLightSwitch', 'FrontLight','Sampx', 'Sampy' :response Content-type: application/json, {motorname: {'Status': status, 'position': position} } :statuscode: 200: no error :statuscode: 409: error """ if 'Light' in elem_id: ret = Utils.get_light_state_and_intensity() else: ret = Utils.get_movable_state_and_position(elem_id) if ret: resp = jsonify(ret) resp.status_code = 200 return resp else: return Response(status=409)