Exemplo n.º 1
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        self.shutter_widget = QCustomSwitchChannel('399/Oven/ProtectionBeam',
                                                   ('Open/Oven On', 'Closed/Oven Off'))
        self.shutter_widget.TTLswitch.toggled.connect(self.toggle)
        self.timer_widget = QCustomTimer('Loading Time', show_control=False)
        self.current_widget = QCustomSpinBox("Current ('A')", (0.0, 3.0))

        self.current_widget.setStepSize(0.01)
        self.current_widget.spinLevel.setDecimals(2)
        self.current_widget.spinLevel.valueChanged.connect(self.current_changed)

        if 'oven' in self.settings:
            value = yield self.reg.get('oven')
            self.current_widget.spinLevel.setValue(value)

        if '399 trapshutter' in self.settings:
            value = yield self.reg.get('399 trapshutter')
            value = bool(value)
            self.shutter_widget.TTLswitch.setChecked(value)
        else:
            self.shutter_widget.TTLswitch.setChecked(False)

        layout.addWidget(self.current_widget, 1, 1)
        layout.addWidget(self.shutter_widget, 0, 0)
        layout.addWidget(self.timer_widget, 0, 1)
        self.setLayout(layout)
Exemplo n.º 2
0
    def setup_widget(self):

        self.spinBox = QCustomSpinBox(self.name, (self.minval, self.maxval))
        self.init_voltage = 0.0
        self.spinBox.spinLevel.setValue(0.0)

        self.spinBox.setStepSize(0.0001)
        self.spinBox.spinLevel.setDecimals(4)
Exemplo n.º 3
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()

        control = QCustomSpinBox("DC value ('V')", (-5.0, 5.0))
        control.setStepSize(0.0001)
        control.spinLevel.setDecimals(4)
        control.spinLevel.valueChanged.connect(self.set_dac)
        layout.addWidget(control)
        self.setLayout(layout)
Exemplo n.º 4
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()

        control = QCustomSpinBox("DC value ('V')", (-5.0, 5.0))
        control.setStepSize(0.0001)
        control.spinLevel.setDecimals(4)
        control.spinLevel.valueChanged.connect(self.set_dac)
        layout.addWidget(control)
        self.setLayout(layout)
Exemplo n.º 5
0
class StepperControl(QtGui.QWidget):
    def __init__(self, reactor):
        super(StepperControl, self).__init__()
        self.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        self.degree_per_step = 1.8
        self.angle = 0.0
        self.connect()

    @inlineCallbacks
    def connect(self):
        """Creates an Asynchronous connection to stepper server and
        connects incoming signals to relavent functions

        """

        from labrad.wrappers import connectAsync
        self.cxn = yield connectAsync()
        self.server = self.cxn.stepper_motor_server
        self.initializeGUI()

    def initializeGUI(self):
        layout = QtGui.QGridLayout()

        zerowidget = QtGui.QPushButton('Zero')
        self.degreewidget = QCustomSpinBox('Angle', (-10000, 10000.0))
        self.angle_label = QtGui.QLabel('0.0')
        self.degreewidget.setStepSize(1.8)
        self.degreewidget.spinLevel.setDecimals(3)

        self.degreewidget.spinLevel.setValue(self.angle)

        self.degreewidget.spinLevel.valueChanged.connect(self.change_angle)
        zerowidget.clicked.connect(self.zero_scale)

        layout.addWidget(zerowidget, 0, 0)
        layout.addWidget(self.degreewidget, 0, 1)
        layout.addWidget(self.angle_label, 0, 2)

        self.setLayout(layout)

    def zero_scale(self, state):
        self.angle = 0.0
        self.degreewidget.spinLevel.setValue(0.0)

    @inlineCallbacks
    def change_angle(self, angle):
        difference = angle - self.angle
        steps = difference / self.degree_per_step
        steps = int(steps)
        self.angle = self.angle + self.degree_per_step * steps
        self.angle_label.setText(str(self.angle))
        self.degreewidget.spinLevel.setValue(angle)
        yield self.server.move_steps(steps)

    def closeEvent(self, x):
        self.reactor.stop()
Exemplo n.º 6
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        lockwidget = QCustomSwitchChannel('Lock Cal', ('Locked', 'Unlocked'))
        lockwidget.TTLswitch.toggled.connect(self.toggle)

        offsetwidget = QCustomSpinBox('DC offset', (-1.0, 1.0))
        setpointwidget = QCustomSpinBox('Set Point', (811.0, 812.0))
        gainwidget = QCustomSpinBox('Gain', (0.1, 10000.0))

        offsetwidget.setStepSize(0.001)
        setpointwidget.setStepSize(0.000001)
        gainwidget.setStepSize(0.1)

        offsetwidget.spinLevel.setDecimals(3)
        setpointwidget.spinLevel.setDecimals(6)
        gainwidget.spinLevel.setDecimals(1)

        setpointwidget.spinLevel.setValue(self.set)
        gainwidget.spinLevel.setValue(self.gain)

        offsetwidget.spinLevel.valueChanged.connect(self.offset)
        setpointwidget.spinLevel.valueChanged.connect(self.set_point)
        gainwidget.spinLevel.valueChanged.connect(self.set_gain)

        layout.addWidget(lockwidget, 0, 0)
        layout.addWidget(offsetwidget, 0, 1)
        layout.addWidget(setpointwidget, 0, 2)
        layout.addWidget(gainwidget, 0, 3)

        self.setLayout(layout)
