Exemplo n.º 1
0
def initialize_bliss(info, db=None):
    shell_info = info['shell_info']
    object_names = info['object_names']
    server_type  = info['server_type']
    server_instance = info['server_instance']
    server_name = server_type + '/' + server_instance

    cfg = beacon_get_config()

    axis_names = []
    for name in object_names:
        obj_cfg = cfg.get_config(name)
        # if tango_server is defined it means it is manually added
        if 'tango_server' in obj_cfg:
            continue
        if obj_cfg.plugin == 'emotion':
            try:
                if name in [x['name'] for x in obj_cfg.parent['axes']]:
                    axis_names.append(name)
            except KeyError:
                continue

    axes, classes = __recreate_axes(server_name, info['manager_device_name'],
                                    axis_names, info['device_map'], db=db)
    return classes
Exemplo n.º 2
0
def initialize_bliss(info, db=None):
    shell_info = info['shell_info']
    object_names = info['object_names']
    server_type = info['server_type']
    server_instance = info['server_instance']
    server_name = server_type + '/' + server_instance

    cfg = beacon_get_config()

    axis_names = []
    for name in object_names:
        obj_cfg = cfg.get_config(name)
        # if tango_server is defined it means it is manually added
        if 'tango_server' in obj_cfg:
            continue
        if obj_cfg.plugin == 'emotion':
            try:
                if name in [x['name'] for x in obj_cfg.parent['axes']]:
                    axis_names.append(name)
            except KeyError:
                continue

    axes, classes = __recreate_axes(server_name,
                                    info['manager_device_name'],
                                    axis_names,
                                    info['device_map'],
                                    db=db)
    return classes
Exemplo n.º 3
0
def test_lima_basler():
    config = beacon_get_config()
    m0 = config.get("bcumot2")
    m0.velocity(360)
    m0.acceleration(720)

    chain = AcquisitionChain()
    nb_points = 4
    emotion_master = SoftwarePositionTriggerMaster(m0,
                                                   0,
                                                   360,
                                                   nb_points,
                                                   time=1)
    tango_host = "lid00limax:20000"
    lima_dev = DeviceProxy("//%s/id00/limaccds/basler_bcu" % tango_host)
    params = {
        "acq_nb_frames": nb_points,
        "acq_expo_time": 10e-3,
        "acq_trigger_mode": "INTERNAL_TRIGGER_MULTI"
    }
    lima_acq_dev = LimaAcquisitionMaster(lima_dev, **params)
    chain.add(emotion_master, lima_acq_dev)

    hdf5_writer = hdf5.Writer(root_path='/tmp')
    toto = Container('test_lima_basler')
    scan = Scan(chain, name='test_acq', parent=toto, writer=hdf5_writer)

    scan.run()
Exemplo n.º 4
0
def get_encoder(encoder_name):
    if BACKEND == 'beacon':
        global BEACON_CONFIG
        if BEACON_CONFIG is None:
            BEACON_CONFIG = beacon_get_config()
        o = BEACON_CONFIG.get(encoder_name)
        if not isinstance(o, Encoder):
            raise AttributeError("'%s` is not an encoder" % encoder_name)
        return o

    try:
        controller_name = CONTROLLER_BY_ENCODER[encoder_name]
    except KeyError:
        raise RuntimeError("no encoder '%s` in config" % encoder_name)
    else:
        try:
            controller = CONTROLLERS[controller_name]
        except KeyError:
            raise RuntimeError("no controller can be found for encoder '%s`" % encoder_name)

    try:
        controller_instance = controller["object"]
    except KeyError:
        raise RuntimeError("could not get controller instance for encoder '%s`" % encoder_name)

    if not controller["initialized"]:
        controller_instance._update_refs()
        controller_instance.initialize()
        controller["initialized"] = True

    encoder = controller_instance.get_encoder(encoder_name)
    
    return encoder
Exemplo n.º 5
0
def get_server_axis_names(instance_name=None):
    if instance_name is None:
        _, instance_name, _ = get_server_info()

    cfg = beacon_get_config()
    result = []
    for item_name in cfg.names_list:
        item_cfg = cfg.get_config(item_name)
        if item_cfg.plugin == 'emotion' and \
                instance_name in item_cfg.get('tango_server', ()):
            result.append(item_name)
    return result
Exemplo n.º 6
0
def get_server_axis_names(instance_name=None):
    if instance_name is None:
        _, instance_name, _ = get_server_info()

    cfg = beacon_get_config()
    result = []
    for item_name in cfg.names_list:
        item_cfg = cfg.get_config(item_name)
        if item_cfg.plugin == 'emotion' and \
                instance_name in item_cfg.get('tango_server', ()):
            result.append(item_name)
    return result
