Exemple #1
0
    def __init__(self, main):
        QDialog.__init__(self, main)
        DlgUtils.__init__(self, 'Settings')
        loadUi(self, 'dialogs/settings.ui')
        self.main = main
        self.sgroup = main.sgroup

        genitem = QTreeWidgetItem(self.settingsTree, ['General'], -2)
        QTreeWidgetItem(self.settingsTree, ['Connection presets'], -1)
        self.settingsTree.setCurrentItem(genitem)
        self.stacker.setCurrentIndex(0)

        # general page
        self.instrument.setText(main.instrument)
        self.confirmExit.setChecked(main.confirmexit)
        self.warnWhenAdmin.setChecked(main.warnwhenadmin)
        self.showTrayIcon.setChecked(main.showtrayicon)
        self.autoReconnect.setChecked(main.autoreconnect)
        self.autoSaveLayout.setChecked(main.autosavelayout)
        self.manualSaveLayout.setChecked(not main.autosavelayout)
        self.allowOutputLineWrap.setChecked(main.allowoutputlinewrap)

        # connection data page
        self.connpresets = main.connpresets
        for setting, cdata in main.connpresets.items():
            QListWidgetItem(setting + ' (%s:%s)' % (cdata.host, cdata.port),
                            self.settinglist).setData(32, setting)
Exemple #2
0
    def __init__(self, app):
        QMainWindow.__init__(self, None)
        self.app = app
        self.client = app  # used by the NewViewDialog

        # this is done in Panel.__init__ for the panel version
        self.settings = CompatSettings()
        self.loadSettings(self.settings)

        BaseHistoryWindow.__init__(self)
        self.splitter.setSizes([20, 80])

        DlgUtils.__init__(self, 'History viewer')

        self.actionAttachElog.setVisible(False)

        self.splitter.restoreState(self.splitterstate)

        self.setCentralWidget(self.splitter)
        self.newValue.connect(self.newvalue_callback)

        for toolbar in self.getToolbars():
            self.addToolBar(toolbar)
        for menu in self.getMenus():
            self.menuBar().addMenu(menu)
        self.actionFitLinear.trigger()
        self.statusBar = QStatusBar(self)
        self.setStatusBar(self.statusBar)
Exemple #3
0
    def __init__(self, parent, client, **configs):
        QDialog.__init__(self, parent)
        DlgUtils.__init__(self, self.toolName)
        loadUi(self, 'tools/downtime.ui')
        self.sendBtn = self.buttonBox.addButton('&Send',
                                                QDialogButtonBox.AcceptRole)
        self.sendBtn.setIcon(QIcon(':/mail'))
        self.sendBtn.setDisabled(True)

        self.parentwindow = parent
        self.client = client
        if hasattr(parent, 'mainwindow'):
            self.mainwindow = parent.mainwindow
            self.log = NicosLogger(self.toolName)
            self.log.parent = self.mainwindow.log
        else:
            self.log = configs.get('log', None)
        self.sgroup = SettingGroup(self.toolName)

        self._sender = configs.get('sender', '*****@*****.**')
        self._receiver = configs.get('receiver', '*****@*****.**')
        self._mailserver = configs.get('mailserver', '') or \
            self._getDeviceComponent('experiment', 'mailserver', 'smtp.frm2.tum.de')
        self._instrument = configs.get('instrument', '') or \
            self._getDeviceComponent('instrument', 'instrument', 'DEMO')
        t = self.mailheaderText.text().replace('{{instrument}}',
                                               self._instrument)
        self.mailheaderText.setText(t)

        self.startDown.setDateTime(QDateTime.currentDateTime().addSecs(-3600))
        self.endDown.setDateTime(QDateTime.currentDateTime())
        self.errorText.setVisible(False)
        with self.sgroup as settings:
            self.loadSettings(settings)
        self.reasons.clearEditText()
