Ejemplo n.º 1
0
    def makeGUI(self):
        self.controls = {
            k: QCustomSpinBox(k, (-2., 2.))
            for k in hc.multipoles
        }
        self.controls['U1'] = QCustomSpinBox('U1', (-2., 2.))
        self.controls['U2'] = QCustomSpinBox('U2', (0., 20.))
        self.controls['U3'] = QCustomSpinBox('U3', (-2., 2.))
        self.multipoleValues = {k: 0.0 for k in hc.multipoles}
        self.ctrlLayout = QtGui.QVBoxLayout()
        for k in hc.multipoles:
            self.ctrlLayout.addWidget(self.controls[k])
        self.multipoleFileSelectButton = QtGui.QPushButton('Set C File')
        self.ctrlLayout.addWidget(self.multipoleFileSelectButton)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in hc.multipoles:
            self.controls[k].onNewValues.connect(self.inputHasUpdated)
        self.multipoleFileSelectButton.released.connect(self.selectCFile)
        self.setLayout(self.ctrlLayout)
        yield self.followSignal(0, 0)
    def makeGUI(self):
        layout = QtGui.QGridLayout()
        self.controlLabels = []
        for i in range(1, Nelectrodes):
            self.controlLabels.append(str(i))

        self.controls = {}
        for label in self.controlLabels:
            if int(label) < 6:
                self.controls[label] = QCustomSpinBox(label, (-30, 30))
            elif int(label) < 15:
                self.controls[label] = QCustomSpinBox(
                    str(int(label) - 5) + '   ', (-30, 30))
            else:
                self.controls[label] = QCustomSpinBox(str(int(label) - 5),
                                                      (-30, 30))
        self.controlLabels.append('CNT')
        self.controls['CNT'] = QCustomSpinBox('CNT', (-30, 30))

        self.labelToNumber = {}
        for l in self.controlLabels:
            if l == 'CNT':
                self.labelToNumber[l] = Nelectrodes
            else:
                self.labelToNumber[l] = int(l)

        self.channelValues = {}
        for k in self.controlLabels:
            self.channelValues[k] = 0.0

        smaBox = QtGui.QGroupBox('SMA Out')
        smaLayout = QtGui.QGridLayout()
        smaBox.setLayout(smaLayout)

        elecBox = QtGui.QGroupBox('Electrodes')
        elecLayout = QtGui.QGridLayout()
        elecBox.setLayout(elecLayout)
        layout.addWidget(smaBox, 0, 0)
        layout.addWidget(elecBox, 0, 1)

        for j in range(5):
            smaLayout.addWidget(self.controls[str(j + 1)], j, 1)
        for j in range(5, 16):
            elecLayout.addWidget(self.controls[str(j + 1)], 16 - j, 1)
        for j in range(16, 27):
            elecLayout.addWidget(self.controls[str(j + 1)], 27 - j, 5)
        elecLayout.addWidget(self.controls['CNT'], 12, 3)

        layout.setColumnStretch(1, 1)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.controlLabels:
            self.controls[k].onNewValues.connect(self.inputHasUpdated(k))

        self.setLayout(layout)
Ejemplo n.º 3
0
    def makeGUI(self):
        self.dacDict = dict(hc.elec_dict.items() + hc.sma_dict.items())
        self.controls = {
            k: QCustomSpinBox(k, self.dacDict[k].allowedVoltageRange)
            for k in self.dacDict.keys()
        }
        layout = QtGui.QGridLayout()
        elecBox = QtGui.QGroupBox('Channels')
        elecLayout = QtGui.QVBoxLayout()
        elecBox.setLayout(elecLayout)
        layout.addWidget(elecBox, 0, 1)

        elecList = hc.elec_dict.keys()
        elecList.sort()
        for i, e in enumerate(elecList):
            elecLayout.addWidget(self.controls[e])

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.dacDict.keys():
            self.controls[k].onNewValues.connect(self.inputHasUpdated(k))

        layout.setColumnStretch(1, 1)
        self.setLayout(layout)
