예제 #1
0
def main():
    import sys
    import fandango

    try:
        server, classname, devicename = sys.argv[1:4]
        props = eval(fandango.first(sys.argv[4:]) or ['{}'])
    except:
        print __doc__
        sys.exit(1)

    fandango.tango.add_new_device(server, classname, devicename)
    if props:
        fandango.get_database().put_device_property

    db = Database()

    rateDS = 100
    nDS = 30
    first = 31

    def addTangoDev(server, _class, device):
        di = DbDevInfo()
        di.name, di._class, di.server = device, _class, server
        db.add_device(di)

    _class = 'PySignalSimulator'
    domain = 'sim'
    family = 'pysignalsimulator'

    print 'Creating ', str(rateDS * nDS), ' TangoTest device Servers ...'
    for m in range(first, nDS + first):
        server = '/'.join([_class, '%02d' % m])
        print 'Deleting server ', server
        try:
            db.delete_server(server)
        except:
            pass
        for n in range(1, rateDS + 1):
            server = '/'.join([_class, '%02d' % m])
            member = '%02d' % m + '-' + '%02d' % n
            device = '/'.join([domain, family, member])
            print 'Creating device ', device
            addTangoDev(server, _class, device)
            print 'Adding Properties to class/device = ', _class, '/', device
            db.put_class_property(
                _class,
                {'Description': ['device used to test the archiving system']})
            db.put_device_property(
                device, {'SimAttributes': ['A1=sin((t+random())/2.)']})
            db.put_device_property(
                device, {
                    'SimStates': [
                        'FAULT=square(t,period=10)', "ALARM=Attr('A1')<0",
                        'ON=1'
                    ]
                })
예제 #2
0
    def load_all_devices(self, filters='*'):
        import fandango
        self.tango = fandango.get_database()
        self.alias_devs = fandango.defaultdict_fromkey(
            lambda k, s=self: str(s.tango.get_device_alias(k)))
        self.archattrs = []
        self.archdevs = []
        #print('In load_all_devices(%s)...'%str(filters))
        devs = fandango.tango.get_all_devices()
        if filters != '*':
            devs = [
                d for d in devs
                if fandango.matchCl(filters.replace(' ', '*'), d, extend=True)
            ]
        self.all_devices = devs
        self.all_domains = sorted(set(a.split('/')[0] for a in devs))
        self.all_families = sorted(set(a.split('/')[1] for a in devs))

        members = []
        for a in devs:
            try:
                members.append(a.split('/')[2])
            except:
                # Wrong names in DB? yes, they are
                pass  #print '%s is an invalid name!'%a
        members = sorted(set(members))

        self.all_members = sorted(
            set(e for m in members for e in re.split('[-_0-9]', m)
                if not fandango.matchCl('^[0-9]+([ABCDE][0-9]+)?$', e)))

        #print 'Loading alias list ...'
        self.all_alias = self.tango.get_device_alias_list('*')
        #self.alias_devs =  dict((str(self.tango.get_device_alias(a)).lower(),a) for a in self.all_alias)
        tracer('Loading (%s) finished.' % (filters))
    def load_all_devices(self,filters='*'):
        import fandango as fn #needed by subprocess
        self.tango = fn.get_database()
        self.alias_devs = fn.defaultdict_fromkey(
                lambda k,s=self: str(s.tango.get_device_alias(k)))
        self.archattrs = []
        self.archdevs = []
        #print('In load_all_devices(%s)...'%str(filters))
        devs = fn.tango.get_all_devices()
        if filters!='*': 
            devs = [d for d in devs if fn.matchCl(
                        filters.replace(' ','*'),d,extend=True)]
        self.all_devices = devs
        self.all_domains = sorted(set(a.split('/')[0] for a in devs))
        self.all_families = sorted(set(a.split('/')[1] for a in devs))

        members = []
        for a in devs:
            try:
                members.append(a.split('/')[2])
            except:
                # Wrong names in DB? yes, they are
                pass #print '%s is an invalid name!'%a
        members = sorted(set(members))
        
        self.all_members = sorted(set(e for m in members 
                for e in re.split('[-_0-9]',m) 
                if not fn.matchCl('^[0-9]+([ABCDE][0-9]+)?$',e)))

        #print 'Loading alias list ...'
        self.all_alias = self.tango.get_device_alias_list('*')
        #self.alias_devs =  dict((str(self.tango.get_device_alias(a)).lower(),a) for a in self.all_alias)
        tracer('Loading (%s) finished.'%(filters))
