Exemplo n.º 1
0
def _get_dev(dev_type):
    ip = get_ipapi()
    ret = ip.user_ns.get("_" + dev_type)
    if ret is not None:
        return ret
    
    dev_obj_name = '%s_NAME' % dev_type
    # TODO: For Taurus 4 compatibility
    dev_name = "tango://%s" % ip.user_ns[dev_obj_name]
    factory = Factory()
    dev_obj = factory.getDevice(dev_name)
    ip.user_ns[dev_type] = PyTango.DeviceProxy(dev_name) 
    ip.user_ns["_" + dev_type] = dev_obj
    setattr(ip, '_%s' % dev_type, dev_obj)
    return dev_obj
Exemplo n.º 2
0
def _get_dev(dev_type):
    ip = get_ipapi()
    ret = ip.user_ns.get("_" + dev_type)
    if ret is not None:
        return ret

    dev_obj_name = '%s_NAME' % dev_type
    # TODO: For Taurus 4 compatibility
    dev_name = "tango://%s" % ip.user_ns[dev_obj_name]
    factory = Factory()
    dev_obj = factory.getDevice(dev_name)
    ip.user_ns[dev_type] = PyTango.DeviceProxy(dev_name)
    ip.user_ns["_" + dev_type] = dev_obj
    setattr(ip, '_%s' % dev_type, dev_obj)
    return dev_obj
Exemplo n.º 3
0
    def _getValueValidator(self, name):
        """Return the name validator for the mapped model name scheme

        :param name: (str) resource name
        :return: A specific TaurusValidator
        """
        scheme = getSchemeFromName(name)
        f = Factory(scheme)
        if self._elementType == TaurusElementType.Attribute:
            return f.getAttributeNameValidator()
        elif self._elementType == TaurusElementType.Device:
            return f.getDeviceNameValidator()
        elif self._elementType == TaurusElementType.Authority:
            return f.getAuthorityNameValidator()
        else:
            msg = '_elementType must be one of (Authority, Device, Attribute)'
            raise Exception(msg)
Exemplo n.º 4
0
def _get_dev(dev_type):
    spock_config = get_config().Spock
    taurus_dev = None
    taurus_dev_var = "_" + dev_type
    if hasattr(spock_config, taurus_dev_var):
        taurus_dev = getattr(spock_config, taurus_dev_var)
    if taurus_dev is None:
        # TODO: For Taurus 4 compatibility
        dev_name = "tango://%s" % getattr(spock_config, dev_type + '_name')
        factory = Factory()
        taurus_dev = factory.getDevice(dev_name)
        import PyTango
        dev = PyTango.DeviceProxy(dev_name)
        setattr(spock_config, dev_type, dev)
        setattr(spock_config, taurus_dev_var, taurus_dev)
        shell = get_shell()
        dev_type_upper = dev_type.upper()
        shell.user_ns[dev_type_upper] = dev
        shell.user_ns["_" + dev_type_upper] = taurus_dev
    return taurus_dev
Exemplo n.º 5
0
def _get_dev(dev_type):
    spock_config = get_config().Spock
    taurus_dev = None
    taurus_dev_var = "_" + dev_type
    if hasattr(spock_config, taurus_dev_var):
        taurus_dev = getattr(spock_config, taurus_dev_var)
    if taurus_dev is None:
        # TODO: For Taurus 4 compatibility
        dev_name = "tango://%s" % getattr(spock_config, dev_type + '_name')
        factory = Factory()
        taurus_dev = factory.getDevice(dev_name)
        import PyTango
        dev = PyTango.DeviceProxy(dev_name)
        setattr(spock_config, dev_type, dev)
        setattr(spock_config, taurus_dev_var, taurus_dev)
        shell = get_shell()
        dev_type_upper = dev_type.upper()
        shell.user_ns[dev_type_upper] = dev
        shell.user_ns["_" + dev_type_upper] = taurus_dev
    return taurus_dev
