예제 #1
0
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 = dict()

    for name in ['Phi', 'Focus', 'PhiZ', 'PhiY', 'Zoom', 'BackLightSwitch','BackLight','FrontLightSwitch', 'FrontLight','Sampx', 'Sampy']:
        motors_info.update(Utils.get_movable_state_and_position(name))

    motors_info['pixelsPerMm'] = mxcube.diffractometer.get_pixels_per_mm()

    aux = {}
    for p in mxcube.diffractometer.savedCentredPos:
            aux.update({p['posId']:p})

    ## 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))

    try:
        msg = { "message": sender +':'+signal, "severity": 'INFO', "timestamp":time.asctime(), "logger":'HWR', "stack_trace":'' }
        socketio.emit('log_record', msg, namespace='/logging')
    except Exception:
        logging.getLogger("HWR").error('error sending message: %s'+str(msg))
예제 #2
0
        def state_cb(state, motor=motor, **kw):
            movable = Utils.get_movable_state_and_position(motor)

            if movable:
                signals.motor_state_callback(movable[motor], **kw)
            else:
                logging.getLogger('HWR').exception("Could not call state callback for %s" % motor)
예제 #3
0
        def state_cb(state, motor=motor, **kw):
            movable = Utils.get_movable_state_and_position(motor)

            if movable:
                signals.motor_state_callback(movable[motor], **kw)
            else:
                logging.getLogger('HWR').exception(
                    "Could not call state callback for %s" % motor)
예제 #4
0
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
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
 def state_cb(state, motor=motor, **kw):
     movable = Utils.get_movable_state_and_position(motor)
     signals.motor_state_callback(movable[motor], **kw)
     signals.motor_state_callback(movable[motor + "Switch"], **kw)
예제 #8
0
 def state_cb(state, motor=motor, **kw):
     movable = Utils.get_movable_state_and_position(motor)
     signals.motor_state_callback(movable[motor], **kw)
     signals.motor_state_callback(movable[motor + "Switch"], **kw)