Exemplo n.º 7
0
    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        qBox = QtGui.QGroupBox("DAC Channels")
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        for v, dac in enumerate(self.dacinfo):
            name = self.dacinfo[dac][0]
            dacchan = self.dacinfo[dac][1]

            widget = QCustomSpinBox(name, (0, 255))
            widget.title.setFixedWidth(120)
            label = QtGui.QLabel("0 V")
            if name + " dac" in self.settings:
                value = yield self.reg.get(name + " dac")
                widget.spinLevel.setValue(value)
                self.setvalue(value, [name, dacchan])
            else:
                widget.spinLevel.setValue(0.0)
            widget.setStepSize(1)
            widget.spinLevel.setDecimals(0)
            widget.spinLevel.valueChanged.connect(
                lambda value=widget.spinLevel.value(), ident=[name, dacchan]: self.setvalue(value, ident)
            )
            self.d[dacchan] = widget
            self.e[dacchan] = label
            subLayout.addWidget(self.d[dacchan], v, 1)
            subLayout.addWidget(self.e[dacchan], v, 2)

        self.ezupwidget = QPushButton("Ez increase")
        self.ezdownwidget = QPushButton("Ez decrease")
        self.exupwidget = QPushButton("Ex increase")
        self.exdownwidget = QPushButton("Ex decrease")
        self.eyupwidget = QPushButton("Ey increase")
        self.eydownwidget = QPushButton("Ey decrease")

        self.ezupwidget.clicked.connect(self.ezup)
        self.ezdownwidget.clicked.connect(self.ezdown)
        self.exupwidget.clicked.connect(self.exup)
        self.exdownwidget.clicked.connect(self.exdown)
        self.eyupwidget.clicked.connect(self.eyup)
        self.eydownwidget.clicked.connect(self.eydown)

        subLayout.addWidget(self.ezupwidget, 0, 5)
        subLayout.addWidget(self.ezdownwidget, 1, 5)
        subLayout.addWidget(self.exupwidget, 3, 6)
        subLayout.addWidget(self.exdownwidget, 3, 3)
        subLayout.addWidget(self.eyupwidget, 2, 5)
        subLayout.addWidget(self.eydownwidget, 4, 5)

        self.setLayout(layout)
Exemplo n.º 8
0
    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        qBox = QtGui.QGroupBox('DAC Channels')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        for v, dac in enumerate(self.dacinfo):
            name = self.dacinfo[dac][0]
            dacchan = self.dacinfo[dac][1]

            widget = QCustomSpinBox(name, (0, 255))
            widget.title.setFixedWidth(120)
            label = QtGui.QLabel('0 V')
            if name + ' dac' in self.settings:
                value = yield self.reg.get(name + ' dac')
                widget.spinLevel.setValue(value)
                self.setvalue(value, [name, dacchan])
            else:
                widget.spinLevel.setValue(0.0)
            widget.setStepSize(1)
            widget.spinLevel.setDecimals(0)
            widget.spinLevel.valueChanged.connect(
                lambda value=widget.spinLevel.value(
                ), ident=[name, dacchan]: self.setvalue(value, ident))
            self.d[dacchan] = widget
            self.e[dacchan] = label
            subLayout.addWidget(self.d[dacchan], v, 1)
            subLayout.addWidget(self.e[dacchan], v, 2)

        self.ezupwidget = QPushButton('Ez increase')
        self.ezdownwidget = QPushButton('Ez decrease')
        self.exupwidget = QPushButton('Ex increase')
        self.exdownwidget = QPushButton('Ex decrease')
        self.eyupwidget = QPushButton('Ey increase')
        self.eydownwidget = QPushButton('Ey decrease')

        self.ezupwidget.clicked.connect(self.ezup)
        self.ezdownwidget.clicked.connect(self.ezdown)
        self.exupwidget.clicked.connect(self.exup)
        self.exdownwidget.clicked.connect(self.exdown)
        self.eyupwidget.clicked.connect(self.eyup)
        self.eydownwidget.clicked.connect(self.eydown)

        subLayout.addWidget(self.ezupwidget, 0, 5)
        subLayout.addWidget(self.ezdownwidget, 1, 5)
        subLayout.addWidget(self.exupwidget, 3, 6)
        subLayout.addWidget(self.exdownwidget, 3, 3)
        subLayout.addWidget(self.eyupwidget, 2, 5)
        subLayout.addWidget(self.eydownwidget, 4, 5)

        self.setLayout(layout)
Exemplo n.º 9
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        self.shutter_widget = QCustomSwitchChannel('399 Trap',
                                                   ('Open', 'Closed'))
        self.shutter_widget.TTLswitch.toggled.connect(self.toggle)
        self.timer_widget = QCustomTimer('Loading Time', show_control=False)
        self.disc_widget = QCustomSpinBox('kcts/s',
                                          (0.0, 999.0))

        qBox = QtGui.QGroupBox('Discriminator')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)

        subLayout.addWidget(self.disc_widget)

        self.disc_widget.setStepSize(0.1)
        self.disc_widget.spinLevel.setDecimals(1)
        self.disc_widget.spinLevel.valueChanged.connect(self.disc_changed)

        if 'discriminator' in self.settings:
            value = yield self.reg.get('discriminator')
            self.disc_widget.spinLevel.setValue(value)

        if '399 trapshutter' in self.settings:
            value = yield self.reg.get('399 trapshutter')
            value = bool(value)
            self.shutter_widget.TTLswitch.setChecked(value)
        else:
            self.shutter_widget.TTLswitch.setChecked(False)

        layout.addWidget(self.shutter_widget, 0, 0)
        layout.addWidget(qBox, 0, 1)
        layout.addWidget(self.timer_widget, 0, 2)
        self.setLayout(layout)
Exemplo n.º 10
0
    def setup_widget(self):

        self.spinBox = QCustomSpinBox(self.name, (self.minval, self.maxval))
        self.init_voltage = 0.0
        self.spinBox.spinLevel.setValue(0.0)

        self.spinBox.setStepSize(0.0001)
        self.spinBox.spinLevel.setDecimals(4)