Ejemplo n.º 4
0
    def makeGUI(self):
        self.multipoles = yield self.dacserver.get_multipole_names()
        self.controls = {
            k: QCustomSpinBox(k, (-20., 20.))
            for k in self.multipoles
        }
        #        for i,el in self.controls:
        #            el.spinLevel.setDecimals(4)
        self.multipoleValues = {k: 0.0 for k in self.multipoles}

        for k in self.multipoles:
            self.ctrlLayout.addWidget(self.controls[k])
        self.multipoleFileSelectButton = QtGui.QPushButton('Set C File')
        self.ctrlLayout.addWidget(self.multipoleFileSelectButton)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.multipoles:
            self.controls[k].onNewValues.connect(self.inputHasUpdated)
        self.multipoleFileSelectButton.released.connect(self.selectCFile)
        self.setLayout(self.ctrlLayout)
        yield self.followSignal(0, 0)
Ejemplo n.º 5
0
    def makeGUI(self):

        self.scan = False
        self.counter = 0

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.scanner)
        self.timer.start(ScanWait)

        self.multipolelist = hc.default_multipoles
        self.displays = {k: QtGui.QLCDNumber() for k in self.multipolelist}
        layout = QtGui.QGridLayout()
        Multipolebox = QtGui.QGroupBox('Multipoles')
        multilayout = QtGui.QGridLayout()
        self.startscanbutton = QtGui.QPushButton('Start Scan')
        self.stopscanbutton = QtGui.QPushButton('Stop Scan')
        self.counterdisplay = QCustomSpinBox('counter', [0, n**3])

        Multipolebox.setLayout(multilayout)
        layout.addWidget(Multipolebox, 0, 0)

        i = 0
        for e in self.multipolelist:
            multilayout.addWidget(QtGui.QLabel(e), i, 0)
            multilayout.addWidget(self.displays[e], i, 1)
            i = i + 1
        multilayout.addWidget(self.startscanbutton, i, 1)
        multilayout.addWidget(self.stopscanbutton, i + 1, 1)
        multilayout.addWidget(self.counterdisplay, i + 2, 1)
        self.startscanbutton.pressed.connect(self.startscan)
        self.stopscanbutton.pressed.connect(self.stopscan)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.updateCounter)
        self.timer.start(ScanWait - 1)
        self.counterdisplay.onNewValues.connect(self.inputHasUpdated())

        self.setLayout(layout)
        self.fields = scan_field(min, max, n)
Ejemplo n.º 6
0
    def makeGUI(self):
        self.dacDict = dict(hc.elecDict.items() + hc.smaDict.items())
        self.controls = {
            k: QCustomSpinBox(k, self.dacDict[k].allowedVoltageRange)
            for k in self.dacDict.keys()
        }
        layout = QtGui.QGridLayout()
        smaBox = QtGui.QGroupBox('SMA Out')
        smaLayout = QtGui.QVBoxLayout()
        smaBox.setLayout(smaLayout)
        elecBox = QtGui.QGroupBox('Electrodes')
        elecLayout = QtGui.QGridLayout()
        elecBox.setLayout(elecLayout)
        layout.addWidget(smaBox, 0, 0)
        layout.addWidget(elecBox, 0, 1)

        for k in hc.smaDict:
            smaLayout.addWidget(self.controls[k],
                                alignment=QtCore.Qt.AlignRight)
        for k in hc.elecDict:
            if (int(k) == hc.centerElectrode):
                labl = str(k) + '(CNT)'
                self.controls[k].title.setText(labl)
                elecLayout.addWidget(self.controls[k], hc.numElectrodes / 2, 1)
            elif int(k) <= hc.numElectrodes / 2:
                elecLayout.addWidget(self.controls[k],
                                     hc.numElectrodes / 2 - int(k), 0)
            elif int(k) > hc.numElectrodes / 2:
                elecLayout.addWidget(self.controls[k],
                                     hc.numElectrodes - 0 - int(k), 2)
            elif (int(k) == hc.numElectrodes):
                elecLayout.addWidget(self.controls[k],
                                     hc.numElectrodes + 1 - int(k), 2)
        spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                   QtGui.QSizePolicy.MinimumExpanding)
        smaLayout.addItem(spacer)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.dacDict.keys():
            self.controls[k].onNewValues.connect(self.inputHasUpdated(k))

        layout.setColumnStretch(1, 1)
        self.setLayout(layout)