Exemplo n.º 7
0
def get_axis(axis_name):
    """Get axis from loaded configuration or from Beacon

    If needed, instanciates the controller of the axis and initializes it.

    Args:
        axis_name (str):
            Axis name

    Returns:
        :class:`bliss.common.axis.Axis` object

    Raises:
        RuntimeError
    """
    if BACKEND=='beacon':
        global BEACON_CONFIG
        if BEACON_CONFIG is None:
            BEACON_CONFIG = beacon_get_config() 
        o = BEACON_CONFIG.get(axis_name)
        if not isinstance(o, Axis):
            raise AttributeError("'%s` is not an axis" % axis_name)
        return o
 
    try:
        controller_name = CONTROLLER_BY_AXIS[axis_name]
    except KeyError:
        raise RuntimeError("no axis '%s` in config" % axis_name)
    else:
        try:
            controller = CONTROLLERS[controller_name]
        except KeyError:
            raise RuntimeError(
                "no controller can be found for axis '%s`" %
                axis_name)

    try:
        controller_instance = controller["object"]
    except KeyError:
        raise RuntimeError(
            "could not get controller instance for axis '%s`" %
            axis_name)

    if not controller["initialized"]:
        controller_instance._update_refs()
        controller_instance.initialize()
        controller["initialized"] = True

    axis = controller_instance.get_axis(axis_name)
    event.connect(axis, "write_setting", write_setting)

    return axis
Exemplo n.º 8
0
 def _reload(self):
     beacon_get_config().reload()
Exemplo n.º 9
0
 def _reload(self):
     beacon_get_config().reload()
Exemplo n.º 10
0
def test_lima_basler_musst():
    config = beacon_get_config()
    m0 = config.get("bcumot2")
    m0_res = m0.steps_per_unit
    m0_acc = m0.acceleration()
    m0_vel = m0.velocity()
    print "m0_acc: %s, m0_vel: %s" % (m0_acc, m0_vel)
    acc_steps = m0_vel**2 / (2 * m0_acc) + 1.0 / m0_res
    print "acc_steps: %s" % (acc_steps)

    musst_config = config.get("musst")
    musst_dev = musst('musst', musst_config)

    def print_musst_state():
        state_val = musst_dev.STATE
        state_name = [
            s for s, v in musst_dev._string2state.items() if v == state_val
        ][0]
        print "MUSST state: %s [%s]" % (state_name, state_val)

    print_musst_state()
    if musst_dev.STATE == musst_dev.RUN_STATE:
        print "Aborting!"
        musst_dev.ABORT
        while musst_dev.STATE != musst_dev.IDLE_STATE:
            pass
        print_musst_state()

    if musst_dev.get_variable_info('NPAT') == 'ERROR':
        musst_dev.CLEAR
        prog_name = 'id15aeromultiwin.mprg'
        print "Uploading MUSST program: %s ..." % prog_name
        this_dir = os.path.dirname(sys.argv[0])
        musst_prog_fname = os.path.join(this_dir, prog_name)
        musst_prog = ''.join(open(musst_prog_fname).readlines())
        musst_dev.upload_program(musst_prog)
        print " Done!"

    ch1 = musst_dev.get_channel(1)

    def musst_pos():
        return float(ch1.value) / m0_res

    def print_pos():
        print m0.position(), musst_pos()

    start_pos = 0
    final_pos = 360
    nb_pts = 100

    point_size = abs(float(final_pos - start_pos) / nb_pts)
    move_dir = 1 if start_pos < final_pos else -1

    patw = point_size * m0_res
    patwi = int(patw)
    patwf = int((patw - patwi) * 2**31)

    scan_start = start_pos - acc_steps * move_dir

    if m0.position() != scan_start:
        m0.move(scan_start)
    if musst_pos() != scan_start:
        ch1.value = scan_start * m0_res
    print_pos()

    musst_dev.VARINIT
    vals = {
        'SCANCH': 1,
        'E1': start_pos * m0_res,
        'DIR': move_dir,
        'PATW': patwi,
        'PATWF': patwf,
        'NPAT': nb_pts,
        'UPW': patw / 4,
        'DOWNW': patw / 2,
        'NPULSE': 1
    }

    for varname, val in vals.items():
        print "Setting: %s=%s" % (varname, val)
        musst_dev.set_variable(varname, val)
        print '%s=%s' % (varname, musst_dev.get_variable(varname))

    musst_dev.run()
    m0.move(final_pos + acc_steps * move_dir)
    print_pos()
    while musst_dev.STATE != musst_dev.IDLE_STATE:
        pass
    print_musst_state()

    print "retcode: %s" % musst_dev.RETCODE