Exemplo n.º 11
0
class Electrode():
    def __init__(self, dac, octant, minval, maxval):

        self.dac = dac
        self.octant = octant
        self.minval = minval
        self.maxval = maxval
        self.name = str('DAC: ' + str(dac))
        self.setup_widget()

    def setup_widget(self):

        self.spinBox = QCustomSpinBox(self.name, (self.minval, self.maxval))
        self.init_voltage = 0.0
        self.spinBox.spinLevel.setValue(0.0)

        self.spinBox.setStepSize(0.0001)
        self.spinBox.spinLevel.setDecimals(4)
Exemplo n.º 12
0
class Electrode():

    def __init__(self, dac, octant, minval, maxval):

        self.dac = dac
        self.octant = octant
        self.minval = minval
        self.maxval = maxval
        self.name = str('DAC: ' + str(dac))
        self.setup_widget()

    def setup_widget(self):

        self.spinBox = QCustomSpinBox(self.name, (self.minval, self.maxval))
        self.init_voltage = 0.0
        self.spinBox.spinLevel.setValue(0.0)

        self.spinBox.setStepSize(0.0001)
        self.spinBox.spinLevel.setDecimals(4)
Exemplo n.º 13
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()

        zerowidget = QtGui.QPushButton('Zero')
        self.degreewidget = QCustomSpinBox('Angle', (-10000, 10000.0))
        self.angle_label = QtGui.QLabel('0.0')
        self.degreewidget.setStepSize(1.8)
        self.degreewidget.spinLevel.setDecimals(3)

        self.degreewidget.spinLevel.setValue(self.angle)

        self.degreewidget.spinLevel.valueChanged.connect(self.change_angle)
        zerowidget.clicked.connect(self.zero_scale)

        layout.addWidget(zerowidget, 0, 0)
        layout.addWidget(self.degreewidget, 0, 1)
        layout.addWidget(self.angle_label, 0, 2)

        self.setLayout(layout)
Exemplo n.º 14
0
    def initialize_GUI(self):
        layout = QtGui.QGridLayout()
        self.electrodes = {}
        qBox = QtGui.QGroupBox('DAC Channels')

        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.electrodeind = ElectrodeIndicator([-12, 12])
        multipole_names = ['Ey', 'Ez', 'Ex', 'M1', 'M2', 'M3', 'M4', 'M5']
        self.multipoles = []
        j = 0
        for i, multipole in enumerate(multipole_names):
            k = i
            if i >= 4:
                j = 1
                i = i - 4
            spinbox = QCustomSpinBox(multipole, (-100, 100))
            spinbox.setStepSize(0.001)
            spinbox.spinLevel.setDecimals(3)
            spinbox.spinLevel.setValue(self.init_multipoles[k])
            spinbox.spinLevel.valueChanged.connect(self.change_multipole)
            layout.addWidget(spinbox, 3 + j, i + 1, 1, 1)
            self.multipoles.append(spinbox)

        layout.addWidget(self.electrodeind, 0, 1, 1, 3)

        for key, channel in self.elec_dict.iteritems():
            electrode = Electrode(channel.dacChannelNumber,
                                  channel.octantNumber,
                                  channel.allowedVoltageRange[0],
                                  channel.allowedVoltageRange[1])
            self.electrodes[electrode.octant] = electrode
            subLayout.addWidget(electrode.spinBox)
            electrode.spinBox.spinLevel.valueChanged.connect(
                lambda value=electrode.spinBox.spinLevel.value(
                ), electrode=electrode: self.update_dac(value, electrode))

        self.change_multipole('dummy value')
        self.setLayout(layout)
Exemplo n.º 15
0
    def initialize_GUI(self):
        layout = QtGui.QGridLayout()
        self.electrodes = {}
        qBox = QtGui.QGroupBox('DAC Channels')

        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.electrodeind = ElectrodeIndicator([-12, 12])
        multipole_names = ['Ey', 'Ez', 'Ex', 'M1', 'M2', 'M3', 'M4', 'M5']
        self.multipoles = []
        j = 0
        for i, multipole in enumerate(multipole_names):
            k = i
            if i >= 4:
                j = 1
                i = i - 4
            spinbox = QCustomSpinBox(multipole, (-100, 100))
            spinbox.setStepSize(0.001)
            spinbox.spinLevel.setDecimals(3)
            spinbox.spinLevel.setValue(self.init_multipoles[k])
            spinbox.spinLevel.valueChanged.connect(self.change_multipole)
            layout.addWidget(spinbox, 3 + j, i + 1, 1, 1)
            self.multipoles.append(spinbox)

        layout.addWidget(self.electrodeind, 0, 1, 1, 3)

        for key, channel in self.elec_dict.iteritems():
            electrode = Electrode(channel.dacChannelNumber, channel.octantNumber,
                                  channel.allowedVoltageRange[0], channel.allowedVoltageRange[1])
            self.electrodes[electrode.octant] = electrode
            subLayout.addWidget(electrode.spinBox)
            electrode.spinBox.spinLevel.valueChanged.connect(lambda value=electrode.spinBox.spinLevel.value(),
                                                             electrode=electrode: self.update_dac(value, electrode))

        self.change_multipole('dummy value')
        self.setLayout(layout)
Exemplo n.º 16
0
    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        self.setWindowTitle('kiethley Control')

        qBox = QtGui.QGroupBox('Kiethley 2230G')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.volt1widget = QCustomSpinBox('Amplitude (Vpp)', (0, 30))
        self.volt2widget = QCustomSpinBox('Amplitude (Vpp)', (0, 30))

        self.volt1widget.spinLevel.valueChanged.connect(
            lambda value=self.volt1widget.spinLevel.value(
            ), chan=1: self.voltchanged(chan, value))
        self.volt2widget.spinLevel.valueChanged.connect(
            lambda value=self.volt2widget.spinLevel.value(
            ), chan=2: self.voltchanged(chan, value))
        subLayout.addWidget(self.volt1widget, 1, 1)
        subLayout.addWidget(self.volt2widget, 1, 3)
        self.setLayout(layout)
