Exemplo n.º 1
0
    def restore_geometry(self):
        x = CONF.get('Window', 'x')
        y = CONF.get('Window', 'y')
        w = CONF.get('Window', 'width')
        h = CONF.get('Window', 'height')

        self.setGeometry(x, y, w, h)
Exemplo n.º 2
0
    def _on_accept(self):
        """ Update connection settings, reconnect with new settings."""
        self.instr.visa_library = self.lineEditLibrary.text()
        self.instr.visa_address = self.comboBoxAddress.currentText()

        CONF.set('Connection', 'VISA_LIBRARY', self.instr.visa_library)
        CONF.set('Connection', 'VISA_ADDRESS', self.instr.visa_address)

        # reconnect with new address
        # close and reopen ResourceManager for visa_lib path change to take effect
        # TODO: this needs testing
        if self.instr.connected:
            self.instr.disconnect()
            time.sleep(0.2)  # wait for pending comminication to finish

        self.instr.rm.close()

        try:
            self.instr.rm = visa.ResourceManager(self.instr.visa_library)

        except ValueError:
            msg = ('Could not find backend %s.\n' % self.lineEditLibrary.text() +
                   'Using default backend instead.')
            QtWidgets.QMessageBox.information(self, str('error'), msg)

            self.instr.visa_library = ''
            self.instr.rm = visa.ResourceManager()

            self.populate_ui_from_instr()

        self.instr.connect()
Exemplo n.º 3
0
def run():

    from mercuryitc import MercuryITC
    from mercurygui.config.main import CONF

    app = QtWidgets.QApplication(sys.argv)

    mercury_address = CONF.get("Connection", "VISA_ADDRESS")
    visa_library = CONF.get("Connection", "VISA_LIBRARY")

    mercury = MercuryITC(mercury_address, visa_library, open_timeout=1)

    mercury_gui = MercuryMonitorApp(mercury)
    mercury_gui.show()

    app.exec_()
Exemplo n.º 4
0
def connect_to_instruments():
    """
    Tries to connect to Keithley, Mercury and Xepr. Uses the visa
    addresses saved in the respective configuration files.

    :returns: Tuple containing instrument instances.
    :rtype: tuple
    """

    from keithley2600 import Keithley2600
    from keithleygui.config.main import CONF as KCONF
    from mercuryitc import MercuryITC
    from mercurygui.config.main import CONF as MCONF

    keithley_address = KCONF.get("Connection", "VISA_ADDRESS")
    keithley_visa_lib = KCONF.get("Connection", "VISA_LIBRARY")
    mercury_address = MCONF.get("Connection", "VISA_ADDRESS")
    mercury_visa_lib = MCONF.get("Connection", "VISA_LIBRARY")

    try:
        # Search for the XeprAPI in the following locations, use the first match:
        # 1) path from environment variable, if given
        # 2) installed python package
        # 3) pre-installed version with Xepr
        sys.path.insert(0, ENVIRON_XEPR_API_PATH)
        sys.path.insert(-1, BRUKER_XEPR_API_PATH)
        from XeprAPI import Xepr

        xepr = Xepr()
    except ImportError:
        logging.info("XeprAPI could not be located.")
        xepr = None
    except IOError:
        logging.info("No running Xepr instance could be found.")
        xepr = None

    mercury = MercuryITC(mercury_address,
                         mercury_visa_lib,
                         open_timeout=1,
                         timeout=5000)
    keithley = Keithley2600(keithley_address,
                            keithley_visa_lib,
                            open_timeout=1,
                            timeout=5000)

    return xepr, mercury, keithley
Exemplo n.º 5
0
def run():

    from mercuryitc import MercuryITC
    from mercurygui.config.main import CONF

    mercury_address = CONF.get('Connection', 'VISA_ADDRESS')
    visa_library = CONF.get('Connection', 'VISA_LIBRARY')

    mercury = MercuryITC(mercury_address, visa_library)

    app = QtWidgets.QApplication(sys.argv)
    app.aboutToQuit.connect(app.deleteLater)

    feed = MercuryFeed(mercury)
    mercury_gui = MercuryMonitorApp(feed)
    mercury_gui.show()

    app.exec_()