예제 #4
0
    def __init__(self,
                 schema,
                 host=None,
                 user='******',
                 passwd='browser',
                 classes=[],
                 LogLevel='info',
                 load=True,
                 logger=None):
        """
        """
        self.log = logger or Logger(
            'ArchivingAPI(%s)' % schema,
            format='%(levelname)-8s %(asctime)s %(name)s: %(message)s')
        self.log.setLogLevel(LogLevel)
        self.log.debug('Logger streams initialized (error,warning,info,debug)')

        self.tango = fandango.get_database()  #access to Tango database
        self.api = self  #hook used by legacy packages
        self.servers = None
        self.schema = str(schema).lower()
        self.user, self.passwd = user, passwd

        if host is None:
            prop = self.tango.get_class_property('%sArchiver' % schema,
                                                 ['DbHost'])['DbHost']
            if not prop:
                print('ERROR: %sArchiver.DbHost property not defined!' %
                      schema)
                self.host = None
            else:
                self.host = prop[0]
            #if 'TANGO_HOST' in os.environ:
            #    self.host=os.environ['TANGO_HOST'].split(':')[0]
        else:
            self.host = host

        self.dbs = {}  #pointers to Archiving databases

        self.ArchivingClasses = classes or self.get_archiving_classes()
        self.ArchiverClass = (k for k in self.ArchivingClasses
                              if 'Archiver' in k).next()
        self.ManagerClass = (k for k in self.ArchivingClasses
                             if 'Manager' in k).next()
        self.ExtractorClass = (k for k in self.ArchivingClasses
                               if 'Extractor' in k).next()
        try:
            self.WatcherClass = (k for k in self.ArchivingClasses
                                 if 'Watcher' in k).next()
        except:
            self.WatcherClass = None

        self.loads = CaselessDefaultDict(
            lambda k: 0)  #a dict with the archiving load for each device
        self.attributes = CaselessDict()  #a dict of ArchivedAttribute objects
        self.dedicated = CaselessDefaultDict(lambda k: set(
        ))  #Dictionary for keeping the attributes reserved for each archiver

        if load and self.host and self.ArchivingClasses:
            self.load_servers()
예제 #5
0
def main():
  import sys
  import fandango

  try:
      server,classname,devicename = sys.argv[1:4]
      props = eval(fandango.first(sys.argv[4:]) or ['{}'])
  except:
      print __doc__
      sys.exit(1)

  fandango.tango.add_new_device(server,classname,devicename)
  if props:
      fandango.get_database().put_device_property

  db = Database()

  rateDS = 100
  nDS = 30
  first = 31

  def addTangoDev(server,_class,device):
          di = DbDevInfo()
          di.name,di._class,di.server = device,_class,server
          db.add_device(di)

  _class = 'PySignalSimulator'
  domain = 'sim'
  family = 'pysignalsimulator'

  print 'Creating ',str(rateDS*nDS) , ' TangoTest device Servers ...'
  for m in range(first,nDS+first):
          server = '/'.join([_class,'%02d'%m])
          print 'Deleting server ',server
          try: db.delete_server(server)
          except: pass
          for n in range(1,rateDS+1):
                  server = '/'.join([_class,'%02d'%m])
                  member = '%02d'%m+'-'+'%02d'%n
                  device = '/'.join([domain,family,member])
                  print 'Creating device ',device
                  addTangoDev(server,_class,device)
                  print 'Adding Properties to class/device = ',_class,'/',device
                  db.put_class_property(_class,{'Description':['device used to test the archiving system']})
                  db.put_device_property(device,{'SimAttributes':['A1=sin((t+random())/2.)']})
                  db.put_device_property(device,{'SimStates':['FAULT=square(t,period=10)',"ALARM=Attr('A1')<0",'ON=1']})