Exemplo n.º 17
0
class rigolclient(QtGui.QWidget):
    def __init__(self, reactor, parent=None):
        """initializels the GUI creates the reactor
        """
        super(rigolclient, self).__init__()
        self.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        self.reactor = reactor
        self.connect()

    @inlineCallbacks
    def connect(self):
        """Creates an Asynchronous connection
        """
        from labrad.wrappers import connectAsync
        from labrad.units import WithUnit as U
        self.U = U
        self.cxn = yield connectAsync(name="rigol client")
        self.server = self.cxn.rigol_dg1022a_server
        self.devicelist = yield self.server.list_devices()
        if self.devicelist:
            yield self.server.select_device(0)
        self.initializeGUI()

    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        self.setWindowTitle('Rigol DG1022 Control')

        qBox = QtGui.QGroupBox('Rigol DG1022')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.deviceselect = QtGui.QComboBox(self)
        self.updatedevices()

        self.offsetwidget1 = QCustomSpinBox('Offset', (-5, 5))
        self.offsetwidget2 = QCustomSpinBox('Offset', (-5, 5))
        self.volt1widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq1widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.volt2widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq2widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.waveselect1 = QtGui.QComboBox(self)
        self.waveselect2 = QtGui.QComboBox(self)
        self.output1 = TextChangingButton(('On', 'Off'))
        self.output2 = TextChangingButton(('On', 'Off'))

        self.waveselect1.addItem("sine")
        self.waveselect1.addItem("square")
        self.waveselect1.addItem("ramp")
        self.waveselect1.addItem("pulse")
        self.waveselect1.addItem("noise")
        self.waveselect1.addItem("DC")
        self.waveselect1.addItem("USER")

        self.waveselect2.addItem("sine")
        self.waveselect2.addItem("square")
        self.waveselect2.addItem("ramp")
        self.waveselect2.addItem("pulse")
        self.waveselect2.addItem("noise")
        self.waveselect2.addItem("DC")
        self.waveselect2.addItem("USER")

        self.output1.toggled.connect(lambda state=self.output1.isDown(), chan=
                                     1, : self.setoutput(chan, state))
        self.output2.toggled.connect(lambda state=self.output1.isDown(), chan=
                                     2, : self.setoutput(chan, state))
        self.volt1widget.spinLevel.valueChanged.connect(
            lambda value=self.volt1widget.spinLevel.value(
            ), chan=1: self.voltchanged(chan, value))
        self.volt2widget.spinLevel.valueChanged.connect(
            lambda value=self.volt2widget.spinLevel.value(
            ), chan=2: self.voltchanged(chan, value))
        self.freq1widget.spinLevel.valueChanged.connect(
            lambda value=self.freq1widget.spinLevel.value(
            ), chan=1: self.freqchanged(chan, value))
        self.freq2widget.spinLevel.valueChanged.connect(
            lambda value=self.freq2widget.spinLevel.value(
            ), chan=2: self.freqchanged(chan, value))
        self.offsetwidget1.spinLevel.valueChanged.connect(
            lambda value=self.offsetwidget1.spinLevel.value(
            ), chan=1: self.offsetchanged(chan, value))
        self.offsetwidget2.spinLevel.valueChanged.connect(
            lambda value=self.offsetwidget2.spinLevel.value(
            ), chan=2: self.offsetchanged(chan, value))
        self.waveselect1.activated[str].connect(
            lambda wave=self.waveselect1.currentText(
            ), chan=1: self.waveselect(chan, wave))
        self.waveselect2.activated[str].connect(
            lambda wave=self.waveselect2.currentText(
            ), chan=2: self.waveselect(chan, wave))
        self.deviceselect.activated[str].connect(self.changedevice)
        subLayout.addWidget(self.freq1widget, 1, 0)
        subLayout.addWidget(self.volt1widget, 1, 1)
        subLayout.addWidget(self.freq2widget, 1, 2)
        subLayout.addWidget(self.volt2widget, 1, 3)
        subLayout.addWidget(self.waveselect1, 2, 0, 1, 2)
        subLayout.addWidget(self.waveselect2, 2, 2, 1, 2)
        subLayout.addWidget(self.offsetwidget1, 3, 0)
        subLayout.addWidget(self.offsetwidget2, 3, 2)
        subLayout.addWidget(self.output1, 3, 1)
        subLayout.addWidget(self.output2, 3, 3)
        subLayout.addWidget(self.deviceselect, 0, 3)

        self.setLayout(layout)

    @inlineCallbacks
    def voltchanged(self, chan, value):
        value = self.U(value, 'V')
        yield self.server.amplitude(chan, value)

    @inlineCallbacks
    def freqchanged(self, chan, value):
        value = self.U(value, 'Hz')
        yield self.server.frequency(chan, value)

    @inlineCallbacks
    def offsetchanged(self, chan, value):
        value = self.U(value, 'V')
        yield self.server.offset(chan, value)

    @inlineCallbacks
    def setoutput(self, chan, state):
        yield self.server.output(chan, state)

    @inlineCallbacks
    def waveselect(self, chan, wave):
        if wave == 'DC':
            if chan == 1:
                self.freq1widget.setEnabled(False)
            else:
                self.freq2widget.setEnabled(False)
        else:
            self.freq1widget.setEnabled(True)
            self.freq2widget.setEnabled(True)
        yield self.server.wave_function(chan, str(wave))

    @inlineCallbacks
    def changedevice(self, deviceid):
        if deviceid == 'Refresh List':
            yield self.server.refresh()
            self.updatedevices()
        else:
            self.server.release_device()
            self.server.select_device(int(deviceid[1]))

    @inlineCallbacks
    def updatedevices(self):
        self.deviceselect.clear()
        self.devicelist = yield self.server.list_devices()
        for device in self.devicelist:
            self.deviceselect.addItem(str(device))
        self.deviceselect.addItem('Refresh List')

    def closeEvent(self, x):
        self.reactor.stop()