Exemple #4
0
 def __init__(self, parent, client, **settings):
     QMainWindow.__init__(self, parent)
     DlgUtils.__init__(self, 'Instrument config')
     loadUi(self, findResource('nicos_mlz/kws1/gui/instrconfig.ui'))
     self.setWindowTitle('Reconfigure Instrument')
     self.client = client
     self.client.connected.connect(self.on_client_connected)
     self.client.disconnected.connect(self.on_client_disconnected)
     self._parts = settings['parts']
     self._widgets = []
     for (i, part) in enumerate(self._parts):
         label = QLabel(part + ':', self)
         bgrp = QButtonGroup(self)
         rbtn = QRadioButton('real', self)
         vbtn = QRadioButton('virtual', self)
         bgrp.addButton(rbtn)
         bgrp.addButton(vbtn)
         self.grid.addWidget(label, i, 0)
         self.grid.addWidget(rbtn, i, 1)
         self.grid.addWidget(vbtn, i, 2)
         self._widgets.append((label, bgrp, rbtn, vbtn))
     self.resize(self.sizeHint())
     if self.client.isconnected:
         self._update()
     else:
         self.frame.setDisabled(True)
Exemple #5
0
    def __init__(self, parent, _client, **_kwds):
        QMainWindow.__init__(self, parent)
        DlgUtils.__init__(self, 'Hexapod')

        # set during actions that will call signal handlers
        self.recursive = False

        loadUi(self, findResource('nicos_mlz/kws1/gui/tools/hexapod.ui'))

        for but in (self.butStart, self.butSetWorkspace, self.butSetFrame,
                    self.butSaveVel):
            but.setEnabled(False)

        self.axes = {}
        self.axeslist = []

        try:
            self._controller = PyTango.DeviceProxy(TANGO_DEV_BASE +
                                                   'controller')
            # make sure the server is running and create remaining proxies
            try:
                self._controller.State()
            except AttributeError:
                raise Exception('server appears to be not running')
            for axis in AXES:
                self.axes[axis] = PyTango.DeviceProxy(TANGO_DEV_BASE + axis)
                self.axeslist.append(self.axes[axis])
        except Exception as err:
            self.showError('could not connect to tango server: %s' % err)
            self.deleteLater()
            return

        self.on_cbsWorkspace_activated(0)
        self.on_cbsFrame_activated(self.cbsFrame.currentText())

        tx_speed = self.query_attr(self.axes['tx'], 'speed')
        self.inpVelTrans.setValue(tx_speed)
        self.lblVelTrans.setText(self.inpVelTrans.text())
        self.inpVelRot.setValue(self.query_attr(self.axes['rx'], 'speed'))
        self.lblVelRot.setText(self.inpVelRot.text())
        self.inpVelOmega.setValue(self.query_attr(self.axes['omega'], 'speed'))
        self.lblVelOmega.setText(self.inpVelOmega.text())

        # ramp time = speed / acceleration
        self.inpRampUp.setValue(tx_speed /
                                self.query_attr(self.axes['tx'], 'accel'))
        self.lblRampUp.setText(self.inpRampUp.text())
        self.inpRampDown.setValue(tx_speed /
                                  self.query_attr(self.axes['tx'], 'decel'))
        self.lblRampDown.setText(self.inpRampDown.text())

        self.updTimer = QTimer()
        self.updTimer.timeout.connect(self.updateTimer)
        self.updTimer.start(1000)
