Exemple #1
0
def main(args):

    import sys, re, traceback, taurus
    assert len(
        args
    ) > 1, '\n\nUsage:\n\t> python panel.py [a/device/name or synoptic.jdw] [--attrs] [attr_regexps] --comms [comm_regexps]'

    model = args[1]
    taurus.setLogLevel(taurus.core.util.Logger.Debug)
    app = Qt.QApplication(args)
    form = None

    if re.match('[\w-]+/[\w-]+/[\w-]+.*', model):

        print 'loading a device panel'
        k, filters = '--attrs', fandango.defaultdict(list)
        for f in args[2:]:
            if f.startswith('--'): k = f.strip('-')
            else: filters[k].append(f)  #(f,()) if k=='comms' else f)

        form = VaccaPanel(filters=filters)  #palette=get_fullWhite_palette()
        form.setModel(model)

    elif model.lower().endswith('.jdw'):
        print 'loading a synoptic'
        form = taurus.qt.qtgui.graphic.TauJDrawSynopticsView(
            designMode=False,
            updateMode=taurus.qt.qtgui.graphic.TauJDrawSynopticsView.
            NoViewportUpdate)
        #FullViewportUpdate, : AWFUL CPU USAGE!!!!!!!!
        #MinimalViewportUpdate, : Qt Defaults
        #SmartViewportUpdate, : ?
        #BoundingRectViewportUpdate, : ?
        #NoViewportUpdate : Tau defaults
        form.setModel(model)
        models = form.get_item_list()
        for m in models:
            m = str(m)
            if m.count('/') == 2: m += '/state'
            period = 120000.
            try:
                taurus.Attribute(m).changePollingPeriod(period)
            except:
                print '(%s).changePollingPeriod(%s): Failed: %s' % (
                    m, period, traceback.format_exc())

    print 'showing ...'
    form.show()
    sys.exit(app.exec_())
Exemple #2
0
def init_qt():
    return Qt.QApplication([])
Exemple #3
0
        if attrname not in self.listeners:
            print "subscribe", attrname,
            t0 = time.time()
            with self.lock:
                print "...got lock"
                listener = TaurusWebAttribute(attrname, callback)
                self.listeners[attrname] = listener
                print "...sub done", attrname, ", took %f s." % (time.time() -
                                                                 t0)

    def _unsubscribe_attribute(self, attrname):
        listener = self.listeners.pop(attrname, None)
        if listener:
            t0 = time.time()
            print "unsubscribe", attrname,
            with self.lock:
                print "...got lock"
                listener.clear()
                print "...unsub done", attrname, ", took %f s." % (
                    time.time() - t0)


if __name__ == '__main__':
    import sys
    print sys.argv[1]
    qapp = Qt.QApplication([])
    sw = SynopticWidget()
    sw.show()
    sw.setModel(sys.argv[1])
    qapp.exec_()