Exemplo n.º 6
0
    def __init__(self, mercury_modules):
        super(self.__class__, self).__init__()
        uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                'module_dialog.ui'), self)

        num = len(mercury_modules)
        temp_modules_nick = []
        self.temp_modules = []
        gas_modules_nick = []
        self.gas_modules = []
        heat_modules_nick = []
        self.heat_modules = []

        self.modNumbers = {}

        for i in range(num-1, -1, -1):
            address = mercury_modules[i].address
            type_ = address.split(':')[-1]
            nick = mercury_modules[i].nick
            if type_ == 'AUX':
                gas_modules_nick.append(nick)
                self.gas_modules.append(i)
            elif type_ == 'HTR':
                heat_modules_nick.append(nick)
                self.heat_modules.append(i)
            elif type_ == 'TEMP':
                if nick not in temp_modules_nick:
                    temp_modules_nick.append(nick)
                    self.temp_modules.append(i)

        self.comboBox.addItems(temp_modules_nick)
        self.comboBox_2.addItems(gas_modules_nick)
        self.comboBox_3.addItems(heat_modules_nick)

        # get default modules
        self.comboBox.setCurrentIndex(CONF.get('MercuryFeed', 'temperature_module'))
        self.comboBox_2.setCurrentIndex(CONF.get('MercuryFeed', 'gasflow_module'))
        self.comboBox_3.setCurrentIndex(CONF.get('MercuryFeed', 'heater_module'))

        self.modNumbers['temperature'] = self.temp_modules[self.comboBox.currentIndex()]
        self.modNumbers['gasflow'] = self.gas_modules[self.comboBox_2.currentIndex()]
        self.modNumbers['heater'] = self.heat_modules[self.comboBox_3.currentIndex()]

        self.buttonBox.accepted.connect(self._on_accept)
Exemplo n.º 7
0
    def _on_accept(self):
        self.modNumbers['temperature'] = self.temp_modules[self.comboBox.currentIndex()]
        self.modNumbers['gasflow'] = self.gas_modules[self.comboBox_2.currentIndex()]
        self.modNumbers['heater'] = self.heat_modules[self.comboBox_3.currentIndex()]

        # update default modules
        CONF.set('MercuryFeed', 'temperature_module', self.comboBox.currentIndex())
        CONF.set('MercuryFeed', 'gasflow_module', self.comboBox_2.currentIndex())
        CONF.set('MercuryFeed', 'heater_module', self.comboBox_3.currentIndex())

        self.accepted.emit(self.modNumbers)
Exemplo n.º 8
0
 def save_geometry(self):
     geo = self.geometry()
     CONF.set('Window', 'height', geo.height())
     CONF.set('Window', 'width', geo.width())
     CONF.set('Window', 'x', geo.x())
     CONF.set('Window', 'y', geo.y())
Exemplo n.º 9
0
        self.readings['Temp'] = self.temperature.temp[0]
        self.readings['TempSetpoint'] = self.control.t_setpoint
        self.readings['TempRamp'] = self.control.ramp
        self.readings['TempRampEnable'] = self.control.ramp_enable

        self.readings_signal.emit(self.readings)

    def update_modules(self, mod_numbers):
        """
        Updates module list after the new modules have been selected in dialog.
        """
        self.gasflow = self.mercury.modules[mod_numbers['gasflow']]
        self.heater = self.mercury.modules[mod_numbers['heater']]
        self.temperature = self.mercury.modules[mod_numbers['temperature']]
        self.control = self.mercury.modules[mod_numbers['temperature'] + 1]


# if we're running the file directly and not importing it
if __name__ == '__main__':

    from mercuryitc import MercuryITC

    # check if event loop is already running (e.g. in IPython),
    # otherwise create a new one
    app = QtWidgets.QApplication(sys.argv)

    m = MercuryITC(CONF.get('Connection', 'VISA_ADDRESS'))
    feed = MercuryFeed(m)

    sys.exit(app.exec_())