Exemple #6
0
    def __init__(self, parent):
        QMainWindow.__init__(self, parent)
        DlgUtils.__init__(self, 'Live data')
        self.panel = parent
        layout1 = QVBoxLayout()
        self.plot = QwtPlot(self)
        layout1.addWidget(self.plot)
        self.curve = QwtPlotCurve()
        self.curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
        self.curve.attach(self.plot)
        self.marker = QwtPlotMarker()
        self.marker.attach(self.plot)
        self.markerpen = QPen(Qt.red)
        self.marker.setSymbol(
            QwtSymbol(QwtSymbol.Ellipse, QBrush(), self.markerpen, QSize(7,
                                                                         7)))
        self.zoomer = QwtPlotZoomer(self.plot.canvas())
        self.zoomer.setMousePattern(QwtPlotZoomer.MouseSelect3, Qt.NoButton)
        self.picker = QwtPlotPicker(self.plot.canvas())
        self.picker.setSelectionFlags(QwtPlotPicker.PointSelection
                                      | QwtPlotPicker.ClickSelection)
        self.picker.setMousePattern(QwtPlotPicker.MouseSelect1, Qt.MidButton)
        self.picker.selected.connect(self.pickerSelected)
        layout2 = QHBoxLayout()
        layout2.addWidget(QLabel('Scale:', self))
        self.scale = QComboBox(self)
        self.scale.addItems([
            'Single detectors, sorted by angle',
            'Scattering angle 2theta (deg)', 'Q value (A-1)'
        ])
        self.scale.currentIndexChanged[int].connect(self.scaleChanged)
        layout2.addWidget(self.scale)
        layout2.addStretch()
        self.scaleframe = QFrame(self)
        self.scaleframe.setLayout(layout2)
        self.scaleframe.setVisible(False)
        layout1.addWidget(self.scaleframe)
        mainframe = QFrame(self)
        mainframe.setLayout(layout1)
        self.setCentralWidget(mainframe)
        self.setContentsMargins(6, 6, 6, 6)
        plotfont = scaledFont(self.font(), 0.7)
        self.plot.setAxisFont(QwtPlot.xBottom, plotfont)
        self.plot.setAxisFont(QwtPlot.yLeft, plotfont)
        self.plot.setCanvasBackground(Qt.white)
        self.resize(800, 200)

        self._detinfo = None
        self._anglemap = None
        self._infowindow = None
        self._infolabel = None
        self._xs = self._ys = None
        self._type = None
Exemple #7
0
    def __init__(self, parent, info=None, client=None):
        QDialog.__init__(self, parent)
        DlgUtils.__init__(self, 'History viewer')
        loadUi(self, 'panels/history_new.ui')
        self.client = client

        self.fromdate.setDateTime(QDateTime.currentDateTime())
        self.todate.setDateTime(QDateTime.currentDateTime())

        self.customY.toggled.connect(self.toggleCustomY)
        self.toggleCustomY(False)

        self.simpleTime.toggled.connect(self.toggleSimpleExt)
        self.extTime.toggled.connect(self.toggleSimpleExt)
        self.frombox.toggled.connect(self.toggleSimpleExt)
        self.tobox.toggled.connect(self.toggleSimpleExt)
        self.toggleSimpleExt(True)

        self.simpleTimeSpec.textChanged.connect(self.setIntervalFromSimple)

        self.helpButton.clicked.connect(self.showDeviceHelp)
        self.simpleHelpButton.clicked.connect(self.showSimpleHelp)

        self.devicesFrame.hide()
        self.deviceTree = None
        self.deviceTreeSel = OrderedDict()
        if not client:
            self.devicesExpandBtn.hide()
        else:
            devices = client.getDeviceList()
            devcompleter = QCompleter(devices, self)
            devcompleter.setCompletionMode(QCompleter.InlineCompletion)
            self.devices.setCompleter(devcompleter)

        if info is not None:
            self.devices.setText(info['devices'])
            self.namebox.setText(info['name'])
            self.simpleTime.setChecked(info['simpleTime'])
            self.simpleTimeSpec.setText(info['simpleTimeSpec'])
            self.slidingWindow.setChecked(info['slidingWindow'])
            self.extTime.setChecked(not info['simpleTime'])
            self.frombox.setChecked(info['frombox'])
            self.tobox.setChecked(info['tobox'])
            self.fromdate.setDateTime(QDateTime.fromTime_t(info['fromdate']))
            self.todate.setDateTime(QDateTime.fromTime_t(info['todate']))
            self.interval.setText(info['interval'])
            self.customY.setChecked(info['customY'])
            self.customYFrom.setText(info['customYFrom'])
            self.customYTo.setText(info['customYTo'])