Ejemplo n.º 7
0
 def makeGUI(self):
     
     self.scan = False
     self.counter = 0
     
     self.timer = QtCore.QTimer(self)
     self.timer.timeout.connect(self.scanner)
     self.timer.start(ScanWait)   
     
     self.multipolelist = hc.default_multipoles
     self.displays = {k: QtGui.QLCDNumber() for k in self.multipolelist}  
     layout = QtGui.QGridLayout()
     Multipolebox = QtGui.QGroupBox('Multipoles')
     multilayout = QtGui.QGridLayout()
     self.startscanbutton = QtGui.QPushButton('Start Scan')
     self.stopscanbutton = QtGui.QPushButton('Stop Scan')
     self.counterdisplay = QCustomSpinBox('counter',[0, n**3])
     
     
     Multipolebox.setLayout(multilayout)
     layout.addWidget(Multipolebox,0,0)
     
     i = 0 
     for e in self.multipolelist:
         multilayout.addWidget(QtGui.QLabel(e),i,0)
         multilayout.addWidget(self.displays[e],i,1)
         i = i+1
     multilayout.addWidget(self.startscanbutton,i,1)  
     multilayout.addWidget(self.stopscanbutton,i+1,1)  
     multilayout.addWidget(self.counterdisplay,i+2,1)
     self.startscanbutton.pressed.connect(self.startscan)
     self.stopscanbutton.pressed.connect(self.stopscan)
     
     self.inputUpdated = False                
     self.timer = QtCore.QTimer(self)        
     self.timer.timeout.connect(self.updateCounter)
     self.timer.start(ScanWait - 1)
     self.counterdisplay.onNewValues.connect(self.inputHasUpdated())
     
     self.setLayout(layout)      
     self.fields = scan_field(min,max,n)
Ejemplo n.º 8
0
    def makeGUI(self):
        self.dacDict = dict(hc.elec_dict.items() + hc.sma_dict.items())

        self.controls = {
            k: QCustomSpinBox(hc.channel_name_dict[k],
                              self.dacDict[k].allowedVoltageRange)
            for k in self.dacDict.keys()
        }

        layout = QtGui.QGridLayout()
        elecBox = QtGui.QGroupBox('Laser Control')
        elecLayout = QtGui.QVBoxLayout()
        elecBox.setLayout(elecLayout)
        layout.addWidget(elecBox, 0, 1)

        elecList = hc.elec_dict.keys()
        elecList.sort()
        if bool(hc.centerElectrode):
            elecList.pop(hc.centerElectrode - 1)
        for i, e in enumerate(elecList):
            if int(e) <= len(elecList) / 2:
                elecLayout.addWidget(self.controls[e])
            elif int(e) > len(elecList) / 2:
                elecLayout.addWidget(self.controls[e])

        spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                   QtGui.QSizePolicy.MinimumExpanding)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.dacDict.keys():
            self.controls[k].onNewValues.connect(self.inputHasUpdated(k))

        layout.setColumnStretch(1, 1)
        self.setLayout(layout)