예제 #6
0
    def __init__(self, mask=None):
        #mask = mask or 'FolderDS/*'
        self.mask = mask
        ProxiesDict.__init__(self)
        devs = tango.get_class_devices('FolderDS')
        extra = fn.get_database().get_class_property('FolderDS',
                                                     ['ExtraDevices'])
        devs.extend(extra.get('ExtraDevices', []))
        if mask: devs = fn.filtersmart(devs, mask)
        self.hosts = fn.defaultdict(list)

        for d in devs:
            self[d]
예제 #7
0
def get_snap_api():
    trace('get_snap_api()',level=-1)
    global SNAP_ALLOWED
    if SNAP_ALLOWED is True:
      try:
          from PyTangoArchiving import snap
          #from PyTangoArchiving.widget.snaps import *
          db = fandango.get_database()
          assert list(db.get_device_exported_for_class('SnapManager'))
          SNAP_ALLOWED = snap.SnapAPI()
          
      except Exception,e:
          trace('PyTangoArchiving.Snaps not available: HISTORY VIEWER DISABLED: '+traceback.format_exc(),'WARNING',-1)
          SNAP_ALLOWED = None
예제 #8
0
    def __init__(self,schema,host=None,user='******',passwd='browser',classes=[],LogLevel='info',load=True,logger=None):
        """
        """
        self.log = logger or Logger('ArchivingAPI(%s)'%schema,format='%(levelname)-8s %(asctime)s %(name)s: %(message)s')
        self.log.setLogLevel(LogLevel)
        self.log.debug('Logger streams initialized (error,warning,info,debug)')

        self.tango = fandango.get_database() #access to Tango database
        self.api = self #hook used by legacy packages
        self.servers = None
        self.schema = str(schema).lower()
        self.user,self.passwd = user,passwd
        
        if host is None:
            prop = self.tango.get_class_property('%sArchiver'%schema,['DbHost'])['DbHost']
            if not prop: 
                print('ERROR: %sArchiver.DbHost property not defined!'%schema)
                self.host = None
            else:
                self.host = prop[0]
            #if 'TANGO_HOST' in os.environ:
            #    self.host=os.environ['TANGO_HOST'].split(':')[0]
        else: self.host=host
        
        self.dbs={} #pointers to Archiving databases
        
        self.ArchivingClasses = classes or self.get_archiving_classes()
        self.ArchiverClass = (k for k in self.ArchivingClasses if 'Archiver' in k).next()
        self.ManagerClass = (k for k in self.ArchivingClasses if 'Manager' in k).next()
        self.ExtractorClass = (k for k in self.ArchivingClasses if 'Extractor' in k).next()
        try: self.WatcherClass = (k for k in self.ArchivingClasses if 'Watcher' in k).next()
        except: self.WatcherClass = None
        
        self.loads=CaselessDefaultDict(lambda k:0) #a dict with the archiving load for each device
        self.attributes=CaselessDict() #a dict of ArchivedAttribute objects        
        self.dedicated = CaselessDefaultDict(lambda k:set()) #Dictionary for keeping the attributes reserved for each archiver
        
        if load and self.host and self.ArchivingClasses: 
          self.load_servers()