Exemple #8
0
 def __init__(self, parent, client, options):
     QWidget.__init__(self, parent)
     self.log = NicosLogger(self.panelName)
     self.log.parent = parent.mainwindow.log
     SetupDepPanelMixin.__init__(self, client, options)
     DlgUtils.__init__(self, self.panelName)
     self.parentwindow = parent
     self.client = client
     self.mainwindow = parent.mainwindow
     self.actions = set()
     self.sgroup = SettingGroup(self.panelName)
     with self.sgroup as settings:
         self.loadSettings(settings)
     self.setProperty('type', 'Panel')
     self.setProperty('panel', self.__class__.__name__)
Exemple #9
0
    def __init__(self, window, timeaxis=False):
        DlgUtils.__init__(self, 'Plot')
        self.window = window
        self.plotcurves = []
        self.show_all = False
        self.timeaxis = timeaxis
        self.hasSymbols = False
        self.hasLines = True

        # currently selected normalization column
        self.normalized = None

        self.fitter = None

        font = self.window.user_font
        bold = QFont(font)
        bold.setBold(True)
        larger = scaledFont(font, 1.6)
        self.setFonts(font, bold, larger)
Exemple #10
0
    def __init__(self, parent, client, **kwds):
        QDialog.__init__(self, parent)
        DlgUtils.__init__(self, self.toolName)
        loadUi(self, 'tools/bugreport.ui')
        self.client = client

        settings = QSettings('nicos', 'secrets')
        settings.beginGroup('Redmine')
        self.instrument = settings.value('instrument', '')
        self.apikey = settings.value('apikey')
        self.username = settings.value('username')

        self.traceback = kwds.get('traceback')
        self.log_excerpt = kwds.get('log_excerpt', '')
        if not self.traceback:
            self.tbLabel.hide()
            self.scriptBox.hide()
        else:
            self.ticketType.setEnabled(False)  # always bug
            self.scriptBox.setChecked(True)
            self.subject.setText(self.traceback.splitlines()[-1].strip())

        self.stacker.setCurrentIndex(0)
        self.subject.setFocus()
        btn = self.buttonBox.addButton('Login details',
                                       QDialogButtonBox.ResetRole)
        btn.clicked.connect(self._queryDetails)

        if not redminelib:
            self.showError('Reporting is not possible since the '
                           'python-redmine module is not installed.')
            return  # don't add Submit button
        elif not self.instrument or not self.apikey:
            if not self._queryDetails():
                return

        self.buttonBox.addButton('Submit', QDialogButtonBox.AcceptRole)

        self.titleLabel.setText(
            'Submit a ticket for instrument "%s" (as user %s)'
            % (self.instrument, self.username))
Exemple #11
0
    def __init__(self, parent, measdef, client):
        self.measdef = measdef
        self.samplefile = None
        self.client = client
        DlgUtils.__init__(self, 'Sample selection')
        QDialog.__init__(self, parent)
        loadUi(self, findResource('nicos_ess/loki/gui/ui_files/samples.ui'))

        self._init_samplefile = False
        self.samplefile = measdef.samplefile
        if self.samplefile is not None:
            self._init_samplefile = True
            self.on_sampleFileBtn_toggled(True)
            self._init_samplefile = False
        else:
            self.on_currentSamplesBtn_toggled(True)

        if self.measdef.samples:
            for sam in self.measdef.samples[0]:
                newitem = QListWidgetItem(sam['sample'].getValue(),
                                          self.selList)
                newitem.setData(SAMPLE_NUM, sam['sample'].extra[0])