Ejemplo n.º 9
0
class MULTIPOLE_MONITOR(QtGui.QWidget):  #######################################################
    def __init__(self, reactor, parent=None):
        super(MULTIPOLE_MONITOR, self).__init__(parent)
        self.reactor = reactor        
        self.makeGUI()
        self.connect()


    def makeGUI(self):
        
        self.scan = False
        self.counter = 0
        
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.scanner)
        self.timer.start(ScanWait)   
        
        self.multipolelist = hc.default_multipoles
        self.displays = {k: QtGui.QLCDNumber() for k in self.multipolelist}  
        layout = QtGui.QGridLayout()
        Multipolebox = QtGui.QGroupBox('Multipoles')
        multilayout = QtGui.QGridLayout()
        self.startscanbutton = QtGui.QPushButton('Start Scan')
        self.stopscanbutton = QtGui.QPushButton('Stop Scan')
        self.counterdisplay = QCustomSpinBox('counter',[0, n**3])
        
        
        Multipolebox.setLayout(multilayout)
        layout.addWidget(Multipolebox,0,0)
        
        i = 0 
        for e in self.multipolelist:
            multilayout.addWidget(QtGui.QLabel(e),i,0)
            multilayout.addWidget(self.displays[e],i,1)
            i = i+1
        multilayout.addWidget(self.startscanbutton,i,1)  
        multilayout.addWidget(self.stopscanbutton,i+1,1)  
        multilayout.addWidget(self.counterdisplay,i+2,1)
        self.startscanbutton.pressed.connect(self.startscan)
        self.stopscanbutton.pressed.connect(self.stopscan)
        
        self.inputUpdated = False                
        self.timer = QtCore.QTimer(self)        
        self.timer.timeout.connect(self.updateCounter)
        self.timer.start(ScanWait - 1)
        self.counterdisplay.onNewValues.connect(self.inputHasUpdated())
        
        self.setLayout(layout)      
        self.fields = scan_field(min,max,n)

    def inputHasUpdated(self):
        def iu():
            self.inputUpdated = True
            self.counter = int(round(self.counterdisplay.spinLevel.value()))
        return iu

    def updateCounter(self):
        if self.inputUpdated:            
            self.inputUpdated = False
        else:
            self.counterdisplay.setValues(self.counter)
    
    def startscan(self):
        self.scan = True
        

    def stopscan(self):
        self.scan = False
#######################################################
    
    @inlineCallbacks
    def scanner(self):
        if self.scan == True:
            el = self.fields[self.counter]
            yield self.setmultipole(el)
            self.counter = self.counter + 1
            print(str((n**3- self.counter)*ScanWait/1000/60) + ' minutes left')
            if self.counter == len(self.fields):
                self.counter = 0
                self.scan = False
                print('scan done!')


    @inlineCallbacks    
    def setmultipole(self, multipoles):    
        list1 = [('Ex',multipoles[0]),('Ey',multipoles[1]),('Ez',multipoles[2]),('U3',10)]
        yield self.dacserver.set_multipole_values(list1)
        yield self.connect()
                     
            
    @inlineCallbacks
    def connect(self):
        from labrad.wrappers import connectAsync
        from labrad.types import Error
        self.cxn = yield connectAsync()
        self.dacserver = yield self.cxn.dac_server
        self.ionInfo = {}
        yield self.setupListeners()
        yield self.followSignal(0, 0)    
        for i in hc.notused_dict:        #Sets unused channels to about 0V
            yield self.dacserver.set_individual_digital_voltages_u([(i, 32768)])     

   
    @inlineCallbacks    
    def setupListeners(self):
        yield self.dacserver.signal__ports_updated(SIGNALID2)
        yield self.dacserver.addListener(listener = self.followSignal, source = None, ID = SIGNALID2)

    @inlineCallbacks
    def followSignal(self, x, s):        
        av = yield self.dacserver.get_multipole_values()
        brightness = 210
        darkness = 255 - brightness           
        for (k, v) in av:
     #       print k
            print v
            self.displays[k].display(float(v)) 

    def closeEvent(self, x):
        self.reactor.stop()