Exemplo n.º 6
0
def init_pre_spock(ip, macro_server, door):
    so = IPython.ipstruct.Struct()
    full_door_tg_name, door_tg_name, door_tg_alias = from_name_to_tango(door)
    #macro_server = get_ms_for_door(door_tg_name)
    full_ms_tg_name, ms_tg_name, ms_tg_alias = from_name_to_tango(macro_server)
    ip.user_ns['MACRO_SERVER_NAME'] = full_ms_tg_name
    ip.user_ns['MACRO_SERVER_ALIAS'] = ms_tg_alias or ms_tg_name
    ip.user_ns['DOOR_NAME'] = full_door_tg_name
    ip.user_ns['DOOR_ALIAS'] = door_tg_alias or door_tg_name
    ip.user_ns['DOOR_STATE'] = ""
    ip.user_ns['spock_options'] = so

    if ip.IP.alias_table.has_key('mv'):
        del ip.IP.alias_table['mv']

    v = release.version
    alias = ip.user_ns['DOOR_ALIAS']
    profile = ip.user_ns['PROFILE']

    so.spock_banner = """\
{Blue}Spock's sardana extension %s loaded with profile: %s (linked to door '%s'){Normal}
""" % (v, profile, alias)

    # the CodecFactory is not thread safe. There are two attributes who will
    # request for it in the first event at startup in different threads
    # therefore this small hack: make sure CodecFactory is initialized.
    CodecFactory()

    factory = Factory()

    import sardana.spock.spockms
    macroserver = sardana.spock.spockms

    factory.registerDeviceClass('MacroServer', macroserver.SpockMacroServer)

    mode = get_gui_mode()
    if mode == 'qt':
        factory.registerDeviceClass('Door', macroserver.QSpockDoor)
    else:
        factory.registerDeviceClass('Door', macroserver.SpockDoor)

    door = get_door()
    macro_server = get_macro_server()

    # Initialize the environment
    expose_variable(ENV_NAME, macro_server.getEnvironment())
Exemplo n.º 7
0
def init_taurus():
    # the CodecFactory is not thread safe. There are two attributes who will
    # request for it in the first event at startup in different threads
    # therefore this small hack: make sure CodecFactory is initialized.
    CodecFactory()

    factory = Factory()

    import sardana.spock.spockms
    macroserver = sardana.spock.spockms

    factory.registerDeviceClass('MacroServer', macroserver.SpockMacroServer)

    mode = get_gui_mode()
    if mode == 'qt':
        factory.registerDeviceClass('Door', macroserver.QSpockDoor)
    else:
        factory.registerDeviceClass('Door', macroserver.SpockDoor)
Exemplo n.º 8
0
def init_pre_spock(ip, macro_server, door):
    so = IPython.ipstruct.Struct()
    full_door_tg_name, door_tg_name, door_tg_alias = from_name_to_tango(door)
    #macro_server = get_ms_for_door(door_tg_name)
    full_ms_tg_name, ms_tg_name, ms_tg_alias = from_name_to_tango(macro_server)
    ip.user_ns['MACRO_SERVER_NAME'] = full_ms_tg_name
    ip.user_ns['MACRO_SERVER_ALIAS'] = ms_tg_alias or ms_tg_name
    ip.user_ns['DOOR_NAME'] = full_door_tg_name
    ip.user_ns['DOOR_ALIAS'] = door_tg_alias or door_tg_name
    ip.user_ns['DOOR_STATE'] = ""
    ip.user_ns['spock_options'] = so
    
    if ip.IP.alias_table.has_key('mv'):
        del ip.IP.alias_table['mv']
    
    v = release.version
    alias = ip.user_ns['DOOR_ALIAS']
    profile = ip.user_ns['PROFILE']
    
    so.spock_banner = """\
{Blue}Spock's sardana extension %s loaded with profile: %s (linked to door '%s'){Normal}
""" % (v, profile, alias)

    # the CodecFactory is not thread safe. There are two attributes who will
    # request for it in the first event at startup in different threads
    # therefore this small hack: make sure CodecFactory is initialized.
    CodecFactory()
    
    factory = Factory()

    import sardana.spock.spockms
    macroserver = sardana.spock.spockms

    factory.registerDeviceClass('MacroServer', macroserver.SpockMacroServer)
    
    mode = get_gui_mode()
    if mode == 'qt':
        factory.registerDeviceClass('Door', macroserver.QSpockDoor)
    else:
        factory.registerDeviceClass('Door', macroserver.SpockDoor)
    
    door = get_door()
    macro_server = get_macro_server()
    
    # Initialize the environment
    expose_variable(ENV_NAME, macro_server.getEnvironment())
Exemplo n.º 9
0
def init_taurus():
    # the CodecFactory is not thread safe. There are two attributes who will
    # request for it in the first event at startup in different threads
    # therefore this small hack: make sure CodecFactory is initialized.
    CodecFactory()

    factory = Factory()

    import sardana.spock.spockms
    macroserver = sardana.spock.spockms

    factory.registerDeviceClass('MacroServer', macroserver.SpockMacroServer)

    mode = get_gui_mode()
    if mode == 'qt':
        factory.registerDeviceClass('Door', macroserver.QSpockDoor)
    else:
        factory.registerDeviceClass('Door', macroserver.SpockDoor)