Exemplo n.º 18
0
    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        self.setWindowTitle('Rigol DG1022 Control')

        qBox = QtGui.QGroupBox('Rigol DG1022')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.deviceselect = QtGui.QComboBox(self)
        self.updatedevices()

        self.offsetwidget1 = QCustomSpinBox('Offset', (-5, 5))
        self.offsetwidget2 = QCustomSpinBox('Offset', (-5, 5))
        self.volt1widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq1widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.volt2widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq2widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.waveselect1 = QtGui.QComboBox(self)
        self.waveselect2 = QtGui.QComboBox(self)
        self.output1 = TextChangingButton(('On', 'Off'))
        self.output2 = TextChangingButton(('On', 'Off'))

        self.waveselect1.addItem("sine")
        self.waveselect1.addItem("square")
        self.waveselect1.addItem("ramp")
        self.waveselect1.addItem("pulse")
        self.waveselect1.addItem("noise")
        self.waveselect1.addItem("DC")
        self.waveselect1.addItem("USER")

        self.waveselect2.addItem("sine")
        self.waveselect2.addItem("square")
        self.waveselect2.addItem("ramp")
        self.waveselect2.addItem("pulse")
        self.waveselect2.addItem("noise")
        self.waveselect2.addItem("DC")
        self.waveselect2.addItem("USER")

        self.output1.toggled.connect(lambda state=self.output1.isDown(), chan=
                                     1, : self.setoutput(chan, state))
        self.output2.toggled.connect(lambda state=self.output1.isDown(), chan=
                                     2, : self.setoutput(chan, state))
        self.volt1widget.spinLevel.valueChanged.connect(
            lambda value=self.volt1widget.spinLevel.value(
            ), chan=1: self.voltchanged(chan, value))
        self.volt2widget.spinLevel.valueChanged.connect(
            lambda value=self.volt2widget.spinLevel.value(
            ), chan=2: self.voltchanged(chan, value))
        self.freq1widget.spinLevel.valueChanged.connect(
            lambda value=self.freq1widget.spinLevel.value(
            ), chan=1: self.freqchanged(chan, value))
        self.freq2widget.spinLevel.valueChanged.connect(
            lambda value=self.freq2widget.spinLevel.value(
            ), chan=2: self.freqchanged(chan, value))
        self.offsetwidget1.spinLevel.valueChanged.connect(
            lambda value=self.offsetwidget1.spinLevel.value(
            ), chan=1: self.offsetchanged(chan, value))
        self.offsetwidget2.spinLevel.valueChanged.connect(
            lambda value=self.offsetwidget2.spinLevel.value(
            ), chan=2: self.offsetchanged(chan, value))
        self.waveselect1.activated[str].connect(
            lambda wave=self.waveselect1.currentText(
            ), chan=1: self.waveselect(chan, wave))
        self.waveselect2.activated[str].connect(
            lambda wave=self.waveselect2.currentText(
            ), chan=2: self.waveselect(chan, wave))
        self.deviceselect.activated[str].connect(self.changedevice)
        subLayout.addWidget(self.freq1widget, 1, 0)
        subLayout.addWidget(self.volt1widget, 1, 1)
        subLayout.addWidget(self.freq2widget, 1, 2)
        subLayout.addWidget(self.volt2widget, 1, 3)
        subLayout.addWidget(self.waveselect1, 2, 0, 1, 2)
        subLayout.addWidget(self.waveselect2, 2, 2, 1, 2)
        subLayout.addWidget(self.offsetwidget1, 3, 0)
        subLayout.addWidget(self.offsetwidget2, 3, 2)
        subLayout.addWidget(self.output1, 3, 1)
        subLayout.addWidget(self.output2, 3, 3)
        subLayout.addWidget(self.deviceselect, 0, 3)

        self.setLayout(layout)