Ejemplo n.º 10
0
class MULTIPOLE_MONITOR(
        QtGui.QWidget
):  #######################################################
    def __init__(self, reactor, parent=None):
        super(MULTIPOLE_MONITOR, self).__init__(parent)
        self.reactor = reactor
        self.makeGUI()
        self.connect()

    def makeGUI(self):

        self.scan = False
        self.counter = 0

        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.scanner)
        self.timer.start(ScanWait)

        self.multipolelist = hc.default_multipoles
        self.displays = {k: QtGui.QLCDNumber() for k in self.multipolelist}
        layout = QtGui.QGridLayout()
        Multipolebox = QtGui.QGroupBox('Multipoles')
        multilayout = QtGui.QGridLayout()
        self.startscanbutton = QtGui.QPushButton('Start Scan')
        self.stopscanbutton = QtGui.QPushButton('Stop Scan')
        self.counterdisplay = QCustomSpinBox('counter', [0, n**3])

        Multipolebox.setLayout(multilayout)
        layout.addWidget(Multipolebox, 0, 0)

        i = 0
        for e in self.multipolelist:
            multilayout.addWidget(QtGui.QLabel(e), i, 0)
            multilayout.addWidget(self.displays[e], i, 1)
            i = i + 1
        multilayout.addWidget(self.startscanbutton, i, 1)
        multilayout.addWidget(self.stopscanbutton, i + 1, 1)
        multilayout.addWidget(self.counterdisplay, i + 2, 1)
        self.startscanbutton.pressed.connect(self.startscan)
        self.stopscanbutton.pressed.connect(self.stopscan)

        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.updateCounter)
        self.timer.start(ScanWait - 1)
        self.counterdisplay.onNewValues.connect(self.inputHasUpdated())

        self.setLayout(layout)
        self.fields = scan_field(min, max, n)

    def inputHasUpdated(self):
        def iu():
            self.inputUpdated = True
            self.counter = int(round(self.counterdisplay.spinLevel.value()))

        return iu

    def updateCounter(self):
        if self.inputUpdated:
            self.inputUpdated = False
        else:
            self.counterdisplay.setValues(self.counter)

    def startscan(self):
        self.scan = True

    def stopscan(self):
        self.scan = False


#######################################################

    @inlineCallbacks
    def scanner(self):
        if self.scan == True:
            el = self.fields[self.counter]
            yield self.setmultipole(el)
            self.counter = self.counter + 1
            print(
                str((n**3 - self.counter) * ScanWait / 1000 / 60) +
                ' minutes left')
            if self.counter == len(self.fields):
                self.counter = 0
                self.scan = False
                print('scan done!')

    @inlineCallbacks
    def setmultipole(self, multipoles):
        list1 = [('Ex', multipoles[0]), ('Ey', multipoles[1]),
                 ('Ez', multipoles[2]), ('U3', 10)]
        yield self.dacserver.set_multipole_values(list1)
        yield self.connect()

    @inlineCallbacks
    def connect(self):
        from labrad.wrappers import connectAsync
        from labrad.types import Error
        self.cxn = yield connectAsync()
        self.dacserver = yield self.cxn.dac_server
        self.ionInfo = {}
        yield self.setupListeners()
        yield self.followSignal(0, 0)
        for i in hc.notused_dict:  #Sets unused channels to about 0V
            yield self.dacserver.set_individual_digital_voltages_u([(i, 32768)
                                                                    ])

    @inlineCallbacks
    def setupListeners(self):
        yield self.dacserver.signal__ports_updated(SIGNALID2)
        yield self.dacserver.addListener(listener=self.followSignal,
                                         source=None,
                                         ID=SIGNALID2)

    @inlineCallbacks
    def followSignal(self, x, s):
        av = yield self.dacserver.get_multipole_values()
        brightness = 210
        darkness = 255 - brightness
        for (k, v) in av:
            #       print k
            print v
            self.displays[k].display(float(v))

    def closeEvent(self, x):
        self.reactor.stop()