예제 #9
0
class AttributesPanel(PARENT_KLASS):

    _domains = ['ALL EPS'] + ['LI', 'LT'] + [
        'LT%02d' % i for i in range(1, 3)
    ] + ['SR%02d' % i for i in range(1, 17)]
    _fes = [
        f for f in get_distinct_domains(
            fandango.get_database().get_device_exported('fe*'))
        if fun.matchCl('fe[0-9]', f)
    ]

    LABELS = 'Label/Value Device Attribute Alias Archiving Check'.split()
    SIZES = [500, 150, 90, 90, 120, 40]
    STRETCH = [8, 4, 4, 4, 2, 1]

    def __init__(self, parent=None, devices=None):
        #print '~'*80
        tracer('In AttributesPanel()')
        PARENT_KLASS.__init__(self, parent)
        self.setSizePolicy(
            Qt.QSizePolicy(Qt.QSizePolicy.Ignored, Qt.QSizePolicy.Ignored))
        self.worker = SingletonWorker(parent=self,
                                      cursor=True,
                                      sleep=50.,
                                      start=True)
        #self.worker.log.setLogLevel(self.worker.log.Debug)
        self.filters = ('', '', '')  #server/device/attribute
        self.devices = devices or []
        self.setValues(None)
        self.models = []

        self.current_item = None
        #self.connect(self, Qt.SIGNAL('customContextMenuRequested(const QPoint&)'), self.onContextMenu)
        self.popMenu = Qt.QMenu(self)

        self.actions = {
            'TestDevice':
            self.popMenu.addAction(Qt.QIcon(), "Test Device",
                                   self.onTestDevice),
            'ShowDeviceInfo':
            self.popMenu.addAction(Qt.QIcon(), "Show Device Info",
                                   self.onShowInfo),
            #'ShowDevicePanel': self.popMenu.addAction(Qt.QIcon(),"Show Info",self.onShowPanel),
            'ShowArchivingInfo':
            self.popMenu.addAction(Qt.QIcon(), "Show Archiving Info",
                                   self.onShowArchivingModes),
            'AddToTrend':
            self.popMenu.addAction(Qt.QIcon(), "Add attribute to Trend",
                                   self.addAttributeToTrend),
            'AddSelected':
            self.popMenu.addAction(Qt.QIcon(),
                                   "Add selected attributes to Trend",
                                   self.addSelectedToTrend),
            'CheckAll':
            self.popMenu.addAction(Qt.QIcon(), "Select all attributes",
                                   self.checkAll),
            'UncheckAll':
            self.popMenu.addAction(Qt.QIcon(), "Deselect all attributes",
                                   self.uncheckAll),

            #'Test Device': self.popMenu.addAction(Qt.QIcon(),"Test Device",self.onTestDevice)
        }
        #if hasattr(self,'setFrameStyle'):
        #self.setFrameStyle(self.Box)
        try:
            import PyTangoArchiving
            self.reader = PyTangoArchiving.Reader('*')
            #self.hreader = self.reader.configs['hdb']
            #self.treader = self.reader.configs.get('tdb',self.hreader)
        except:
            traceback.print_exc()

    def __del__(self):
        print 'AttributesPanel.__del__'
        QGridTable.__del__(self)

    def setItem(self, x, y, item, spanx=1, spany=1, align=None, model=None):
        align = align or Qt.Qt.AlignLeft
        try:
            if model:
                item._model = model
        except:
            pass
        self.layout().addWidget(item, x, y, spany, spanx, Qt.Qt.AlignCenter)
        if item not in self._widgets: self._widgets.append(item)

    def mousePressEvent(self, event):
        point = event.pos()
        widget = Qt.QApplication.instance().widgetAt(self.mapToGlobal(point))
        if hasattr(widget, '_model'):
            print('onMouseEvent(%s)' %
                  (getattr(widget, 'text', lambda: widget)()))
            self.current_item = widget
            if event.button() == Qt.Qt.RightButton:
                self.onContextMenu(point)
        getattr(super(type(self), self), 'mousePressEvent',
                lambda e: None)(event)

    def onContextMenu(self, point):
        print('onContextMenu()')
        try:
            self.actions['TestDevice'].setEnabled(
                '/' in self.current_item._model)
            self.actions['ShowDeviceInfo'].setEnabled(
                '/' in self.current_item._model)
            self.actions['ShowArchivingInfo'].setEnabled(
                '/' in self.current_item._model)
            self.actions['AddToTrend'].setEnabled(hasattr(self, 'trend'))
            self.actions['AddSelected'].setEnabled(hasattr(self, 'trend'))
            self.popMenu.exec_(self.mapToGlobal(point))
        except:
            traceback.print_exc()

    def getCurrentModel(self):
        return '/'.join(str(self.current_item._model).split('/')[-4:])

    def getCurrentDevice(self):
        return str(self.current_item._model.rsplit('/', 1)[0])

    def onTestDevice(self, device=None):
        from PyTangoArchiving.widget.panel import showTestDevice
        showTestDevice(device or self.getCurrentDevice())

    def onShowInfo(self, device=None):
        from PyTangoArchiving.widget.panel import showDeviceInfo
        showDeviceInfo(device=device or self.getCurrentDevice(), parent=self)

    def onShowArchivingModes(self, model=None):
        try:
            from PyTangoArchiving.widget.panel import showArchivingModes
            model = model or self.getCurrentModel()
            showArchivingModes(model, parent=self)
        except:
            Qt.QMessageBox.warning(self, "ups!", traceback.format_exc())

    def addAttributeToTrend(self, model=None):
        try:
            model = model or self.getCurrentModel()
            self.trend.addModels([model])
        except:
            Qt.QMessageBox.warning(self, "ups!", traceback.format_exc())

    def addSelectedToTrend(self):
        try:
            y = self.columnCount() - 1
            models = []
            for x in range(self.rowCount()):
                item = self.itemAt(x, y).widget()
                m = getattr(item, '_model', '')
                if m and item.isChecked():
                    models.append(m)
            if len(models) > 20:
                Qt.QMessageBox.warning(
                    self, "warning",
                    "To avoid performance issues, dynamic scale will be disabled"
                )
                self.trend.setXDynScale(False)
            self.trend.addModels(models)
        except:
            Qt.QMessageBox.warning(self, "ups!", traceback.format_exc())

    def checkAll(self):
        y = self.columnCount() - 1
        for x in range(self.rowCount()):
            self.itemAt(x, y).widget().setChecked(True)

    def uncheckAll(self):
        y = self.columnCount() - 1
        for x in range(self.rowCount()):
            self.itemAt(x, y).widget().setChecked(False)

    def setValues(self, values, filters=None):
        """ filters will be a tuple containing several regular expressions to match """
        #print('In AttributesPanel.setValues([%s])'%len(values or []))
        if values is None:
            self.generateTable([])
        elif True:  #filters is None:
            self.generateTable(values)
        #print 'In AttributesPanel.setValues(...): done'
        return

    def generateTable(self, values):

        #thermocouples = thermocouples if thermocouples is not None else self.thermocouples
        self.setRowCount(len(values))
        self.setColumnCount(5)
        #self.vheaders = []
        self.offset = 0
        self.widgetbuffer = []

        for i, tc in enumerate(sorted(values)):
            #print 'setTableRow(%s,%s)'%(i,tc)
            model, device, attribute, alias, archived, ok = tc
            model, device, attribute, alias = map(
                str.upper, (model, device, attribute, alias))

            #self.vheaders.append(model)
            def ITEM(m, model='', size=0):
                q = fandango.qt.Draggable(Qt.QLabel)(m)
                if size is not 0:
                    q.setMinimumWidth(size)  #(.7*950/5.)
                q._model = model
                q._archived = archived
                q.setDragEventCallback(lambda s=q: s._model)
                return q

            ###################################################################
            qf = Qt.QFrame()
            qf.setLayout(Qt.QGridLayout())
            qf.setMinimumWidth(self.SIZES[0])
            qf.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
            #Order changed, it is not clear if it has to be done before or after adding TaurusValue selfect
            self.setCellWidget(i + self.offset, 0, qf)

            #print('Adding item: %s, %s, %s, %s, %s' % (model,device,attribute,alias,archived))
            if ok:
                tv = TaurusValue()  #TaurusValueLabel()
                qf.layout().addWidget(tv, 0, 0)
                tv.setParent(qf)
            else:
                self.setItem(i + self.offset, 0, ITEM(model, model))

            devlabel = ITEM(device, model, self.SIZES[1])
            self.setItem(i + self.offset, 1, devlabel)
            self.setItem(i + self.offset, 2,
                         ITEM(attribute, model, self.SIZES[2]))
            self.setItem(i + self.offset, 3, ITEM(alias, model, self.SIZES[3]))

            from PyTangoArchiving.widget.panel import showArchivingModes, show_history
            if archived:
                active = self.reader.is_attribute_archived(model, active=True)
                txt = '/'.join(a.upper() if a in active else a
                               for a in archived)
            else:
                txt = '...'
            q = Qt.QPushButton(txt)
            q.setFixedWidth(self.SIZES[-2])
            q.setToolTip("""%s<br><br><pre>
              'HDB' : Archived and updated, push to export values
              'hdb' : Archiving stopped, push to export values
              '...' : Not archived
              </pre>""" % txt)
            self.connect(q,
                         Qt.SIGNAL("pressed ()"),
                         lambda a=self.reader.get_attribute_alias(
                             model), o=q: setattr(q, 'w', show_history(a))
                         )  #showArchivingModes(a,parent=self)))
            self.setItem(i + self.offset, 4, q)

            qc = Qt.QCheckBox()
            qc.setFixedWidth(self.SIZES[-1])
            self.setItem(i + self.offset, 5, qc, 1, 1, Qt.Qt.AlignCenter,
                         model)

            if ok:
                #print('Setting Model %s'%model)
                #ADDING WIDGETS IN BACKGROUND DIDN'T WORKED, I JUST CAN SET MODELS FROM THE WORKER
                try:
                    if self.worker:
                        self.worker.put([(lambda w=tv, m=model: w.setModel(m))
                                         ])
                        #print 'worker,put,%s'%str(model)
                    else:
                        tv.setModel(model)
                except:
                    print traceback.format_exc()
                self.models.append(tv)

            #self.widgetbuffer.extend([qf,self.itemAt(i+self.offset,1),self.itemAt(i+self.offset,2),self.itemAt(i+self.offset,3),self.itemAt(i+self.offset,4)])
            fandango.threads.Event().wait(.02)

        if len(values):

            def setup(o=self):
                [o.setRowHeight(i, 20) for i in range(o.rowCount())]
                #o.setColumnWidth(0,350)
                o.update()
                o.repaint()
                #print o.rowCount()
                o.show()

            setup(self)

        if self.worker:
            print('%s.next()' % (self.worker))
            self.worker.next()

        #threading.Event().wait(10.)
        tracer('Out of generateTable()')

    def clear(self):
        try:
            #print('In AttributesPanel.clear()')
            for m in self.models:
                m.setModel(None)
            self.models = []
            self.setValues(None)

            #QGridTable.clear(self)
            def deleteItems(layout):
                if layout is not None:
                    while layout.count():
                        item = layout.takeAt(0)
                        widget = item.widget()
                        if widget is not None:
                            widget.deleteLater()
                        else:
                            deleteItems(item.layout())

            deleteItems(self.layout())
            #l = self.layout()
            #l.deleteLater()
            #self.setLayout(Qt.QGridLayout())
        except:
            traceback.print_exc()