Exemplo n.º 19
0
class LoadControl(QtGui.QWidget):

    def __init__(self, reactor, cxn=None):
        super(LoadControl, self).__init__()
        self.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        mixer.init()
        self.its_trap = mixer.Sound('/home/qsimexpcontrol/Music/trap.wav')
        self.vader = mixer.Sound('/home/qsimexpcontrol/Music/swvader01.wav')
        self.reactor = reactor
        self.kt = None
        self.bi_directional_state = False
        self.cxn = cxn
        self.connect()

    @inlineCallbacks
    def connect(self):
        """Creates an Asynchronous connection to arduinottl and
        connects incoming signals to relavent functions

        """
        from labrad.units import WithUnit as U
        self.U = U
        if self.cxn is None:
            self.cxn = yield connection(name="Load Control")
            yield self.cxn.connect()
        self.PMT = yield self.cxn.get_server('normalpmtflow')
        self.pv = yield self.cxn.get_server('parametervault')
        self.TTL = yield self.cxn.get_server('arduinottl')
        self.oven = yield self.cxn.get_server('ovenserver')
        self.reg = yield self.cxn.get_server('registry')
        try:
            yield self.reg.cd(['', 'settings'])
            self.settings = yield self.reg.dir()
            self.settings = self.settings[1]
        except:
            self.settings = []
        yield self.setup_listeners()
        yield self.initializeGUI()

    @inlineCallbacks
    def setup_listeners(self):
        yield self.PMT.signal__new_count(SIGNALID)
        yield self.PMT.addListener(listener=self.on_new_counts,
                                   source=None, ID=SIGNALID)

    @inlineCallbacks
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        self.shutter_widget = QCustomSwitchChannel('399/Oven/ProtectionBeam',
                                                   ('Open/Oven On', 'Closed/Oven Off'))
        self.shutter_widget.TTLswitch.toggled.connect(self.toggle)
        self.timer_widget = QCustomTimer('Loading Time', show_control=False)
        self.current_widget = QCustomSpinBox("Current ('A')", (0.0, 3.0))

        self.current_widget.setStepSize(0.01)
        self.current_widget.spinLevel.setDecimals(2)
        self.current_widget.spinLevel.valueChanged.connect(self.current_changed)

        if 'oven' in self.settings:
            value = yield self.reg.get('oven')
            self.current_widget.spinLevel.setValue(value)

        if '399 trapshutter' in self.settings:
            value = yield self.reg.get('399 trapshutter')
            value = bool(value)
            self.shutter_widget.TTLswitch.setChecked(value)
        else:
            self.shutter_widget.TTLswitch.setChecked(False)

        layout.addWidget(self.current_widget, 1, 1)
        layout.addWidget(self.shutter_widget, 0, 0)
        layout.addWidget(self.timer_widget, 0, 1)
        self.setLayout(layout)

    @inlineCallbacks
    def on_new_counts(self, signal, pmt_value):
        disc_value = yield self.pv.get_parameter('Loading', 'ion_threshold') #this throws error on closeout since listner is yielding to server
        switch_on = self.shutter_widget.TTLswitch.isChecked()
        if (pmt_value >= disc_value) and switch_on:
            self.shutter_widget.TTLswitch.setChecked(False)
            self.its_trap.play()
        elif (self.timer_widget.time >= 600.0) and switch_on:
            self.vader.play()
            self.shutter_widget.TTLswitch.setChecked(False)

    @inlineCallbacks
    def toggle(self, value):
        yield self.changeState(value)
        if value:
            self.timer_widget.reset()
            self.timer_widget.start()
            yield self.oven.oven_output(True)
        else:
            yield self.oven.oven_output(False)
            self.timer_widget.reset()

    @inlineCallbacks
    def current_changed(self, value):
        yield self.oven.oven_current(self.U(value, 'A'))
        if 'oven' in self.settings:
            yield self.reg.set('oven', value)

    @inlineCallbacks
    def changeState(self, state):
        if '399 trapshutter' in self.settings:
            yield self.reg.set('399 trapshutter', state)
        yield self.TTL.ttl_output(10, state)

    def closeEvent(self, x):
        self.reactor.stop()
Exemplo n.º 20
0
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        lockwidget = QCustomSwitchChannel('Lock Cal', ('Locked', 'Unlocked'))
        lockwidget.TTLswitch.toggled.connect(self.toggle)

        offsetwidget = QCustomSpinBox('DC offset', (-1.0, 1.0))
        setpointwidget = QCustomSpinBox('Set Point', (811.0, 812.0))
        gainwidget = QCustomSpinBox('Gain', (0.1, 10000.0))

        offsetwidget.setStepSize(0.001)
        setpointwidget.setStepSize(0.000001)
        gainwidget.setStepSize(0.1)

        offsetwidget.spinLevel.setDecimals(3)
        setpointwidget.spinLevel.setDecimals(6)
        gainwidget.spinLevel.setDecimals(1)

        setpointwidget.spinLevel.setValue(self.set)
        gainwidget.spinLevel.setValue(self.gain)

        offsetwidget.spinLevel.valueChanged.connect(self.offset)
        setpointwidget.spinLevel.valueChanged.connect(self.set_point)
        gainwidget.spinLevel.valueChanged.connect(self.set_gain)

        layout.addWidget(lockwidget, 0, 0)
        layout.addWidget(offsetwidget, 0, 1)
        layout.addWidget(setpointwidget, 0, 2)
        layout.addWidget(gainwidget, 0, 3)

        self.setLayout(layout)
Exemplo n.º 21
0
class LoadControl(QtGui.QWidget):

    def __init__(self, reactor, cxn=None):
        super(LoadControl, self).__init__()
        self.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        self.reactor = reactor
        self.cxn = cxn
        self.connect()

    @inlineCallbacks
    def connect(self):
        """Creates an Asynchronous connection to arduinottl and
        connects incoming signals to relavent functions

        """

        if self.cxn is None:
            self.cxn = connection(name="Load Control")
            yield self.cxn.connect()
        self.PMT = yield self.cxn.get_server('normalpmtflow')
        self.TTL = yield self.cxn.get_server('arduinottl')
        self.reg = yield self.cxn.get_server('registry')
        try:
            yield self.reg.cd(['', 'settings'])
            self.settings = yield self.reg.dir()
            self.settings = self.settings[1]
        except:
            self.settings = []
        yield self.setup_listeners()
        yield self.initializeGUI()

    @inlineCallbacks
    def setup_listeners(self):
        ctx = yield self.PMT.context()
        yield self.PMT.signal__new_count(SIGNALID, context=ctx)
        yield self.PMT.addListener(listener=self.on_new_counts,
                                   source=None, ID=SIGNALID, context=ctx)

    @inlineCallbacks
    def initializeGUI(self):
        layout = QtGui.QGridLayout()
        self.shutter_widget = QCustomSwitchChannel('399 Trap',
                                                   ('Open', 'Closed'))
        self.shutter_widget.TTLswitch.toggled.connect(self.toggle)
        self.timer_widget = QCustomTimer('Loading Time', show_control=False)
        self.disc_widget = QCustomSpinBox('kcts/s',
                                          (0.0, 999.0))

        qBox = QtGui.QGroupBox('Discriminator')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)

        subLayout.addWidget(self.disc_widget)

        self.disc_widget.setStepSize(0.1)
        self.disc_widget.spinLevel.setDecimals(1)
        self.disc_widget.spinLevel.valueChanged.connect(self.disc_changed)

        if 'discriminator' in self.settings:
            value = yield self.reg.get('discriminator')
            self.disc_widget.spinLevel.setValue(value)

        if '399 trapshutter' in self.settings:
            value = yield self.reg.get('399 trapshutter')
            value = bool(value)
            self.shutter_widget.TTLswitch.setChecked(value)
        else:
            self.shutter_widget.TTLswitch.setChecked(False)

        layout.addWidget(self.shutter_widget, 0, 0)
        layout.addWidget(qBox, 0, 1)
        layout.addWidget(self.timer_widget, 0, 2)
        self.setLayout(layout)

    def on_new_counts(self, signal, pmt_value):
        switch_on = self.shutter_widget.TTLswitch.isChecked()
        disc_value = self.disc_widget.spinLevel.value()
        if (pmt_value >= disc_value) and switch_on:
            self.shutter_widget.TTLswitch.setChecked(False)

    @inlineCallbacks
    def toggle(self, value):
        yield self.changeState(value)
        if value:
            self.timer_widget.reset()
            self.timer_widget.start()
        else:
            self.timer_widget.stop()

    @inlineCallbacks
    def disc_changed(self, value):
        if 'discriminator' in self.settings:
            yield self.reg.set('discriminator', value)

    @inlineCallbacks
    def changeState(self, state):
        if '399 trapshutter' in self.settings:
            yield self.reg.set('399 trapshutter', state)
        yield self.TTL.ttl_output(10, state)

    def closeEvent(self, x):
        self.reactor.stop()