Ejemplo n.º 11
0
    def makeGUI(self):
        self.dacDict = dict(hc.elec_dict.items() + hc.sma_dict.items())
        self.controls = {
            k: QCustomSpinBox(k, self.dacDict[k].allowedVoltageRange)
            for k in self.dacDict.keys()
        }
        layout = QtGui.QGridLayout()
        if bool(hc.sma_dict):
            smaBox = QtGui.QGroupBox('SMA Out')
            smaLayout = QtGui.QVBoxLayout()
            smaBox.setLayout(smaLayout)
        elecBox = QtGui.QGroupBox('Electrodes')
        elecLayout = QtGui.QGridLayout()
        elecBox.setLayout(elecLayout)
        if bool(hc.sma_dict):
            layout.addWidget(smaBox, 0, 0)
        layout.addWidget(elecBox, 0, 1)

        for s in hc.sma_dict:
            smaLayout.addWidget(self.controls[s],
                                alignment=QtCore.Qt.AlignRight)
        elecList = hc.elec_dict.keys()
        elecList.sort()

        for i, e in enumerate(
                elecList):  #i is the number value of the elec, e is the name
            if bool(hc.sma_dict):
                self.controls[s].setAutoFillBackground(True)
            if int(i) == 0:
                elecLayout.addWidget(self.controls[e], 1, 4)
            if int(i) == 1:
                #                elecLayout.addWidget(QtGui.QLabel(e),0,6)
                elecLayout.addWidget(self.controls[e], 0, 3)
            if int(i) == 2:
                #                elecLayout.addWidget(QtGui.QLabel(e),0,2)
                elecLayout.addWidget(self.controls[e], 0, 1)
            if int(i) == 3:
                #                elecLayout.addWidget(QtGui.QLabel(e),2,0)
                elecLayout.addWidget(self.controls[e], 1, 0)
            if int(i) == 4:
                #                elecLayout.addWidget(QtGui.QLabel(e),5,0)
                elecLayout.addWidget(self.controls[e], 3, 0)
            if int(i) == 5:
                #                elecLayout.addWidget(QtGui.QLabel(e),7,2)
                elecLayout.addWidget(self.controls[e], 4, 1)
            if int(i) == 6:
                #                elecLayout.addWidget(QtGui.QLabel(e),7,6)
                elecLayout.addWidget(self.controls[e], 4, 3)
            if int(i) == 7:
                #                elecLayout.addWidget(QtGui.QLabel(e),5,8)
                elecLayout.addWidget(self.controls[e], 3, 4)
            if int(i) == 8:
                #                elecLayout.addWidget(QtGui.QLabel(e),5,8)
                elecLayout.addWidget(self.controls[e], 2, 1)

        #elecLayout.addItem(QtGui.QLayoutItem.spacerItem(),1,0,1,8)
        elecLayout.setRowMinimumHeight(0, 20)
        elecLayout.setRowMinimumHeight(1, 20)
        elecLayout.setRowMinimumHeight(2, 10)
        elecLayout.setRowMinimumHeight(3, 20)
        elecLayout.setRowMinimumHeight(4, 20)
        elecLayout.setColumnMinimumWidth(0, 20)
        elecLayout.setColumnMinimumWidth(1, 20)
        elecLayout.setColumnMinimumWidth(2, 20)
        elecLayout.setColumnMinimumWidth(3, 20)
        elecLayout.setColumnMinimumWidth(4, 20)

        spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                   QtGui.QSizePolicy.MinimumExpanding)
        if bool(hc.sma_dict):
            smaLayout.addItem(spacer)
        self.inputUpdated = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.sendToServer)
        self.timer.start(UpdateTime)

        for k in self.dacDict.keys():
            self.controls[k].onNewValues.connect(self.inputHasUpdated(k))

        layout.setColumnStretch(1, 1)
        self.setLayout(layout)