예제 #10
0
                lambda self, attr: attr.set_value(__RELEASE__))
except Exception, e:
    __RELEASE__ = traceback.format_exc()
print '> ', __RELEASE__

#==================================================================
#
#    Vacuum Device Servers class main method
#
#==================================================================
if __name__ == '__main__':
    try:
        py = PyTango.PyUtil(sys.argv)
        #######################################################################
        ## DO NOT CHANGE THE ORDER IN WHICH THE CLASSES ARE LOADED, IT IS NOT TRIVIAL
        db = fandango.get_database()
        classes = db.get_device_class_list('VacuumController/%s' %
                                           sys.argv[1])[1::2]

        k = 'MKSGaugeController'
        if not classes or k in classes:
            try:
                from MKSGaugeController.MKSGaugeController import *
                py.add_class(MKSGaugeControllerClass, MKSGaugeController,
                             'MKSGaugeController')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'MVC3GaugeController'
        if not classes or k in classes:
예제 #11
0
    tango_create Server/Instance Class DeviceName {properties as python dictionary}
"""

import sys
import fandango

try:
    server,classname,devicename = sys.argv[1:4]
    props = eval(fandango.first(sys.argv[4:]) or ['{}'])
except:
    print __doc__
    sys.exit(1)

fandango.tango.add_new_device(server,classname,devicename)
if props:
    fandango.get_database().put_device_property


from PyTango import *

db = Database()

rateDS = 100
nDS = 30
first = 31

def addTangoDev(server,_class,device):
	di = DbDevInfo()
	di.name,di._class,di.server = device,_class,server
	db.add_device(di)
예제 #12
0
def main():
    try:
        py = PyTango.PyUtil(sys.argv)
        #######################################################################
        ## DO NOT CHANGE THE ORDER IN WHICH THE CLASSES ARE LOADED, IT IS NOT TRIVIAL
        db = fandango.get_database()
        classes = db.get_device_class_list('VacuumController/%s' %
                                           sys.argv[1])[1::2]

        k = 'MKSGaugeController'
        if not classes or k in classes:
            try:
                from MKSGaugeController import MKSGaugeController, MKSGaugeControllerClass
                py.add_class(MKSGaugeControllerClass, MKSGaugeController,
                             'MKSGaugeController')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'MVC3GaugeController'
        if not classes or k in classes:
            try:
                from MVC3GaugeController import MVC3GaugeController, MVC3GaugeControllerClass
                py.add_class(MVC3GaugeControllerClass, MVC3GaugeController)
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'PfeifferGaugeController'
        if not classes or k in classes:
            try:
                from PfeifferGaugeController import PfeifferGaugeController, PfeifferGaugeControllerClass
                py.add_TgClass(PfeifferGaugeControllerClass,
                               PfeifferGaugeController,
                               'PfeifferGaugeController')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'LeyboldGaugeController'
        if not classes or k in classes:
            try:
                from LeyboldGaugeController import LeyboldGaugeController, LeyboldGaugeControllerClass
                py.add_TgClass(LeyboldGaugeControllerClass,
                               LeyboldGaugeController,
                               'LeyboldGaugeController')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'AxtranGaugeController'
        if not classes or k in classes:
            try:
                from AxtranGaugeController import AxtranGaugeController, AxtranGaugeControllerClass
                py.add_TgClass(AxtranGaugeControllerClass,
                               AxtranGaugeController, 'AxtranGaugeController')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'VacuumGauge'
        if not classes or k in classes:
            try:
                from VacuumGauge import VacuumGauge, VacuumGaugeClass
                py.add_class(VacuumGaugeClass, VacuumGauge, 'VacuumGauge')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))

        #######################################################################
        ## DO NOT CHANGE THE ORDER IN WHICH THE CLASSES ARE LOADED, IT IS NOT TRIVIAL

        k = 'VarianDUAL'
        if not classes or k in classes:
            try:
                from VarianDUAL import VarianDUAL, VarianDUALClass
                py.add_class(VarianDUALClass, VarianDUAL, 'VarianDUAL')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'MidiVac'
        if not classes or k in classes:
            try:
                from MidiVac import MidiVac, MidiVacClass
                py.add_class(MidiVacClass, MidiVac, 'MidiVac')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'SplitterBox'
        if not classes or k in classes:
            try:
                from SplitterBox import SplitterBox, SplitterBoxClass
                py.add_class(SplitterBoxClass, SplitterBox, 'SplitterBox')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))
        k = 'IonPump'
        if not classes or k in classes:
            try:
                from IonPump import IonPump, IonPumpClass
                py.add_class(IonPumpClass, IonPump, 'IonPump')
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))

        # Commented due to problems with 64 bits in Tango8
        #k = 'Serial'
        #try:
        #    py.add_Cpp_TgClass('Serial','Serial')
        #except:
        #    print('Unable to import %s Class: %s'%(k,traceback.format_exc()))

        k = 'DDebug'
        if not classes or k in classes:
            try:
                from fandango.dynamic import CreateDynamicCommands
                from fandango.device import DDebug, DDebugClass
                py.add_class(DDebugClass, DDebug, 'DDebug')
                CreateDynamicCommands(DDebug, DDebugClass)
                print('%s class added' % k)
            except:
                print('Unable to import %s Class: %s' %
                      (k, traceback.format_exc()))

        U = PyTango.Util.instance()
        U.server_init()
        U.server_run()

    except PyTango.DevFailed, e:
        print '-------> Received a DevFailed exception:', e
        traceback.print_exc()
예제 #13
0
    def setTable(self, model, filters=[]):
        ''' 
        This method  overrides TaurusPropTable.setTable(), which connects with TaurusClassTable
        This method fill the table with the names of properties and values for the device selected
        '''
        try:
            model = model and fandango.tango.parse_tango_model(str(model))
            if model is None:
                self.warning(
                    'VaccaPropTable.setTable(%s(%s)): MODEL NOT PARSABLE!' %
                    (type(model), model))
                return
            else:
                try:
                    model = model['device']
                except:
                    model = str(model)
                self.debug('VaccaPropTable.setTable(%s(%s))' %
                           (type(model), model))

            #TaurusPropTable.setTable(self,model)
            Qt.QObject.disconnect(self, Qt.SIGNAL("cellChanged(int,int)"),
                                  self.valueChanged)
            self.db = fandango.get_database()
            dev_name = str(model)
            self.list_prop = list(
                self.db.get_device_property_list(dev_name, '*'))
            neg = ['polled_attr'
                   ] + [f[1:] for f in filters if f.startswith('!')]
            pos = [f for f in filters if not f.startswith('!')]
            self.list_prop = [
                p for p in self.list_prop
                if (not pos or fandango.matchAny(pos, p))
                and not fandango.matchAny(neg, p)
            ]

            self.setRowCount(len(self.list_prop))
            for i in range(0, len(self.list_prop)):
                elem = self.list_prop[i]
                self.setText(elem, i, 0)
                self.dictionary = self.db.get_device_property(
                    dev_name, self.list_prop)
                self.debug('Getting %s properties: %s -> %s' %
                           (dev_name, self.list_prop, self.dictionary))
                value = self.dictionary[elem]
                self.debug('VaccaPropTable: property %s is type %s' %
                           (elem, type(value)))
                USE_TABLES = False
                if USE_TABLES: self.setPropertyValue(value, i, 1)
                else:
                    if not isinstance(value,
                                      str):  #not something like an string
                        #if isinstance(value,list):#type(value) is list:
                        heigh1 = len(value)
                        value = '\n'.join(
                            str(v) for v in value
                        )  # adding new lines in between elements in the list
                    self.setText(str(value), i, 1)

            self.updateStyle()
            self.dev_name = dev_name
            #self.dev_obj = taurus.Device(dev_name)
            self.setWindowTitle('%s Properties' % dev_name)
            self.resizeColumnsToContents()
            self.resizeRowsToContents()

        except:
            traceback.print_exc()
예제 #14
0
import panic, fandango
from PyQt4 import Qt, QtCore, QtGui
from taurus.qt.qtgui.resource import getThemeIcon
from taurus.qt.qtgui.panel import TaurusForm
from operator import itemgetter

try:
  from PyTangoArchiving import snap
  from PyTangoArchiving.widget.snaps import *
  db = fandango.get_database()
  assert list(db.get_device_exported_for_class('SnapManager'))
  SNAP_ALLOWED = True
except:
  print 'PyTangoArchiving.Snaps not available!'
  snap = None
  SNAP_ALLOWED = False

class ahWidget(QtGui.QWidget):
    def __init__(self,parent=None,container=None):
        QtGui.QWidget.__init__(self,parent)
        self._ah = alarmhistoryForm()
        self._ah.alarmhistorySetupUi(self)
        self._kontainer = container
        self.setAlarmCombo()

    def setAlarmCombo(self, alarm=None):
        self._ah.setAlarmCombo(alarm=alarm or 'All')

    def show(self):
        QtGui.QWidget.show(self)
        self._ah.setAlarmCombo(alarm='All')