import tango import re # ============================================================================= # The following attributes will be populated when first needed. # ============================================================================= # List of attributes tangopath in TDB TDBLIST = [] # List of attributes tangopath in TDB HDBLIST = [] # List of tango devices DEVLIST = [] ############################################################################### ## USEFULL FUNCTION ############################################################################### def searchattr(prx, attr, ignorecase=True): """ Search in a tango device proxy for an attribute name. PARAMETERS ---------- prx: tango.DeviceProxy Proxy to the device. attr: string String to search for. ignorecase: bool Case insensitive. """ if ignorecase: return [a for a in prx.get_attribute_list() if attr.lower() in a.lower()] else: return [a for a in prx.get_attribute_list() if attr in a] def searcharch(attr, db, ignorecase=True): """ Search for an attribute in the archiver list. PARAMETERS ---------- attr: string String to search for. db: string Which database, "H", "T" ignorecase: bool Case insensitive. RETURNS ------- """ global ARCHLIST if ARCHLIST is None: # Populate archlist ARCHLIST=dict() for db in "HT": ARCHLIST[db] = tango.DeviceProxy("archiving/{}dbextractor/1".format(db)).getcurrentarchivedatt() if ignorecase: return [a for a in ARCHLIST[db] if attr.lower() in a.lower()] else: return [a for a in prx.get_attribute_list() if attr in a] ############################################################################### ## POPULATE ATTRIBUTE FUNCTIONS ############################################################################### # ============================================================================= def populate_tdblist(): """ Fill the global list of TDB archived attributes. """ global TDBLIST TDBLIST= tango.DeviceProxy("archiving/tdbextractor/1").getcurrentarchivedatt() # ============================================================================= def populate_hdblist(): """ Fill the global list of HDB archived attributes. """ global HDBLIST HDBLIST= tango.DeviceProxy("archiving/hdbextractor/1").getcurrentarchivedatt() # ============================================================================= def populate_devlist(): """ Fill the global list of devices. """ DB = tango.Database() for domain in DB.get_device_domain("*"): for family in DB.get_device_family(domain+"/*"): for member in DB.get_device_member(domain+"/"+family+"/*"): DEVLIST.append(domain+"/"+family+"/"+member) # ============================================================================= def populate_devlist2(): """ Fill the global list of devices. """ DB = tango.Database() DEVLIST = [dev for dev in DB.get_device_exported("*")]