Exemplo n.º 22
0
    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        self.setWindowTitle('Rigol DG1022 Control')

        qBox = QtGui.QGroupBox('Rigol DG1022')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.deviceselect = QtGui.QComboBox(self)
        self.updatedevices()


        self.offsetwidget1 = QCustomSpinBox('Offset', (-5, 5))
        self.offsetwidget2 = QCustomSpinBox('Offset', (-5, 5))
        self.volt1widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq1widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.volt2widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq2widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.waveselect1 = QtGui.QComboBox(self)
        self.waveselect2 = QtGui.QComboBox(self)
        self.output1 = TextChangingButton(('On','Off'))
        self.output2 = TextChangingButton(('On','Off'))

        self.waveselect1.addItem("sine")
        self.waveselect1.addItem("square")
        self.waveselect1.addItem("ramp")
        self.waveselect1.addItem("pulse")
        self.waveselect1.addItem("noise")
        self.waveselect1.addItem("DC")
        self.waveselect1.addItem("USER")

        self.waveselect2.addItem("sine")
        self.waveselect2.addItem("square")
        self.waveselect2.addItem("ramp")
        self.waveselect2.addItem("pulse")
        self.waveselect2.addItem("noise")
        self.waveselect2.addItem("DC")
        self.waveselect2.addItem("USER")

        self.output1.toggled.connect(lambda state = self.output1.isDown(), chan = 1, : self.setoutput(chan, state))
        self.output2.toggled.connect(lambda state = self.output1.isDown(), chan = 2, : self.setoutput(chan, state))
        self.volt1widget.spinLevel.valueChanged.connect(lambda value = self.volt1widget.spinLevel.value(), chan = 1 : self.voltchanged(chan, value))
        self.volt2widget.spinLevel.valueChanged.connect(lambda value = self.volt2widget.spinLevel.value(), chan = 2 : self.voltchanged(chan, value))
        self.freq1widget.spinLevel.valueChanged.connect(lambda value = self.freq1widget.spinLevel.value(), chan = 1 : self.freqchanged(chan, value))
        self.freq2widget.spinLevel.valueChanged.connect(lambda value = self.freq2widget.spinLevel.value(), chan = 2 : self.freqchanged(chan, value))
        self.offsetwidget1.spinLevel.valueChanged.connect(lambda value = self.offsetwidget1.spinLevel.value(), chan = 1 : self.offsetchanged(chan, value))
        self.offsetwidget2.spinLevel.valueChanged.connect(lambda value = self.offsetwidget2.spinLevel.value(), chan = 2 : self.offsetchanged(chan, value))
        self.waveselect1.activated[str].connect(lambda wave = self.waveselect1.currentText(), chan = 1 : self.waveselect(chan, wave))
        self.waveselect2.activated[str].connect(lambda wave = self.waveselect2.currentText(), chan = 2 : self.waveselect(chan, wave))
        self.deviceselect.activated[str].connect(self.changedevice)
        subLayout.addWidget(self.freq1widget, 1,0)
        subLayout.addWidget(self.volt1widget, 1,1)
        subLayout.addWidget(self.freq2widget, 1,2)
        subLayout.addWidget(self.volt2widget, 1,3)
        subLayout.addWidget(self.waveselect1, 2,0, 1,2)
        subLayout.addWidget(self.waveselect2, 2,2, 1,2)
        subLayout.addWidget(self.offsetwidget1, 3,0)
        subLayout.addWidget(self.offsetwidget2, 3,2)
        subLayout.addWidget(self.output1,      3,1)
        subLayout.addWidget(self.output2,      3,3)
        subLayout.addWidget(self.deviceselect, 0,3)

        self.setLayout(layout)