Exemple #12
0
    def __init__(self, log, gui_conf, viewonly=False, tunnel=''):
        QMainWindow.__init__(self)
        DlgUtils.__init__(self, 'NICOS')
        loadUi(self, self.ui)

        # set app icon in multiple sizes
        icon = QIcon()
        icon.addFile(':/appicon')
        icon.addFile(':/appicon-16')
        icon.addFile(':/appicon-48')
        self.setWindowIcon(icon)

        if tunnel and SSHTunnelForwarder is None:
            self.showError('You want to establish a connection to NICOS via '
                           "a SSH tunnel, but the 'sshtunnel' module is not "
                           'installed. The tunneling feature will disabled.')
        self.tunnel = tunnel if SSHTunnelForwarder is not None else ''
        self.tunnelServer = None

        # hide admin label until we are connected as admin
        self.adminLabel.hide()

        # our logger instance
        self.log = log

        # window for displaying errors
        self.errorWindow = None

        # window for "prompt" event confirmation
        self.promptWindow = None

        # debug console window, if opened
        self.debugConsole = None

        # log messages sent by the server
        self.messages = []

        # are we in expert mode?  (always false on startup)
        self.expertmode = False

        # no wrapping at startup
        self.allowoutputlinewrap = False

        # set-up the initial connection data
        self.conndata = ConnectionData(host='localhost',
                                       port=1301,
                                       user='******',
                                       password=None,
                                       viewonly=viewonly)

        # state members
        self.current_status = None

        # connect the client's events
        self.client = NicosGuiClient(self, self.log)
        self.client.error.connect(self.on_client_error)
        self.client.broken.connect(self.on_client_broken)
        self.client.failed.connect(self.on_client_failed)
        self.client.connected.connect(self.on_client_connected)
        self.client.disconnected.connect(self.on_client_disconnected)
        self.client.status.connect(self.on_client_status)
        self.client.showhelp.connect(self.on_client_showhelp)
        self.client.clientexec.connect(self.on_client_clientexec)
        self.client.plugplay.connect(self.on_client_plugplay)
        self.client.watchdog.connect(self.on_client_watchdog)
        self.client.prompt.connect(self.on_client_prompt)

        # data handling setup
        self.data = DataHandler(self.client)

        # panel configuration
        self.gui_conf = gui_conf
        self.initDataReaders()
        self.mainwindow = self

        # determine if there is an editor window type, because we would like to
        # have a way to open files from a console panel later
        self.editor_wintype = self.gui_conf.find_panel(
            ('editor.EditorPanel',
             'nicos.clients.gui.panels.editor.EditorPanel'))
        self.history_wintype = self.gui_conf.find_panel(
            ('history.HistoryPanel',
             'nicos.clients.gui.panels.history.HistoryPanel'))

        # additional panels
        self.panels = []
        self.splitters = []
        self.windowtypes = []
        self.windows = {}

        # setting presets
        self.instrument = self.gui_conf.name

        self.createWindowContent()

        # timer for reconnecting
        self.reconnectTimer = QTimer(singleShot=True, timeout=self._reconnect)
        self._reconnect_count = 0
        self._reconnect_time = 0

        # timer for session keepalive, every 12 hours
        self.keepaliveTimer = QTimer(singleShot=False, timeout=self._keepalive)
        self.keepaliveTimer.start(self.keepaliveInterval)

        # setup tray icon
        self.trayIcon = QSystemTrayIcon(self)
        self.trayIcon.activated.connect(self.on_trayIcon_activated)
        self.trayMenu = QMenu(self)
        nameAction = self.trayMenu.addAction(self.instrument)
        nameAction.setEnabled(False)
        self.trayMenu.addSeparator()
        toggleAction = self.trayMenu.addAction('Hide main window')
        toggleAction.setCheckable(True)
        toggleAction.triggered[bool].connect(
            lambda hide: self.setVisible(not hide))
        self.trayIcon.setContextMenu(self.trayMenu)

        # help window
        self.helpWindow = None
        # watchdog window
        self.watchdogWindow = None
        # plug-n-play notification windows
        self.pnpWindows = {}

        # create initial state
        self._init_toolbar()