Exemplo n.º 23
0
class rigolclient(QtGui.QWidget):

    def __init__(self, reactor, parent = None):
        """initializels the GUI creates the reactor
        """
        super(rigolclient, self).__init__()
        self.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        self.reactor = reactor
        self.connect()

    @inlineCallbacks
    def connect(self):
        """Creates an Asynchronous connection
        """
        from labrad.wrappers import connectAsync
        from labrad.units import WithUnit as U
        self.U = U
        self.cxn = yield connectAsync(name = "rigol client")
        self.server = self.cxn.rigol_dg1022_server
        self.devicelist = yield self.server.list_devices()
        if self.devicelist:
            yield self.server.select_device(0)
        self.initializeGUI()

    def initializeGUI(self):

        layout = QtGui.QGridLayout()

        self.setWindowTitle('Rigol DG1022 Control')

        qBox = QtGui.QGroupBox('Rigol DG1022')
        subLayout = QtGui.QGridLayout()
        qBox.setLayout(subLayout)
        layout.addWidget(qBox, 0, 0)

        self.deviceselect = QtGui.QComboBox(self)
        self.updatedevices()


        self.offsetwidget1 = QCustomSpinBox('Offset', (-5, 5))
        self.offsetwidget2 = QCustomSpinBox('Offset', (-5, 5))
        self.volt1widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq1widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.volt2widget = QCustomSpinBox('Amplitude (Vpp)', (-10, 10))
        self.freq2widget = QCustomSpinBox('Frequency (Hz)', (0, 40e6))
        self.waveselect1 = QtGui.QComboBox(self)
        self.waveselect2 = QtGui.QComboBox(self)
        self.output1 = TextChangingButton(('On','Off'))
        self.output2 = TextChangingButton(('On','Off'))

        self.waveselect1.addItem("sine")
        self.waveselect1.addItem("square")
        self.waveselect1.addItem("ramp")
        self.waveselect1.addItem("pulse")
        self.waveselect1.addItem("noise")
        self.waveselect1.addItem("DC")
        self.waveselect1.addItem("USER")

        self.waveselect2.addItem("sine")
        self.waveselect2.addItem("square")
        self.waveselect2.addItem("ramp")
        self.waveselect2.addItem("pulse")
        self.waveselect2.addItem("noise")
        self.waveselect2.addItem("DC")
        self.waveselect2.addItem("USER")

        self.output1.toggled.connect(lambda state = self.output1.isDown(), chan = 1, : self.setoutput(chan, state))
        self.output2.toggled.connect(lambda state = self.output1.isDown(), chan = 2, : self.setoutput(chan, state))
        self.volt1widget.spinLevel.valueChanged.connect(lambda value = self.volt1widget.spinLevel.value(), chan = 1 : self.voltchanged(chan, value))
        self.volt2widget.spinLevel.valueChanged.connect(lambda value = self.volt2widget.spinLevel.value(), chan = 2 : self.voltchanged(chan, value))
        self.freq1widget.spinLevel.valueChanged.connect(lambda value = self.freq1widget.spinLevel.value(), chan = 1 : self.freqchanged(chan, value))
        self.freq2widget.spinLevel.valueChanged.connect(lambda value = self.freq2widget.spinLevel.value(), chan = 2 : self.freqchanged(chan, value))
        self.offsetwidget1.spinLevel.valueChanged.connect(lambda value = self.offsetwidget1.spinLevel.value(), chan = 1 : self.offsetchanged(chan, value))
        self.offsetwidget2.spinLevel.valueChanged.connect(lambda value = self.offsetwidget2.spinLevel.value(), chan = 2 : self.offsetchanged(chan, value))
        self.waveselect1.activated[str].connect(lambda wave = self.waveselect1.currentText(), chan = 1 : self.waveselect(chan, wave))
        self.waveselect2.activated[str].connect(lambda wave = self.waveselect2.currentText(), chan = 2 : self.waveselect(chan, wave))
        self.deviceselect.activated[str].connect(self.changedevice)
        subLayout.addWidget(self.freq1widget, 1,0)
        subLayout.addWidget(self.volt1widget, 1,1)
        subLayout.addWidget(self.freq2widget, 1,2)
        subLayout.addWidget(self.volt2widget, 1,3)
        subLayout.addWidget(self.waveselect1, 2,0, 1,2)
        subLayout.addWidget(self.waveselect2, 2,2, 1,2)
        subLayout.addWidget(self.offsetwidget1, 3,0)
        subLayout.addWidget(self.offsetwidget2, 3,2)
        subLayout.addWidget(self.output1,      3,1)
        subLayout.addWidget(self.output2,      3,3)
        subLayout.addWidget(self.deviceselect, 0,3)

        self.setLayout(layout)

    @inlineCallbacks
    def voltchanged(self, chan, value):
        value = self.U(value, 'V')
        yield self.server.amplitude(chan, value)

    @inlineCallbacks
    def freqchanged(self, chan, value):
        value = self.U(value, 'Hz')
        yield self.server.frequency(chan, value)

    @inlineCallbacks
    def offsetchanged(self, chan, value):
        value = self.U(value, 'V')
        yield self.server.offset(chan, value)

    @inlineCallbacks
    def setoutput(self, chan, state):
        yield self.server.output(chan, state)

    @inlineCallbacks
    def waveselect(self, chan, wave):
        if wave == 'DC':
            if chan == 1:
                self.freq1widget.setEnabled(False)
            else:
                self.freq2widget.setEnabled(False)
        else:
            self.freq1widget.setEnabled(True)
            self.freq2widget.setEnabled(True)
        yield self.server.wave_function(chan, str(wave))

    @inlineCallbacks
    def changedevice(self, deviceid):
        if deviceid == 'Refresh List':
            yield self.server.refresh()
            self.updatedevices()
        else:
            self.server.release_device()
            self.server.select_device(int(deviceid[1]))


    @inlineCallbacks
    def updatedevices(self):
        self.deviceselect.clear()
        self.devicelist = yield self.server.list_devices()
        for device in self.devicelist:
            self.deviceselect.addItem(str(device))
        self.deviceselect.addItem('Refresh List')


    def closeEvent(self, x):
        self.reactor.stop()