Exemplo n.º 1
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        self.stateButton = QtGui.QPushButton()
        self.stateButton.setCheckable(1)

        self.piezoVoltageLabel = ClickableLabel('Piezo Voltage: ')
        self.piezoVoltageBox = SuperSpinBox(self.device._piezo_voltage_range,
                                            self.piezoVoltageDisplayUnits,
                                            self.piezoVoltageDigits)
        self.piezoVoltageBox.setFixedWidth(self.spinboxWidth)
        self.piezoVoltageBox.display(0)

        self.diodeCurrentLabel = ClickableLabel('Diode Current: ')
        self.diodeCurrentBox = SuperSpinBox(self.device._diode_current_range,
                                            self.diodeCurrentDisplayUnits,
                                            self.diodeCurrentDigits)
        self.diodeCurrentBox.setFixedWidth(self.spinboxWidth)
        self.diodeCurrentBox.display(0)

        self.layout = QtGui.QGridLayout()
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 1,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.stateButton, 0, 1)
        self.layout.addWidget(self.piezoVoltageLabel, 1, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.piezoVoltageBox, 1, 1)
        self.layout.addWidget(self.diodeCurrentLabel, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.diodeCurrentBox, 2, 1)
        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(120 + self.spinboxWidth, 100)

        self.reactor.callInThread(self.getAll)
Exemplo n.º 2
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        self.stateButton = QtGui.QPushButton()
        self.stateButton.setCheckable(True)
        
        self.frequencyLabel = ClickableLabel('Frequency: ')
        self.frequencyBox = SuperSpinBox(self.device._frequency_range, 
                                          self.frequencyDisplayUnits, 
                                          self.frequencyDigits)
        self.frequencyBox.setFixedWidth(self.spinboxWidth)
        
        self.amplitudeLabel = ClickableLabel('Amplitude: ')
        self.amplitudeBox = SuperSpinBox(self.device._amplitude_range, 
                                          self.amplitudeDisplayUnits, 
                                          self.amplitudeDigits)
        self.amplitudeBox.setFixedWidth(self.spinboxWidth)
        
        self.layout = QtGui.QGridLayout() 
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 1, 
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.stateButton, 0, 1)
        self.layout.addWidget(self.frequencyLabel, 1, 0, 1, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.frequencyBox, 1, 1)
        self.layout.addWidget(self.amplitudeLabel, 2, 0, 1, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.amplitudeBox, 2, 1)
        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(110 + self.spinboxWidth, 100)
        
        self.connectSignals()
        self.reactor.callInThread(self.getAll)
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        self.stateButton = QtWidgets.QPushButton()
        self.stateButton.setCheckable(True)

        self.frequencyLabel = ClickableLabel('Frequency: ')
        self.frequencyBox = SuperSpinBox(self.device._frequency_range,
                                         self.frequencyDisplayUnits,
                                         self.frequencyDigits)
        self.frequencyBox.setFixedWidth(self.spinboxWidth)

        self.amplitudeLabel = ClickableLabel('Amplitude: ')
        self.amplitudeBox = SuperSpinBox(self.device._amplitude_range,
                                         self.amplitudeDisplayUnits,
                                         self.amplitudeDigits)
        self.amplitudeBox.setFixedWidth(self.spinboxWidth)

        self.fmstateButton = QtWidgets.QPushButton()
        self.fmfreqBox = SuperSpinBox(self.device._fmfreq_range,
                                      self.fmfreqDisplayUnits,
                                      self.fmfreqDigits)
        self.fmfreqBox.setFixedWidth(self.spinboxWidth)
        self.fmfreqBox.setReadOnly(True)

        self.fmstateButton.setCheckable(True)
        self.fmdevLabel = ClickableLabel('FM Dev: ')
        self.fmdevBox = QtWidgets.QDoubleSpinBox()
        self.fmdevBox.setKeyboardTracking(False)
        self.fmdevBox.setRange(*self.device._fmdev_range)
        #        self.fmdevBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.fmdevBox.setDecimals(0)

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.stateButton, 0, 1)
        self.layout.addWidget(self.frequencyLabel, 1, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.frequencyBox, 1, 1)
        self.layout.addWidget(self.amplitudeLabel, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.amplitudeBox, 2, 1)

        self.layout.addWidget(self.fmstateButton, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.fmfreqBox, 3, 1)
        self.layout.addWidget(self.fmdevLabel, 4, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.fmdevBox, 4, 1)

        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(120 + self.spinboxWidth, 180)

        self.connectSignals()
        self.reactor.callInThread(self.getAll)
Exemplo n.º 4
0
    def populate(self):
        self.setWindowTitle(self.pd_name)
        self.canvas = MplCanvas()
        self.nav = NavigationToolbar(self.canvas, self)

        self.nameLabel1 = ClickableLabel('Parameter 1: ')
        self.nameLabel1.setFont(QtGui.QFont("Times", 18))
        self.nameBox1 = QtWidgets.QLineEdit()
        self.nameBox1.setFixedSize(self.boxWidth, self.boxHeight)

        self.valueLabel1 = ClickableLabel('Value 1: ')
        self.valueLabel1.setFont(QtGui.QFont("Times", 18))
        self.valueBox1 = NeatSpinBox()
        self.valueBox1.setFixedSize(self.boxWidth, self.boxHeight)

        self.nameLabel2 = ClickableLabel('Parameter 2: ')
        self.nameLabel2.setFont(QtGui.QFont("Times", 18))
        self.nameBox2 = QtWidgets.QLineEdit()
        self.nameBox2.setFixedSize(self.boxWidth, self.boxHeight)

        self.valueLabel2 = ClickableLabel('Value 2: ')
        self.valueLabel2.setFont(QtGui.QFont("Times", 18))
        self.valueBox2 = NeatSpinBox()
        self.valueBox2.setFixedSize(self.boxWidth, self.boxHeight)

        self.layout = QtWidgets.QGridLayout()
        self.layout.setSpacing(1)
        self.layout.setContentsMargins(2, 2, 2, 2)

        self.layout.addWidget(self.nav, 1, 0, 1, 5)
        self.layout.addWidget(self.canvas, 2, 0, 4, 4)

        self.layout.addWidget(self.nameLabel1, 7, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.nameBox1, 7, 1)
        self.layout.addWidget(self.valueLabel1, 7, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.valueBox1, 7, 3)

        # self.layout.addWidget(self.nameLabel2, 8, 0, 1, 1,
        #                       QtCore.Qt.AlignRight)
        # self.layout.addWidget(self.nameBox2, 8, 1)
        # self.layout.addWidget(self.valueLabel2, 8, 2, 1, 1,
        #                       QtCore.Qt.AlignRight)
        # self.layout.addWidget(self.valueBox2, 8, 3)

        self.setLayout(self.layout)

        width = self.canvas.width() + 20
        height = self.nav.height() + self.canvas.height(
        ) + self.nameBox1.height() * 2 + 60
        self.setFixedSize(width, height)
        self.setWindowTitle('pd_viewer')
Exemplo n.º 5
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        self.stateButton = QtGui.QPushButton()
        self.stateButton.setCheckable(1)

        self.currentLabel = ClickableLabel('Current [A]: ')
        self.currentBox = QtGui.QDoubleSpinBox()
        self.currentBox.setKeyboardTracking(False)
        self.currentBox.setRange(*self.device._current_range)
        self.currentBox.setSingleStep(self.currentStepsize)
        self.currentBox.setDecimals(
            abs(int(np.floor(np.log10(self.currentStepsize)))))
        self.currentBox.setAccelerated(True)

        self.powerLabel = ClickableLabel('Power [mW]: ')
        self.powerBox = QtGui.QDoubleSpinBox()
        self.powerBox.setRange(0, 1e3)
        self.powerBox.setReadOnly(True)
        self.powerBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)
        self.powerBox.setDecimals(4)

        self.layout = QtGui.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 1, 1,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.stateButton, 1, 1)
        self.layout.addWidget(self.currentLabel, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.currentBox, 2, 1)
        self.layout.addWidget(self.powerLabel, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.powerBox, 3, 1)

        self.setWindowTitle(self.name)
        self.setLayout(self.layout)
        self.setFixedSize(200, 120)

        self.reactor.callInThread(self.getAll)
    def populate(self):
        self.nameLabel = ClickableLabel(
            '<b> MSquared Laser Wavemeter Lock </b>')

        self.serverButton = QtWidgets.QPushButton()
        self.serverButton.setCheckable(True)
        self.serverButton.setFixedHeight(40)
        self.serverButton.setFixedWidth(120)

        self.lockButton = QtWidgets.QPushButton()
        self.lockButton.setCheckable(True)
        self.lockButton.setFixedHeight(40)
        self.lockButton.setFixedWidth(120)

        self.statusLabel = ClickableLabel('<b> Lock status: </b>')
        self.statusText = QtWidgets.QLineEdit()
        self.statusText.setReadOnly(True)
        self.statusText.setAlignment(QtCore.Qt.AlignCenter)
        self.statusText.setFixedHeight(40)
        self.statusText.setFixedWidth(300)
        self.statusText.setFont(QtGui.QFont('Arial', 12))

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 1, 6,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.serverButton, 2, 0, 2, 3,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.lockButton, 2, 3, 2, 3,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.statusLabel, 4, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.statusText, 4, 1, 2, 4, QtCore.Qt.AlignLeft)
        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setSpacing(5)
        self.setLayout(self.layout)
        self.setFixedSize(400, 150)
Exemplo n.º 7
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>      ')
        #        self.nameLabel.setFixedWidth(50)
        self.positionBox = IntSpinBox(self.positionRange)
        self.positionBox.setFixedWidth(self.spinboxWidth)

        self.layout = QtGui.QGridLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.positionBox, 0, 1)

        self.setWindowTitle('{}'.format(self.name))
        self.setLayout(self.layout)
        self.setFixedSize(60 + self.spinboxWidth, 40)
        self.setFixedSize(self.minimumSize())

        self.connectSignals()
Exemplo n.º 8
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        self.stateText = QtWidgets.QLineEdit()
        self.stateText.setReadOnly(True)
        self.stateText.setAlignment(QtCore.Qt.AlignCenter)

        self.warmupLabel = ClickableLabel('Warm up: ')
        self.warmupButton = QtWidgets.QPushButton()
        self.shutoffLabel = ClickableLabel('Shut off: ')
        self.shutoffButton = QtWidgets.QPushButton()

        self.scanLabel = ClickableLabel('Scan: ')
        self.scanButton = QtWidgets.QPushButton()

        self.lockLabel = ClickableLabel('Lock: ')
        self.lockButton = QtWidgets.QPushButton()

        self.relockLabel = ClickableLabel('Enable ReLock: ')
        self.relockButton = QtWidgets.QCheckBox()

        self.currentLabel = ClickableLabel('Current: ')
        self.currentBox = QtWidgets.QDoubleSpinBox()
        self.currentBox.setKeyboardTracking(False)
        self.currentBox.setRange(*self.device._current_range)
        self.currentBox.setSingleStep(self.currentStepsize)
        self.currentBox.setDecimals(
            abs(int(np.floor(np.log10(self.currentStepsize)))))
        #        self.currentBox.setAccelerated(True)
        self.currentBox.setSuffix(' mA')

        self.powerLabel = ClickableLabel('MonCurrent: ')
        self.powerBox = QtWidgets.QDoubleSpinBox()
        self.powerBox.setRange(0, 3e3)
        self.powerBox.setReadOnly(True)
        self.powerBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.powerBox.setDecimals(1)
        self.powerBox.setSuffix(' uA')

        self.scaniLabel = ClickableLabel('Scan i: ')
        self.scaniBox = QtWidgets.QDoubleSpinBox()
        self.scaniBox.setKeyboardTracking(False)
        self.scaniBox.setRange(*self.device._current_range)
        self.scaniBox.setSingleStep(self.currentStepsize)
        self.scaniBox.setDecimals(
            abs(int(np.floor(np.log10(self.currentStepsize)))))
        self.scaniBox.setSuffix(' mA')

        self.scanfLabel = ClickableLabel('Scan f: ')
        self.scanfBox = QtWidgets.QDoubleSpinBox()
        self.scanfBox.setKeyboardTracking(False)
        self.scanfBox.setRange(*self.device._current_range)
        self.scanfBox.setSingleStep(self.currentStepsize)
        self.scanfBox.setDecimals(
            abs(int(np.floor(np.log10(self.currentStepsize)))))
        self.scanfBox.setSuffix(' mA')

        self.lockiLabel = ClickableLabel('Lock i: ')
        self.lockiBox = QtWidgets.QDoubleSpinBox()
        self.lockiBox.setRange(0, 1e3)
        self.lockiBox.setReadOnly(True)
        self.lockiBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.lockiBox.setDecimals(1)
        self.lockiBox.setSuffix(' mA')

        self.lockfLabel = ClickableLabel('Lock f: ')
        self.lockfBox = QtWidgets.QDoubleSpinBox()
        self.lockfBox.setRange(0, 1e3)
        self.lockfBox.setReadOnly(True)
        self.lockfBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.lockfBox.setDecimals(1)
        self.lockfBox.setSuffix(' mA')

        self.thresholdLabel = ClickableLabel('Lock threshold: ')
        self.thresholdBox = QtWidgets.QDoubleSpinBox()
        self.thresholdBox.setRange(0, 3e3)
        self.thresholdBox.setReadOnly(True)
        self.thresholdBox.setButtonSymbols(
            QtWidgets.QAbstractSpinBox.NoButtons)
        self.thresholdBox.setDecimals(1)
        self.thresholdBox.setSuffix(' uA')

        self.plotterClient = PlotterClient(self.reactor, self)
        self.grapherLabel = ClickableLabel('Scan Curve {}: '.format(
            self.name[-1]))
        self.grapher = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        self.grapher.addWidget(self.plotterClient)

        self.stopLabel = ClickableLabel('Stop relock: ')
        self.stopButton = QtWidgets.QPushButton()

        self.statusLabel = ClickableLabel('Status: ')
        self.statusText = QtWidgets.QLineEdit()
        self.statusText.setReadOnly(True)
        self.statusText.setAlignment(QtCore.Qt.AlignCenter)

        # lAYOUT #
        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 1, 1,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(
            self.stateText,
            1,
            1,
        )

        self.layout.addWidget(self.warmupLabel, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.warmupButton, 2, 1)
        self.layout.addWidget(self.shutoffLabel, 2, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.shutoffButton, 2, 3)

        self.layout.addWidget(self.currentLabel, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.currentBox, 3, 1)
        self.layout.addWidget(self.powerLabel, 3, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.powerBox, 3, 3)

        self.layout.addWidget(self.scanLabel, 4, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.scanButton, 4, 1)
        self.layout.addWidget(self.relockLabel, 4, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.relockButton, 4, 3)

        self.layout.addWidget(self.lockLabel, 5, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.lockButton, 5, 1)
        self.layout.addWidget(self.stopLabel, 5, 2, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.stopButton, 5, 3)

        self.layout.addWidget(self.scaniLabel, 6, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.scaniBox, 6, 1)
        self.layout.addWidget(self.scanfLabel, 6, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.scanfBox, 6, 3)

        self.layout.addWidget(self.lockiLabel, 7, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.lockiBox, 7, 1)
        self.layout.addWidget(self.lockfLabel, 7, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.lockfBox, 7, 3)

        self.layout.addWidget(self.thresholdLabel, 8, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.thresholdBox, 8, 1)

        self.layout.addWidget(self.grapherLabel, 9, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.statusLabel, 9, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.statusText, 9, 3)
        self.layout.addWidget(self.grapher, 10, 0, 4, 4)

        self.setWindowTitle(self.name)
        self.setLayout(self.layout)
        self.setFixedSize(390, 580)

        self.reactor.callInThread(self.getAll)
    def populate(self):
        self.nameLabel = ClickableLabel('<b> MSquared Laser Control </b>')

        self.statusLabel = ClickableLabel('<b> MSquared Status: </b>')
        self.statusText = QtWidgets.QLineEdit()
        self.statusText.setReadOnly(True)
        self.statusText.setAlignment(QtCore.Qt.AlignCenter)
        self.statusText.setFixedHeight(40)
        self.statusText.setFont(QtGui.QFont('Arial', 10))

        self.wlmLabel = ClickableLabel('<b> HF Wavemeter: </b>')
        self.wlmText = QtWidgets.QLineEdit()
        self.wlmText.setReadOnly(True)
        self.wlmText.setAlignment(QtCore.Qt.AlignCenter)
        self.wlmText.setFixedHeight(40)
        self.wlmText.setFont(QtGui.QFont('Arial', 10))

        self.lockButton = QtWidgets.QPushButton()
        self.lockButton.setCheckable(True)
        self.lockButton.setFixedHeight(40)
        self.lockButton.setFixedWidth(120)

        self.oneshotButton = QtWidgets.QPushButton()
        self.oneshotButton.setFixedHeight(40)
        self.oneshotButton.setFixedWidth(120)
        self.oneshotButton.setText('One Shot Alignment')

        self.manualButton = QtWidgets.QPushButton()
        self.manualButton.setFixedHeight(40)
        self.manualButton.setFixedWidth(120)
        self.manualButton.setText('Manual Alignment')

        self.EtalonTunerLabel = ClickableLabel('Etalon Tuner: ')
        self.EtalonTunerBox = SuperSpinBox(self.etalon_range,
                                           self.etalon_units,
                                           self.etalon_digits)
        self.EtalonTunerBox.setFixedHeight(self.spinbox_height)
        self.EtalonTunerBox.setFixedWidth(self.spinbox_width)

        self.ResonatorTunerLabel = ClickableLabel('Resonator Tuner: ')
        self.ResonatorTunerBox = SuperSpinBox(self.resonator_range,
                                              self.resonator_units,
                                              self.resonator_digits)
        self.ResonatorTunerBox.setFixedHeight(self.spinbox_height)
        self.ResonatorTunerBox.setFixedWidth(self.spinbox_width)

        self.ResonatorFineTunerLabel = ClickableLabel(
            'Resonator Fine \n Tuner:')
        self.ResonatorFineTunerLabel.setAlignment(QtCore.Qt.AlignRight
                                                  | QtCore.Qt.AlignVCenter)
        self.ResonatorFineTunerBox = SuperSpinBox(self.fineresonator_range,
                                                  self.fineresonator_units,
                                                  self.fineresonator_digits)
        self.ResonatorFineTunerBox.setFixedHeight(self.spinbox_height)
        self.ResonatorFineTunerBox.setFixedWidth(self.spinbox_width)

        self.XLabel = ClickableLabel('X Tuner: ')
        self.XBox = SuperSpinBox(self.xy_range, self.xy_units, self.xy_digits)
        self.XBox.setFixedHeight(self.spinbox_height)
        self.XBox.setFixedWidth(self.spinbox_width)

        self.YLabel = ClickableLabel('Y Tuner: ')
        self.YBox = SuperSpinBox(self.xy_range, self.xy_units, self.xy_digits)
        self.YBox.setFixedHeight(self.spinbox_height)
        self.YBox.setFixedWidth(self.spinbox_width)

        self.wavelengthLabel = ClickableLabel(
            'Preset wavelength: \n (rough tune)')
        self.wavelengthLabel.setAlignment(QtCore.Qt.AlignRight
                                          | QtCore.Qt.AlignVCenter)
        self.wavelengthBox = SuperSpinBox(self.wl_range, self.wl_units,
                                          self.wl_digits)
        self.wavelengthBox.setFixedHeight(self.spinbox_height)
        self.wavelengthBox.setFixedWidth(self.spinbox_width)

        self.EtalonPDLabel = ClickableLabel('Etalon PD DC:')
        self.EtalonPDLabel.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignVCenter)
        self.EtalonPDBox = SuperSpinBox(self.PD_range, self.PD_units,
                                        self.PD_digits)
        self.EtalonPDBox.setFixedHeight(self.spinbox_height)
        self.EtalonPDBox.setFixedWidth(self.spinbox_width)
        self.EtalonPDBox.setReadOnly(True)

        self.OutputPDLabel = ClickableLabel('Output PD:')
        self.OutputPDLabel.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignVCenter)
        self.OutputPDBox = SuperSpinBox(self.PD_range, self.PD_units,
                                        self.PD_digits)
        self.OutputPDBox.setFixedHeight(self.spinbox_height)
        self.OutputPDBox.setFixedWidth(self.spinbox_width)
        self.OutputPDBox.setReadOnly(True)

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 1, 6,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.statusLabel, 2, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.statusText, 2, 1, 2, 5)
        self.layout.addWidget(self.wlmLabel, 4, 0, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.wlmText, 4, 1, 2, 5)
        self.layout.addWidget(self.lockButton, 6, 0, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.oneshotButton, 6, 2, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.manualButton, 6, 4, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.EtalonTunerLabel, 8, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.EtalonTunerBox, 8, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.XLabel, 8, 3, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.XBox, 8, 4, 2, 2, QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.ResonatorTunerLabel, 10, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ResonatorTunerBox, 10, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.YLabel, 10, 3, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.YBox, 10, 4, 2, 2, QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.ResonatorFineTunerLabel, 12, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ResonatorFineTunerBox, 12, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.wavelengthLabel, 12, 3, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.wavelengthBox, 12, 4, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.EtalonPDLabel, 14, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.EtalonPDBox, 14, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.OutputPDLabel, 14, 3, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.OutputPDBox, 14, 4, 2, 2,
                              QtCore.Qt.AlignLeft)

        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setSpacing(5)
        self.setLayout(self.layout)
        self.setFixedSize(450, 450)
Exemplo n.º 10
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')

        self.channelLabel1 = ClickableLabel('<b>' + 'CH 1' + '</b>')
        self.stateButton1 = QtWidgets.QPushButton()
        self.stateButton1.setCheckable(True)

        self.frequencyLabel1 = ClickableLabel('Frequency: ')
        self.frequencyBox1 = SuperSpinBox(self.device._frequency_range,
                                          self.frequencyDisplayUnits,
                                          self.frequencyDigits)
        self.frequencyBox1.setFixedWidth(self.spinboxWidth)

        self.amplitudeLabel1 = ClickableLabel('Amplitude: ')
        self.amplitudeBox1 = SuperSpinBox(self.device._amplitude_range,
                                          self.amplitudeDisplayUnits,
                                          self.amplitudeDigits)
        self.amplitudeBox1.setFixedWidth(self.spinboxWidth)

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

        self.channelLabel2 = ClickableLabel('<b>' + 'CH 2' + '</b>')
        self.stateButton2 = QtWidgets.QPushButton()
        self.stateButton2.setCheckable(True)

        self.frequencyLabel2 = ClickableLabel('Frequency: ')
        self.frequencyBox2 = SuperSpinBox(self.device._frequency_range,
                                          self.frequencyDisplayUnits,
                                          self.frequencyDigits)
        self.frequencyBox2.setFixedWidth(self.spinboxWidth)

        self.amplitudeLabel2 = ClickableLabel('Amplitude: ')
        self.amplitudeBox2 = SuperSpinBox(self.device._amplitude_range,
                                          self.amplitudeDisplayUnits,
                                          self.amplitudeDigits)
        self.amplitudeBox2.setFixedWidth(self.spinboxWidth)

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

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 2,
                              QtCore.Qt.AlignHCenter)

        self.layout.addWidget(self.channelLabel1, 1, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.stateButton1, 1, 1)
        self.layout.addWidget(self.frequencyLabel1, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.frequencyBox1, 2, 1)
        self.layout.addWidget(self.amplitudeLabel1, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.amplitudeBox1, 3, 1)

        self.layout.addWidget(self.channelLabel2, 4, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.stateButton2, 4, 1)
        self.layout.addWidget(self.frequencyLabel2, 5, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.frequencyBox2, 5, 1)
        self.layout.addWidget(self.amplitudeLabel2, 6, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.amplitudeBox2, 6, 1)

        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(120 + self.spinboxWidth, 250)

        self.connectSignals()
        self.reactor.callInThread(self.getAll)
Exemplo n.º 11
0
    def populate(self):
        self.andorLabel = ClickableLabel('<b>' + 'IXon - 888' + '</b>')

        self.tempLabel = ClickableLabel('Temp: ')
        self.tempBox = QtWidgets.QDoubleSpinBox()
        self.tempBox.setRange(-150, 50)
        self.tempBox.setReadOnly(True)
        self.tempBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.tempBox.setDecimals(0)
        self.tempBox.setSuffix(' \u00b0 C')
        self.tempBox.setFixedWidth(80)

        self.emgainLabel = ClickableLabel('EM Gain: ')
        self.emgainBox = QtWidgets.QDoubleSpinBox()
        self.emgainBox.setRange(0, 300)
        self.emgainBox.setReadOnly(True)
        self.emgainBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.emgainBox.setDecimals(0)
        self.emgainBox.setFixedWidth(80)

        self.exposureLabel = ClickableLabel('Exposure Time: ')
        self.exposureBox = SuperSpinBox(self.timeRange, self.timeDisplayUnits,
                                        self.timeDigits)
        self.exposureBox.setReadOnly(True)
        self.exposureBox.setFixedWidth(80)

        self.accumulationLabel = ClickableLabel('Accumulation Time: ')
        self.accumulationBox = SuperSpinBox(self.timeRange,
                                            self.timeDisplayUnits,
                                            self.timeDigits)
        self.accumulationBox.setReadOnly(True)
        self.accumulationBox.setFixedWidth(80)

        self.kineticLabel = ClickableLabel('Kinetic Time: ')
        self.kineticBox = SuperSpinBox(self.timeRange, self.timeDisplayUnits,
                                       self.timeDigits)
        self.kineticBox.setReadOnly(True)
        self.kineticBox.setFixedWidth(80)

        self.readoutLabel = ClickableLabel('Readout Time: ')
        self.readoutBox = SuperSpinBox(self.timeRange, self.timeDisplayUnits,
                                       self.timeDigits)
        self.readoutBox.setReadOnly(True)
        self.readoutBox.setFixedWidth(80)

        self.imageView = pg.ImageView()
        self.imageView.setColorMap(MyColorMap)
        self.imageView.show()

        self.layout = QtWidgets.QGridLayout()
        self.layout.setSpacing(5)
        self.layout.setContentsMargins(5, 5, 5, 5)

        self.layout.addWidget(self.andorLabel, 1, 0, 1, 2,
                              QtCore.Qt.AlignCenter)
        self.layout.addWidget(self.tempLabel, 1, 2, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.tempBox, 1, 3, 1, 1)
        self.layout.addWidget(self.emgainLabel, 1, 4, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.emgainBox, 1, 5, 1, 1)
        self.layout.addWidget(self.exposureLabel, 1, 6, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.exposureBox, 1, 7, 1, 1)
        self.layout.addWidget(self.accumulationLabel, 1, 8, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.accumulationBox, 1, 9, 1, 1)
        self.layout.addWidget(self.kineticLabel, 1, 10, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.kineticBox, 1, 11, 1, 1)
        self.layout.addWidget(self.readoutLabel, 1, 12, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.readoutBox, 1, 13, 1, 1)
        self.layout.addWidget(self.imageView, 2, 0, 15, 15)
        self.setLayout(self.layout)
        # self.setFixedSize(1200, 800)
        self.setWindowTitle('{} - {} - client'.format(self.servername,
                                                      self.name))
class MSQClient(QtWidgets.QWidget):
    """ Widget for Msquared server control """
    msquared_servername = None
    msquared_devicename = None
    wlm_servername = None

    update_time1 = 2500  # [ms]
    update_time2 = 5000  # [ms]
    lock_update_time = 2500  # [ms]
    is_on_OneShot = False

    frequency_units = ['THz', 'GHz']
    wavelength_units = ['nm', 'um']

    etalon_range = (0, 100)  # Etalon tuner
    etalon_units = [(0, '%')]
    etalon_digits = 2
    etalon_max = 196

    resonator_range = (0, 100)  # Resonator tuner
    resonator_units = [(0, '%')]
    resonator_digits = 4
    resonator_max = 196

    fineresonator_range = (0, 100)  # Resonator Fine tuner
    fineresonator_units = [(0, '%')]
    fineresonator_digits = 2

    PD_range = (0, 100)
    PD_units = [(0, 'V')]
    PD_digits = 4

    xy_range = (0, 100)  # X, Y tuner
    xy_units = [(0, '%')]
    xy_digits = 2

    wl_range = (696, 877)  # Rough wavelength
    wl_units = [(0, 'nm')]
    wl_digits = 1

    spinbox_height = 30
    spinbox_width = 80
    update_id = np.random.randint(0, 2**31 - 1)

    def __init__(self, reactor, cxn, msquared_servername, msquared_devicename,
                 wlm_servername, parent):
        super(MSQClient, self).__init__()
        try:
            self.reactor = reactor
            self.cxn = cxn
            self.msquared_servername = msquared_servername
            self.msquared_devicename = msquared_devicename
            self.wlm_servername = wlm_servername
            self.parent = parent
            self.connect()
        except Exception as e:
            print(e)
            traceback.print_exc()

    @inlineCallbacks
    def connect(self):
        if self.cxn == None:
            self.cxn = connection()
            yield self.cxn.connect()
        self.populate()
        yield self.connectWidgets()

    def populate(self):
        self.nameLabel = ClickableLabel('<b> MSquared Laser Control </b>')

        self.statusLabel = ClickableLabel('<b> MSquared Status: </b>')
        self.statusText = QtWidgets.QLineEdit()
        self.statusText.setReadOnly(True)
        self.statusText.setAlignment(QtCore.Qt.AlignCenter)
        self.statusText.setFixedHeight(40)
        self.statusText.setFont(QtGui.QFont('Arial', 10))

        self.wlmLabel = ClickableLabel('<b> HF Wavemeter: </b>')
        self.wlmText = QtWidgets.QLineEdit()
        self.wlmText.setReadOnly(True)
        self.wlmText.setAlignment(QtCore.Qt.AlignCenter)
        self.wlmText.setFixedHeight(40)
        self.wlmText.setFont(QtGui.QFont('Arial', 10))

        self.lockButton = QtWidgets.QPushButton()
        self.lockButton.setCheckable(True)
        self.lockButton.setFixedHeight(40)
        self.lockButton.setFixedWidth(120)

        self.oneshotButton = QtWidgets.QPushButton()
        self.oneshotButton.setFixedHeight(40)
        self.oneshotButton.setFixedWidth(120)
        self.oneshotButton.setText('One Shot Alignment')

        self.manualButton = QtWidgets.QPushButton()
        self.manualButton.setFixedHeight(40)
        self.manualButton.setFixedWidth(120)
        self.manualButton.setText('Manual Alignment')

        self.EtalonTunerLabel = ClickableLabel('Etalon Tuner: ')
        self.EtalonTunerBox = SuperSpinBox(self.etalon_range,
                                           self.etalon_units,
                                           self.etalon_digits)
        self.EtalonTunerBox.setFixedHeight(self.spinbox_height)
        self.EtalonTunerBox.setFixedWidth(self.spinbox_width)

        self.ResonatorTunerLabel = ClickableLabel('Resonator Tuner: ')
        self.ResonatorTunerBox = SuperSpinBox(self.resonator_range,
                                              self.resonator_units,
                                              self.resonator_digits)
        self.ResonatorTunerBox.setFixedHeight(self.spinbox_height)
        self.ResonatorTunerBox.setFixedWidth(self.spinbox_width)

        self.ResonatorFineTunerLabel = ClickableLabel(
            'Resonator Fine \n Tuner:')
        self.ResonatorFineTunerLabel.setAlignment(QtCore.Qt.AlignRight
                                                  | QtCore.Qt.AlignVCenter)
        self.ResonatorFineTunerBox = SuperSpinBox(self.fineresonator_range,
                                                  self.fineresonator_units,
                                                  self.fineresonator_digits)
        self.ResonatorFineTunerBox.setFixedHeight(self.spinbox_height)
        self.ResonatorFineTunerBox.setFixedWidth(self.spinbox_width)

        self.XLabel = ClickableLabel('X Tuner: ')
        self.XBox = SuperSpinBox(self.xy_range, self.xy_units, self.xy_digits)
        self.XBox.setFixedHeight(self.spinbox_height)
        self.XBox.setFixedWidth(self.spinbox_width)

        self.YLabel = ClickableLabel('Y Tuner: ')
        self.YBox = SuperSpinBox(self.xy_range, self.xy_units, self.xy_digits)
        self.YBox.setFixedHeight(self.spinbox_height)
        self.YBox.setFixedWidth(self.spinbox_width)

        self.wavelengthLabel = ClickableLabel(
            'Preset wavelength: \n (rough tune)')
        self.wavelengthLabel.setAlignment(QtCore.Qt.AlignRight
                                          | QtCore.Qt.AlignVCenter)
        self.wavelengthBox = SuperSpinBox(self.wl_range, self.wl_units,
                                          self.wl_digits)
        self.wavelengthBox.setFixedHeight(self.spinbox_height)
        self.wavelengthBox.setFixedWidth(self.spinbox_width)

        self.EtalonPDLabel = ClickableLabel('Etalon PD DC:')
        self.EtalonPDLabel.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignVCenter)
        self.EtalonPDBox = SuperSpinBox(self.PD_range, self.PD_units,
                                        self.PD_digits)
        self.EtalonPDBox.setFixedHeight(self.spinbox_height)
        self.EtalonPDBox.setFixedWidth(self.spinbox_width)
        self.EtalonPDBox.setReadOnly(True)

        self.OutputPDLabel = ClickableLabel('Output PD:')
        self.OutputPDLabel.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignVCenter)
        self.OutputPDBox = SuperSpinBox(self.PD_range, self.PD_units,
                                        self.PD_digits)
        self.OutputPDBox.setFixedHeight(self.spinbox_height)
        self.OutputPDBox.setFixedWidth(self.spinbox_width)
        self.OutputPDBox.setReadOnly(True)

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 1, 6,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.statusLabel, 2, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.statusText, 2, 1, 2, 5)
        self.layout.addWidget(self.wlmLabel, 4, 0, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.wlmText, 4, 1, 2, 5)
        self.layout.addWidget(self.lockButton, 6, 0, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.oneshotButton, 6, 2, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.manualButton, 6, 4, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.EtalonTunerLabel, 8, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.EtalonTunerBox, 8, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.XLabel, 8, 3, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.XBox, 8, 4, 2, 2, QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.ResonatorTunerLabel, 10, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ResonatorTunerBox, 10, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.YLabel, 10, 3, 2, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.YBox, 10, 4, 2, 2, QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.ResonatorFineTunerLabel, 12, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ResonatorFineTunerBox, 12, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.wavelengthLabel, 12, 3, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.wavelengthBox, 12, 4, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.EtalonPDLabel, 14, 0, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.EtalonPDBox, 14, 1, 2, 2,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.OutputPDLabel, 14, 3, 2, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.OutputPDBox, 14, 4, 2, 2,
                              QtCore.Qt.AlignLeft)

        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setSpacing(5)
        self.setLayout(self.layout)
        self.setFixedSize(450, 450)

    @inlineCallbacks
    def connectWidgets(self):
        self.msquared_server = yield self.cxn.get_server(
            self.msquared_servername)
        yield self.msquared_server.signal__update(self.update_id)
        yield self.msquared_server.addListener(listener=self.receive_update,
                                               source=None,
                                               ID=self.update_id)
        self.wlm_server = yield self.cxn.get_server(self.wlm_servername)
        self.nameLabel.clicked.connect(self.onNameLabelClick)
        self.wlmLabel.clicked.connect(self.getWLM)
        self.lockButton.released.connect(self.onLockButton)
        self.oneshotButton.released.connect(self.onOneShotButton)
        self.manualButton.released.connect(self.onManualButton)
        self.XBox.returnPressed.connect(self.onX)
        self.YBox.returnPressed.connect(self.onY)
        self.wavelengthBox.returnPressed.connect(self.onWavelength)
        self.EtalonPDLabel.clicked.connect(self.getEtalonPD)
        self.OutputPDLabel.clicked.connect(self.getOutputPD)

        self.timer1 = QtCore.QTimer(self)
        self.timer1.timeout.connect(self.timer_task1)
        self.timer1.start(self.update_time1)

        self.timer2 = QtCore.QTimer(self)
        self.timer2.timeout.connect(self.timer_task2)
        self.timer2.start(self.update_time2)

        self.lock_timer = QtCore.QTimer(self)
        self.lock_timer.timeout.connect(self.lock_timer_task)

        self.getAll()

    def receive_update(self, c, signal_json):
        signal = json.loads(signal_json)
        message = signal.get('alignment_x_auto')
        if message is not None:
            value = message[self.msquared_devicename]
            self.displayX(value)
        message = signal.get('alignment_y_auto')
        if message is not None:
            value = message[self.msquared_devicename]
            self.displayY(value)

    def disable_when_wlm_lock(self, state):
        self.lockButton.setDisabled(state)
        self.EtalonTunerBox.setDisabled(state)
        self.wavelengthBox.setDisabled(state)

        resonator_state = not bool(state ^ self.lockButton.isChecked())
        self.ResonatorTunerBox.setDisabled(resonator_state)
        self.ResonatorFineTunerBox.setDisabled(resonator_state)

    def onNameLabelClick(self):
        self.getAll()

    def timer_task1(self):
        if self.lockButton.isChecked():
            self.getLockState()
        if self.parent.LockClient.lockButton.isChecked():
            self.lock_timer.start(self.lock_update_time)
        else:
            self.lock_timer.stop()

    def timer_task2(self):
        if self.is_on_OneShot:
            self.getOneShotState()
            self.getOutputPD()
            self.getEtalonPD()

    def lock_timer_task(self):
        self.getWLM()
        self.getResonatorTuner()
        self.getEtalonPD()
        self.getOutputPD()

    def getAll(self):
        self.getLockState()
        self.getEtalonTuner()
        self.getResonatorTuner()
        self.getX()
        self.getY()
        self.getWavelength()
        self.getWLM()
        self.getEtalonPD()
        self.getOutputPD()

    def onLockButton(self):
        lock_state = self.lockButton.isChecked()
        self.setLockState(lock_state)

    @inlineCallbacks
    def setLockState(self, lock_state):
        if lock_state:
            request_json = json.dumps({self.msquared_devicename: True})
        else:
            request_json = json.dumps({self.msquared_devicename: False})
        yield self.msquared_server.etalon_lock(request_json)
        self.displayLockState(lock_state)

    @inlineCallbacks
    def getLockState(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.etalon_lock(request_json)
        response = json.loads(response_json)
        message = response[self.msquared_devicename]
        if message == True:
            lock_state = True
        elif message == False:
            lock_state = False
        else:
            lock_state = False
            self.statusText.setText(message)
            request_json = json.dumps({self.msquared_devicename: False})
            yield self.msquared_server.etalon_lock(request_json)
        self.displayLockState(lock_state)

    def displayLockState(self, lock_state):
        if lock_state == True:
            self.lockButton.setChecked(1)
            self.lockButton.setText('Remove Etalon Lock')
            self.statusText.setText('Etalon lock ON')
            self.ResonatorTunerBox.setDisabled(False)
            self.ResonatorFineTunerBox.setDisabled(False)
        else:
            self.lockButton.setChecked(0)
            self.lockButton.setText('Apply Etalon Lock')
            self.statusText.setText('Etalon lock OFF')
            self.ResonatorTunerBox.setDisabled(True)
            self.ResonatorFineTunerBox.setDisabled(True)
        self.parent.toggle_lock()

    @inlineCallbacks
    def onOneShotButton(self):
        if not self.is_on_OneShot:
            self.is_on_OneShot = True
            mode = 4  # 4 for One Shot
            request_json = json.dumps({self.msquared_devicename: mode})
            yield self.msquared_server.beam_alignment(request_json)
            self.statusText.setText('One Shot Alignment Started...')
            self.oneshotButton.setDisabled(True)
            self.manualButton.setEnabled(True)
            self.XBox.setDisabled(True)
            self.YBox.setDisabled(True)
        else:
            pass

    @inlineCallbacks
    def getOneShotState(self):
        if self.is_on_OneShot:
            request_json = json.dumps({self.msquared_devicename: None})
            response_json = yield self.msquared_server.beam_alignment(
                request_json)
            status = json.loads(response_json).get(self.msquared_devicename)
            if status == True:
                self.is_on_OneShot = False
                self.statusText.setText('One Shot Alignment Completed')
                self.oneshotButton.setDisabled(False)
                self.XBox.setDisabled(False)
                self.YBox.setDisabled(False)
            else:
                pass
        else:
            pass

    @inlineCallbacks
    def onNewEtalonTuner(self):
        value = self.EtalonTunerBox.value()
        request_json = json.dumps({self.msquared_devicename: value})
        yield self.msquared_server.etalon_tune(request_json)
        self.displayEtalonTuner(value)

    @inlineCallbacks
    def getEtalonTuner(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.etalon_tune(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        value_percentage = value / self.etalon_max * 100
        self.displayEtalonTuner(value_percentage)

    def displayEtalonTuner(self, value):
        self.EtalonTunerBox.display(value)

    @inlineCallbacks
    def onNewResonatorTuner(self):
        value = self.ResonatorTunerBox.value()
        request_json = json.dumps({self.msquared_devicename: value})
        yield self.msquared_server.resonator_tune(request_json)
        self.displayResonatorTuner(value)

    @inlineCallbacks
    def getResonatorTuner(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.resonator_tune(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        value_percentage = value / self.resonator_max * 100
        self.displayResonatorTuner(value_percentage)

    def displayResonatorTuner(self, value):
        self.ResonatorTunerBox.display(value)

    @inlineCallbacks
    def onManualButton(self):
        self.is_on_OneShot = False
        self.oneshotButton.setDisabled(False)
        self.XBox.setDisabled(False)
        self.YBox.setDisabled(False)
        mode = 1  # 1 for Manual
        request_json = json.dumps({self.msquared_devicename: mode})
        yield self.msquared_server.beam_alignment(request_json)

    @inlineCallbacks
    def onX(self):
        value = self.XBox.value()
        request_json = json.dumps({self.msquared_devicename: value})
        yield self.msquared_server.alignment_x(request_json)
        self.displayX(value)

    @inlineCallbacks
    def getX(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.alignment_x(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        self.displayX(value)

    def displayX(self, value):
        self.XBox.display(value)

    @inlineCallbacks
    def onY(self):
        value = self.YBox.value()
        request_json = json.dumps({self.msquared_devicename: value})
        yield self.msquared_server.alignment_y(request_json)
        self.displayY(value)

    @inlineCallbacks
    def getY(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.alignment_y(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        self.displayY(value)

    def displayY(self, value):
        self.YBox.display(value)

    @inlineCallbacks
    def onWavelength(self):
        value = self.wavelengthBox.value()
        request_json = json.dumps({self.msquared_devicename: value})
        yield self.msquared_server.wavelength(request_json)
        self.displayWavelength(value)

    @inlineCallbacks
    def getWavelength(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.wavelength(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        self.displayWavelength(value)

    def displayWavelength(self, value):
        self.wavelengthBox.display(value)

    @inlineCallbacks
    def getWLM(self):
        units = self.parent.PIDClient.unitsBox.currentText()
        channel = self.parent.PIDClient.channelBox.currentText()
        if units in self.frequency_units:
            value = yield self.wlm_server.get_frequency(int(channel))
        elif units in self.wavelength_units:
            value = yield self.wlm_server.get_wavelength(int(channel))
        self.displayWLM(value, units)

    def displayWLM(self, value, units):
        self.wlmText.setText('{} {}'.format(value, units))

    @inlineCallbacks
    def getEtalonPD(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.etalon_pd(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        self.displayEtalonPD(value)

    def displayEtalonPD(self, value):
        self.EtalonPDBox.display(value)

    @inlineCallbacks
    def getOutputPD(self):
        request_json = json.dumps({self.msquared_devicename: None})
        response_json = yield self.msquared_server.output_pd(request_json)
        response = json.loads(response_json)
        value = response.get(self.msquared_devicename)
        self.displayOutputPD(value)

    def displayOutputPD(self, value):
        self.OutputPDBox.display(value)

    def closeEvent(self, x):
        pass
Exemplo n.º 13
0
    def populateGUI(self):
        self.AFGnameLabel = ClickableLabel('<b> RED MOT AFG </b>')

        self.ch1Label = ClickableLabel('CH1: ')
        self.ch1Button = QtWidgets.QPushButton()
        self.ch1Button.setText('Configure')

        self.scale1Label = ClickableLabel('Scale 1: ')
        self.scale1Box = SuperSpinBox(self.device.scaleRange,
                                      self.scaleDisplayUnits, self.scaleDigits)
        self.scale1Box.setFixedWidth(self.spinboxWidth)

        self.offset1Label = ClickableLabel('Offset 1: ')
        self.offset1Box = SuperSpinBox(self.device.offsetRange,
                                       self.offsetDisplayUnits,
                                       self.offsetDigits)
        self.offset1Box.setFixedWidth(self.spinboxWidth)

        self.ch2Label = ClickableLabel('CH2: ')
        self.ch2Button = QtWidgets.QPushButton()
        self.ch2Button.setText('Configure')

        self.scale2Label = ClickableLabel('Scale 2: ')
        self.scale2Box = SuperSpinBox(self.device.scaleRange,
                                      self.scaleDisplayUnits, self.scaleDigits)
        self.scale2Box.setFixedWidth(self.spinboxWidth)

        self.offset2Label = ClickableLabel('Offset 2: ')
        self.offset2Box = SuperSpinBox(self.device.offsetRange,
                                       self.offsetDisplayUnits,
                                       self.offsetDigits)
        self.offset2Box.setFixedWidth(self.spinboxWidth)

        # lAYOUT #
        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.AFGnameLabel, 0, 0, 1, 2,
                              QtCore.Qt.AlignHCenter)

        self.layout.addWidget(self.ch1Label, 1, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch1Button, 1, 1)
        self.layout.addWidget(self.scale1Label, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.scale1Box, 2, 1)
        self.layout.addWidget(self.offset1Label, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.offset1Box, 3, 1)

        self.layout.addWidget(self.ch2Label, 4, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch2Button, 4, 1)
        self.layout.addWidget(self.scale2Label, 5, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.scale2Box, 5, 1)
        self.layout.addWidget(self.offset2Label, 6, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.offset2Box, 6, 1)

        self.setWindowTitle(self.name)
        self.setLayout(self.layout)
        self.setFixedSize(180, 200)

        self.reactor.callInThread(self.getAll)
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')

        self.shape1Label = ClickableLabel('679 nm :')

        self.shape1Button = QtWidgets.QPushButton()
        self.shape1Button.setCheckable(True)

        self.dc1Label = ClickableLabel('DC 1 Voltage: ')
        self.dc1Box = SuperSpinBox(self.device._dc_v_range,
                                   self.voltageDisplayUnits,
                                   self.voltageDigits)
        self.dc1Box.setFixedWidth(self.spinboxWidth)

        self.ramp1Label = ClickableLabel('Ramp 1 Freq : ')
        self.ramp1AmpLabel = ClickableLabel('Ramp 1 Amp :')
        self.ramp1OffsetLabel = ClickableLabel('Ramp 1 Offset :')

        self.ramp1FreqBox = SuperSpinBox(self.device._ramp_freq_range,
                                         self.frequencyDisplayUnits,
                                         self.frequencyDigits)
        self.ramp1FreqBox.setFixedWidth(self.spinboxWidth)

        self.ramp1AmpBox = SuperSpinBox(self.device._dc_v_range,
                                        self.voltageDisplayUnits,
                                        self.voltageDigits)
        self.ramp1AmpBox.setFixedWidth(self.spinboxWidth)

        self.ramp1OffsetBox = SuperSpinBox(self.device._dc_v_range,
                                           self.voltageDisplayUnits,
                                           self.voltageDigits)
        self.ramp1OffsetBox.setFixedWidth(self.spinboxWidth)

        self.shape2Label = ClickableLabel('707 nm :')

        self.shape2Button = QtWidgets.QPushButton()
        self.shape2Button.setCheckable(True)

        self.dc2Label = ClickableLabel('DC 2 Voltage: ')
        self.dc2Box = SuperSpinBox(self.device._dc_v_range,
                                   self.voltageDisplayUnits,
                                   self.voltageDigits)
        self.dc2Box.setFixedWidth(self.spinboxWidth)

        self.ramp2Label = ClickableLabel('Ramp 2 Freq : ')
        self.ramp2AmpLabel = ClickableLabel('Ramp 2 Amp :')
        self.ramp2OffsetLabel = ClickableLabel('Ramp 2 Offset :')

        self.ramp2FreqBox = SuperSpinBox(self.device._ramp_freq_range,
                                         self.frequencyDisplayUnits,
                                         self.frequencyDigits)
        self.ramp2FreqBox.setFixedWidth(self.spinboxWidth)

        self.ramp2AmpBox = SuperSpinBox(self.device._dc_v_range,
                                        self.voltageDisplayUnits,
                                        self.voltageDigits)
        self.ramp2AmpBox.setFixedWidth(self.spinboxWidth)

        self.ramp2OffsetBox = SuperSpinBox(self.device._dc_v_range,
                                           self.voltageDisplayUnits,
                                           self.voltageDigits)
        self.ramp2OffsetBox.setFixedWidth(self.spinboxWidth)

        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 2,
                              QtCore.Qt.AlignCenter)

        self.layout.addWidget(self.shape1Label, 1, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.shape1Button, 1, 1)

        self.layout.addWidget(self.dc1Label, 2, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.dc1Box, 2, 1)

        self.layout.addWidget(self.ramp1Label, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp1FreqBox, 3, 1)

        self.layout.addWidget(self.ramp1AmpLabel, 4, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp1AmpBox, 4, 1)
        self.layout.addWidget(self.ramp1OffsetLabel, 5, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp1OffsetBox, 5, 1)

        self.layout.addWidget(self.shape2Label, 6, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.shape2Button, 6, 1)

        self.layout.addWidget(self.dc2Label, 7, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.dc2Box, 7, 1)

        self.layout.addWidget(self.ramp2Label, 8, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp2FreqBox, 8, 1)

        self.layout.addWidget(self.ramp2AmpLabel, 9, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp2AmpBox, 9, 1)
        self.layout.addWidget(self.ramp2OffsetLabel, 10, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ramp2OffsetBox, 10, 1)

        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(120 + self.spinboxWidth, 300)

        self.connectSignals()
        self.reactor.callInThread(self.getAll)
Exemplo n.º 15
0
class PIDClient(QtWidgets.QWidget):
    
    wlm_lock_servername = None
    
    units = None
    units_list = ['nm', 'GHz']
    
    channel_list = ['1', '2', '3', '4']
    
    gain_range = (0, 100)
    gain_units = [(0, '')]
    gain_digits = 2
    
    setpoint_range = (0, 1e15)
    setpoint_units = [(0, '')]
    setpoint_digits = 6
    
    offset_range = (0, 100)  # Resonator offset
    offset_units = [(0, '%')]
    offset_digits = 4
    
    spinbox_height = 30
    spinbox_width = 80
    
    config_directory = 'C:\\LabRad\\SrA\\msquared_wlm_lock'
    
    def __init__(self, reactor, cxn, wlm_lock_servername, parent):
        super(PIDClient, self).__init__(None)
        try:
            self.reactor = reactor
            self.cxn = cxn
            self.wlm_lock_servername = wlm_lock_servername
            self.parent = parent
            self.connect()
        except Exception as e:
            print(e)
            traceback.print_exc()            
    
    @inlineCallbacks
    def connect(self):
        if self.cxn == None:
            self.cxn = connection()
            yield self.cxn.connect()
        self.populate()
        yield self.connectWidgets()
    
    def populate(self):
        self.nameLabel =  ClickableLabel('<b> PID Settings </b>')
        
        self.loadButton = QtWidgets.QPushButton()
        self.loadButton.setText('Load Settings')
        self.loadButton.setFixedHeight(40)
        self.loadButton.setFixedWidth(100)
        self.saveButton = QtWidgets.QPushButton()
        self.saveButton.setText('Save Settings')
        self.saveButton.setFixedHeight(40)
        self.saveButton.setFixedWidth(self.spinbox_width*1.5)
        
        self.setpointLabel = ClickableLabel('Set point: ')
        self.setpointBox = SuperSpinBox(self.setpoint_range, self.setpoint_units,
                                        self.setpoint_digits)
        self.setpointBox.setFixedHeight(self.spinbox_height)
        self.setpointBox.setFixedWidth(self.spinbox_width*1.5)
    
        self.offsetLabel = ClickableLabel('Offset: ')
        self.offsetBox = SuperSpinBox(self.offset_range, self.offset_units,
                                        self.offset_digits)
        self.offsetBox.setFixedHeight(self.spinbox_height)
        self.offsetBox.setFixedWidth(self.spinbox_width*1.5)
        
        self.unitsLabel = ClickableLabel('<b> Setpoint Units: </b>')
        self.unitsBox = QtWidgets.QComboBox()
        self.unitsBox.addItems(self.units_list)
        
        self.channelLabel = ClickableLabel('<b> WLM Channel: </b>')
        self.channelBox = QtWidgets.QComboBox()
        self.channelBox.addItems(self.channel_list)
        
        self.OverallGainLabel = ClickableLabel('Overall Gain: ')
        self.OverallGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                        4)
        self.OverallGainBox.setFixedHeight(self.spinbox_height)
        self.OverallGainBox.setFixedWidth(self.spinbox_width)
        self.PGainLabel = ClickableLabel('P Gain: ')
        self.PGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                        self.gain_digits)
        self.PGainBox.setFixedHeight(self.spinbox_height)
        self.PGainBox.setFixedWidth(self.spinbox_width)
        self.IGainLabel = ClickableLabel('I Gain: ')
        self.IGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                        self.gain_digits)
        self.IGainBox.setFixedHeight(self.spinbox_height)
        self.IGainBox.setFixedWidth(self.spinbox_width)
        self.DGainLabel = ClickableLabel('D Gain: ')
        self.DGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                        self.gain_digits)
        self.DGainBox.setFixedHeight(self.spinbox_height)
        self.DGainBox.setFixedWidth(self.spinbox_width)
        
        
        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.nameLabel, 1, 0, 3, 1, 
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.loadButton, 1, 1, 3, 2, 
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.saveButton, 1, 3, 3, 2, 
                              QtCore.Qt.AlignHCenter)
        
        self.layout.addWidget(self.setpointLabel, 4, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.setpointBox, 4, 1, 3, 3, 
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.offsetLabel, 7, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.offsetBox, 7, 1, 3, 3, 
                              QtCore.Qt.AlignLeft)
        
        self.layout.addWidget(self.unitsLabel, 4, 3, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.unitsBox, 6, 3, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.channelLabel, 8, 3, 2, 2,
                              QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.channelBox, 10, 3, 2, 2,
                              QtCore.Qt.AlignHCenter)
        
        self.layout.addWidget(self.OverallGainLabel, 10, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.OverallGainBox, 10, 1, 3, 1,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.PGainLabel, 13, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.PGainBox, 13, 1, 3, 1,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.IGainLabel, 16, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.IGainBox, 16, 1, 3, 1,
                              QtCore.Qt.AlignLeft)
        self.layout.addWidget(self.DGainLabel, 19, 0, 3, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.DGainBox, 19, 1, 3, 1,
                              QtCore.Qt.AlignLeft)
        
        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setSpacing(10)
        self.setLayout(self.layout)
        self.setFixedSize(400, 300)

    # def updateParameters(self, parameter_values):
    #     self.parameter_values = parameter_values
    #     self.displaySequence(self.sequence)
    
    @inlineCallbacks
    def connectWidgets(self):
        self.wlm_lock_server = yield self.cxn.get_server(self.wlm_lock_servername)
        
        self.nameLabel.clicked.connect(self.getAll)
        self.loadButton.clicked.connect(self.browseLoad)
        self.saveButton.clicked.connect(self.browseSave)
        self.setpointBox.returnPressed.connect(self.onNewPIDsetpoint)
        self.offsetBox.returnPressed.connect(self.onNewPIDoffset)
        self.OverallGainBox.returnPressed.connect(self.onNewPIDparams)
        self.PGainBox.returnPressed.connect(self.onNewPIDparams)
        self.IGainBox.returnPressed.connect(self.onNewPIDparams)
        self.DGainBox.returnPressed.connect(self.onNewPIDparams)
        self.unitsBox.currentIndexChanged.connect(self.onUnitsChange)
        self.channelBox.currentIndexChanged.connect(self.onChannelChange)
        
        self.getAll()
    
    def disconnectWidgets(self):
        try:
            self.nameLabel.disconnect()
            self.loadButton.disconnect()
            self.saveButton.disconnect()
            self.setpointBox.disconnect()
            self.offsetBox.disconnect()
            self.OverallGainBox.disconnect()
            self.PGainBox.disconnect()
            self.IGainBox.disconnect()
            self.DGainBox.disconnect()
            self.unitsBox.disconnect()
            self.channelBox.disconnect()
        except:
            pass
    
    def disableAll(self):
        self.loadButton.setDisabled(True)
        self.saveButton.setDisabled(True)
        self.setpointBox.setDisabled(True)
        self.offsetBox.setDisabled(True)
        self.OverallGainBox.setDisabled(True)
        self.PGainBox.setDisabled(True)
        self.IGainBox.setDisabled(True)
        self.DGainBox.setDisabled(True)
        self.unitsBox.setDisabled(True)
        self.channelBox.setDisabled(True)
        self.disconnectWidgets()

    def enableAll(self):
        self.loadButton.setDisabled(False)
        self.saveButton.setDisabled(False)
        self.setpointBox.setDisabled(False)
        self.offsetBox.setDisabled(False)
        self.OverallGainBox.setDisabled(False)
        self.PGainBox.setDisabled(False)
        self.IGainBox.setDisabled(False)
        self.DGainBox.setDisabled(False)
        self.unitsBox.setDisabled(False)
        self.channelBox.setDisabled(False)
        self.connectWidgets()
    
    def getAll(self):
        self.getPID()
        self.getWLM()
    
    def disable_when_wlm_lock(self, state):
        self.unitsBox.setDisabled(state)
        self.channelBox.setDisabled(state)
        self.setpointBox.setDisabled(state)
        self.offsetBox.setDisabled(state)
        self.loadButton.setDisabled(state)
    
    @inlineCallbacks
    def loadSettingsFromServer(self):
        current_settings_json = yield self.wlm_lock_server.load_current_settings()
        current_settings = json.loads(current_settings_json)
        self.displaySettings(current_settings)

    def browseLoad(self):
        # timestr = time.strftime(self.time_format)
        directory = self.config_directory
        if not os.path.exists(directory):
            directory = self.config_directory.split('{}')[0]
        filepath = QtWidgets.QFileDialog().getOpenFileName(directory=directory)[0]  # Added [0]
        if filepath:
            self.loadConfig(filepath)
    
    def loadConfig(self, filepath):
        with open(filepath, 'r') as infile:
            settings = json.load(infile)
        self.displaySettings(settings)       
        
    def browseSave(self):
        directory = self.config_directory
        if not os.path.exists(directory):
            directory = self.config_directory.split('{}')[0]
        filepath = QtWidgets.QFileDialog().getSaveFileName(directory=directory)[0]
        if filepath:
            self.saveConfig(filepath)
    
    @inlineCallbacks
    def saveConfig(self, filepath):
        current_settings_json = yield self.wlm_lock_server.load_current_settings()
        with open(filepath, 'w') as f:
            f.write(current_settings_json)

    def displaySettings(self, settings):
        pid_settings = settings['pid']
        wlm_settings = settings['wlm']
        
        setpoint = pid_settings['setpoint']
        offset = pid_settings['offset']
        overall_gain = pid_settings['overall_gain']
        prop_gain = pid_settings['prop_gain']
        int_gain = pid_settings['int_gain']
        diff_gain = pid_settings['diff_gain']
        
        units = wlm_settings['units']
        channel = wlm_settings['channel']
        
        self.displayPIDsetpoint(setpoint)
        self.displayPIDoffset(offset)
        self.displayPIDparams(overall_gain, prop_gain, int_gain, diff_gain)
        self.displayUnits(units)
        self.displayChannel(channel)    


    def getPID(self):
        self.getPIDsetpoint()
        self.getPIDoffset()
        self.getPIDparams()
    
    @inlineCallbacks
    def getPIDsetpoint(self):
        setpoint = yield self.wlm_lock_server.get_setpoint()
        self.displayPIDsetpoint(setpoint)
        
    @inlineCallbacks
    def getPIDoffset(self):
        offset = yield self.wlm_lock_server.get_offset()
        self.displayPIDoffset(offset)
    
    @inlineCallbacks
    def getPIDparams(self):
        overall_gain = yield self.wlm_lock_server.get_gain()
        prop_gain = yield self.wlm_lock_server.get_prop_gain()
        int_gain = yield self.wlm_lock_server.get_int_gain()
        diff_gain = yield self.wlm_lock_server.get_diff_gain()
        self.displayPIDparams(overall_gain, prop_gain, int_gain, diff_gain)
    
    def displayPIDsetpoint(self, setpoint):
        self.setpointBox.display(setpoint)

    def displayPIDoffset(self, offset):
        self.offsetBox.display(offset)
        
    def displayPIDparams(self, overall_gain, prop_gain, int_gain, diff_gain):
        self.OverallGainBox.display(overall_gain)
        self.PGainBox.display(prop_gain)
        self.IGainBox.display(int_gain)
        self.DGainBox.display(diff_gain)
    
    def onNewPIDsetpoint(self):
        setpoint = self.setpointBox.value()
        self.setPIDsetpoint(setpoint)

    def onNewPIDoffset(self):
        offset = self.offsetBox.value()
        self.setPIDoffset(offset)
    
    def onNewPIDparams(self):
        overall_gain = self.OverallGainBox.value()
        prop_gain = self.PGainBox.value()
        int_gain = self.IGainBox.value()
        diff_gain = self.DGainBox.value()
        self.setPIDparams(overall_gain, prop_gain, int_gain, diff_gain)

    @inlineCallbacks
    def setPIDsetpoint(self, setpoint):
        yield self.wlm_lock_server.set_setpoint(setpoint)
        self.displayPIDsetpoint(setpoint)
        
    @inlineCallbacks
    def setPIDoffset(self, offset):
        yield self.wlm_lock_server.set_offset(offset)
        self.displayPIDoffset(offset)
        
    @inlineCallbacks
    def setPIDparams(self, overall_gain, prop_gain, int_gain, diff_gain):
        yield self.wlm_lock_server.set_gain(overall_gain)
        yield self.wlm_lock_server.set_prop_gain(prop_gain)
        yield self.wlm_lock_server.set_int_gain(int_gain)
        yield self.wlm_lock_server.set_diff_gain(diff_gain)
        self.displayPIDparams(overall_gain, prop_gain, int_gain, diff_gain)
    
    def getWLM(self):
        self.getUnits()
        self.getChannel() 
        
    def onUnitsChange(self):
        value = self.unitsBox.currentText()
        self.setUnits(value)
    
    @inlineCallbacks
    def setUnits(self, value):
        yield self.wlm_lock_server.set_units(value)
    
    @inlineCallbacks
    def getUnits(self):
        units = yield self.wlm_lock_server.get_units()
        self.displayUnits(units)
    
    def displayUnits(self, units):
        index = self.unitsBox.findText(units, QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.unitsBox.setCurrentIndex(index)
    
    def onChannelChange(self):
        value = self.channelBox.currentText()
        self.setChannel(int(value))

    @inlineCallbacks
    def setChannel(self, value):
        yield self.wlm_lock_server.set_channel(value)
        
    @inlineCallbacks
    def getChannel(self):
        channel = yield self.wlm_lock_server.get_channel()
        self.displayChannel(channel)
        
    def displayChannel(self, channel):
        index = self.channelBox.findText(str(channel), QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.channelBox.setCurrentIndex(index)
    
    def closeEvent(self, x):
        # super(WLMLockControllerClient, self).closeEvent(x)
        # self.PIDClient.wlm_lock_server.remove_etalon_lock(10) # TODO: Remove Etalon Lock when exit
        try:
            self.reactor.stop()
            x.accept()
        except:
            pass       
Exemplo n.º 16
0
 def populate(self):
     self.nameLabel =  ClickableLabel('<b> PID Settings </b>')
     
     self.loadButton = QtWidgets.QPushButton()
     self.loadButton.setText('Load Settings')
     self.loadButton.setFixedHeight(40)
     self.loadButton.setFixedWidth(100)
     self.saveButton = QtWidgets.QPushButton()
     self.saveButton.setText('Save Settings')
     self.saveButton.setFixedHeight(40)
     self.saveButton.setFixedWidth(self.spinbox_width*1.5)
     
     self.setpointLabel = ClickableLabel('Set point: ')
     self.setpointBox = SuperSpinBox(self.setpoint_range, self.setpoint_units,
                                     self.setpoint_digits)
     self.setpointBox.setFixedHeight(self.spinbox_height)
     self.setpointBox.setFixedWidth(self.spinbox_width*1.5)
 
     self.offsetLabel = ClickableLabel('Offset: ')
     self.offsetBox = SuperSpinBox(self.offset_range, self.offset_units,
                                     self.offset_digits)
     self.offsetBox.setFixedHeight(self.spinbox_height)
     self.offsetBox.setFixedWidth(self.spinbox_width*1.5)
     
     self.unitsLabel = ClickableLabel('<b> Setpoint Units: </b>')
     self.unitsBox = QtWidgets.QComboBox()
     self.unitsBox.addItems(self.units_list)
     
     self.channelLabel = ClickableLabel('<b> WLM Channel: </b>')
     self.channelBox = QtWidgets.QComboBox()
     self.channelBox.addItems(self.channel_list)
     
     self.OverallGainLabel = ClickableLabel('Overall Gain: ')
     self.OverallGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                     4)
     self.OverallGainBox.setFixedHeight(self.spinbox_height)
     self.OverallGainBox.setFixedWidth(self.spinbox_width)
     self.PGainLabel = ClickableLabel('P Gain: ')
     self.PGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                     self.gain_digits)
     self.PGainBox.setFixedHeight(self.spinbox_height)
     self.PGainBox.setFixedWidth(self.spinbox_width)
     self.IGainLabel = ClickableLabel('I Gain: ')
     self.IGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                     self.gain_digits)
     self.IGainBox.setFixedHeight(self.spinbox_height)
     self.IGainBox.setFixedWidth(self.spinbox_width)
     self.DGainLabel = ClickableLabel('D Gain: ')
     self.DGainBox = SuperSpinBox(self.gain_range, self.gain_units,
                                     self.gain_digits)
     self.DGainBox.setFixedHeight(self.spinbox_height)
     self.DGainBox.setFixedWidth(self.spinbox_width)
     
     
     self.layout = QtWidgets.QGridLayout()
     self.layout.addWidget(self.nameLabel, 1, 0, 3, 1, 
                           QtCore.Qt.AlignHCenter)
     self.layout.addWidget(self.loadButton, 1, 1, 3, 2, 
                           QtCore.Qt.AlignHCenter)
     self.layout.addWidget(self.saveButton, 1, 3, 3, 2, 
                           QtCore.Qt.AlignHCenter)
     
     self.layout.addWidget(self.setpointLabel, 4, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.setpointBox, 4, 1, 3, 3, 
                           QtCore.Qt.AlignLeft)
     self.layout.addWidget(self.offsetLabel, 7, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.offsetBox, 7, 1, 3, 3, 
                           QtCore.Qt.AlignLeft)
     
     self.layout.addWidget(self.unitsLabel, 4, 3, 2, 2,
                           QtCore.Qt.AlignHCenter)
     self.layout.addWidget(self.unitsBox, 6, 3, 2, 2,
                           QtCore.Qt.AlignHCenter)
     self.layout.addWidget(self.channelLabel, 8, 3, 2, 2,
                           QtCore.Qt.AlignHCenter)
     self.layout.addWidget(self.channelBox, 10, 3, 2, 2,
                           QtCore.Qt.AlignHCenter)
     
     self.layout.addWidget(self.OverallGainLabel, 10, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.OverallGainBox, 10, 1, 3, 1,
                           QtCore.Qt.AlignLeft)
     self.layout.addWidget(self.PGainLabel, 13, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.PGainBox, 13, 1, 3, 1,
                           QtCore.Qt.AlignLeft)
     self.layout.addWidget(self.IGainLabel, 16, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.IGainBox, 16, 1, 3, 1,
                           QtCore.Qt.AlignLeft)
     self.layout.addWidget(self.DGainLabel, 19, 0, 3, 1, 
                           QtCore.Qt.AlignRight)
     self.layout.addWidget(self.DGainBox, 19, 1, 3, 1,
                           QtCore.Qt.AlignLeft)
     
     self.layout.setContentsMargins(5, 5, 5, 5)
     self.layout.setSpacing(10)
     self.setLayout(self.layout)
     self.setFixedSize(400, 300)
Exemplo n.º 17
0
    def populateGUI(self):
        self.nameLabel = ClickableLabel('<b>' + self.name + '</b>')
        
        self.beatnoteLabel = ClickableLabel('Beatnote Freq: ')
        self.beatnoteBox = SuperSpinBox(self.device._frequency_range, 
                                          self.frequencyDisplayUnits, 
                                          self.frequencyDigits)
        self.beatnoteBox.setFixedWidth(self.spinboxWidth)
        
        self.isotopeLabel = ClickableLabel('Choose isotope: ')
        self.isotopeBox = QtWidgets.QComboBox()
        isotope = 'Sr-88'
        isotope_list = ['Sr-87, F=11/2', 'Sr-87, F=9/2', 'Sr-86', 'Sr-84']
        
        self.isotopeBox.addItem(isotope)
        self.isotopeBox.addItems(isotope_list)
        
        self.transitionfreqLabel = ClickableLabel('1S0-3P1 freq: ')
        self.transitionfreqBox = QtWidgets.QDoubleSpinBox()
        self.transitionfreqBox.setRange(0, 3e9)
        self.transitionfreqBox.setReadOnly(True)
        self.transitionfreqBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.transitionfreqBox.setDecimals(2)
        self.transitionfreqBox.setGroupSeparatorShown(True)
        self.transitionfreqBox.setSuffix(' MHz')
        
        self.redafreqLabel = ClickableLabel('Red-A freq: ')
        self.redafreqBox = QtWidgets.QDoubleSpinBox()
        self.redafreqBox.setRange(0, 3e9)
        self.redafreqBox.setReadOnly(True)
        self.redafreqBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.redafreqBox.setDecimals(2)
        self.transitionfreqBox.setGroupSeparatorShown(True)
        self.transitionfreqBox.setSuffix(' MHz')
        
        # CH 2
        self.name2Label = ClickableLabel('<b>' + 'CH2' + '</b>')
        self.state2Button = QtWidgets.QPushButton()
        self.state2Button.setCheckable(True)
        
        self.layout = QtWidgets.QGridLayout() 
        self.layout.addWidget(self.nameLabel, 0, 0, 1, 2, 
                              QtCore.Qt.AlignCenter)
        
        self.layout.addWidget(self.beatnoteLabel, 1, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.beatnoteBox, 1, 1)
        
        self.layout.addWidget(self.isotopeLabel, 2, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.isotopeBox, 2, 1)
        
        self.layout.addWidget(self.transitionfreqLabel, 3, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.transitionfreqBox, 3, 1)        

        self.layout.addWidget(self.redafreqLabel, 4, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.redafreqBox, 4, 1)   
        
        self.layout.addWidget(self.name2Label, 5, 0, 1, 1, 
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.state2Button, 5, 1)
        
        self.setLayout(self.layout)

        self.setWindowTitle(self.name)
        self.setFixedSize(120 + self.spinboxWidth, 170)
        
        self.connectSignals()
        self.reactor.callInThread(self.getAll)
Exemplo n.º 18
0
    def populateGUI(self):
        self.SGname1Label = ClickableLabel('<b> 679 nm: </b>')

        self.dc1Label = ClickableLabel('set DC [V]: ')
        self.dc1Box = QtWidgets.QDoubleSpinBox()
        self.dc1Box.setKeyboardTracking(False)
        self.dc1Box.setRange(*self.device2._v_range)
        self.dc1Box.setSingleStep(self.vStepsize * 5)  # Mininum Step Size at
        self.dc1Box.setDecimals(abs(int(np.floor(np.log10(self.vStepsize)))))

        self.SGname2Label = ClickableLabel('<b> 707 nm: </b>')

        self.dc2Label = ClickableLabel('set DC [V]: ')
        self.dc2Box = QtWidgets.QDoubleSpinBox()
        self.dc2Box.setKeyboardTracking(False)
        self.dc2Box.setRange(*self.device2._v_range)
        self.dc2Box.setSingleStep(self.vStepsize * 5)  # Mininum Step Size at
        self.dc2Box.setDecimals(abs(int(np.floor(np.log10(self.vStepsize)))))

        self.WLMname1Label = ClickableLabel('<b> WLM Ch1 (nm) :</b>')

        self.ch1Box = QtWidgets.QDoubleSpinBox()
        self.ch1Box.setRange(0, 1e10)
        self.ch1Box.setReadOnly(True)
        self.ch1Box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.ch1Box.setDecimals(5)

        self.WLMname2Label = ClickableLabel('<b> WLM Ch2 (nm) :</b>')

        self.ch2Box = QtWidgets.QDoubleSpinBox()
        self.ch2Box.setRange(0, 1e10)
        self.ch2Box.setReadOnly(True)
        self.ch2Box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.ch2Box.setDecimals(5)

        self.WLMname3Label = ClickableLabel('<b> WLM Ch3 (nm) :</b>')

        self.ch3Box = QtWidgets.QDoubleSpinBox()
        self.ch3Box.setRange(0, 1e10)
        self.ch3Box.setReadOnly(True)
        self.ch3Box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.ch3Box.setDecimals(5)

        self.WLMname4Label = ClickableLabel('<b> WLM Ch4 (nm) :</b>')

        self.ch4Box = QtWidgets.QDoubleSpinBox()
        self.ch4Box.setRange(0, 1e10)
        self.ch4Box.setReadOnly(True)
        self.ch4Box.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.ch4Box.setDecimals(5)

        # lAYOUT #

        # lAYOUT #
        self.layout = QtWidgets.QGridLayout()
        self.layout.addWidget(self.SGname1Label, 1, 0, 1, 1,
                              QtCore.Qt.AlignHCenter)

        self.layout.addWidget(self.dc1Label, 2, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.dc1Box, 2, 1)

        self.layout.addWidget(self.SGname2Label, 3, 0, 1, 1,
                              QtCore.Qt.AlignHCenter)

        self.layout.addWidget(self.dc2Label, 4, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.dc2Box, 4, 1)

        self.layout.addWidget(self.WLMname1Label, 5, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch1Box, 5, 1)
        self.layout.addWidget(self.WLMname2Label, 6, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch2Box, 6, 1)
        self.layout.addWidget(self.WLMname3Label, 7, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch3Box, 7, 1)
        self.layout.addWidget(self.WLMname4Label, 8, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.ch4Box, 8, 1)

        self.setWindowTitle(self.name1)
        self.setLayout(self.layout)
        self.setFixedSize(220, 200)

        self.reactor.callInThread(self.getAll)
Exemplo n.º 19
0
class PDViewer(QtWidgets.QDialog):
    pd_name = None
    data_dir = None

    boxHeight = 50
    boxWidth = 220

    def __init__(self, reactor, cxn=None):
        super(PDViewer, self).__init__(None)
        self.reactor = reactor
        self.cxn = cxn
        print(self.data_dir)

        self.update_id = np.random.randint(0, 2**31 - 1)
        self.loading = False
        self.connect()

    @inlineCallbacks
    def connect(self):
        if self.cxn is None:
            self.cxn = connection()
            cname = 'pd - {} - client'.format(self.pd_name)
            yield self.cxn.connect(name=cname)

        self.populate()
        yield self.connect_signals()

    def populate(self):
        self.setWindowTitle(self.pd_name)
        self.canvas = MplCanvas()
        self.nav = NavigationToolbar(self.canvas, self)

        self.nameLabel1 = ClickableLabel('Parameter 1: ')
        self.nameLabel1.setFont(QtGui.QFont("Times", 18))
        self.nameBox1 = QtWidgets.QLineEdit()
        self.nameBox1.setFixedSize(self.boxWidth, self.boxHeight)

        self.valueLabel1 = ClickableLabel('Value 1: ')
        self.valueLabel1.setFont(QtGui.QFont("Times", 18))
        self.valueBox1 = NeatSpinBox()
        self.valueBox1.setFixedSize(self.boxWidth, self.boxHeight)

        self.nameLabel2 = ClickableLabel('Parameter 2: ')
        self.nameLabel2.setFont(QtGui.QFont("Times", 18))
        self.nameBox2 = QtWidgets.QLineEdit()
        self.nameBox2.setFixedSize(self.boxWidth, self.boxHeight)

        self.valueLabel2 = ClickableLabel('Value 2: ')
        self.valueLabel2.setFont(QtGui.QFont("Times", 18))
        self.valueBox2 = NeatSpinBox()
        self.valueBox2.setFixedSize(self.boxWidth, self.boxHeight)

        self.layout = QtWidgets.QGridLayout()
        self.layout.setSpacing(1)
        self.layout.setContentsMargins(2, 2, 2, 2)

        self.layout.addWidget(self.nav, 1, 0, 1, 5)
        self.layout.addWidget(self.canvas, 2, 0, 4, 4)

        self.layout.addWidget(self.nameLabel1, 7, 0, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.nameBox1, 7, 1)
        self.layout.addWidget(self.valueLabel1, 7, 2, 1, 1,
                              QtCore.Qt.AlignRight)
        self.layout.addWidget(self.valueBox1, 7, 3)

        # self.layout.addWidget(self.nameLabel2, 8, 0, 1, 1,
        #                       QtCore.Qt.AlignRight)
        # self.layout.addWidget(self.nameBox2, 8, 1)
        # self.layout.addWidget(self.valueLabel2, 8, 2, 1, 1,
        #                       QtCore.Qt.AlignRight)
        # self.layout.addWidget(self.valueBox2, 8, 3)

        self.setLayout(self.layout)

        width = self.canvas.width() + 20
        height = self.nav.height() + self.canvas.height(
        ) + self.nameBox1.height() * 2 + 60
        self.setFixedSize(width, height)
        self.setWindowTitle('pd_viewer')

    @inlineCallbacks
    def connect_signals(self):
        pd_server = yield self.cxn.get_server('pd')
        yield pd_server.signal__update(self.update_id)
        yield pd_server.addListener(listener=self.receive_update,
                                    source=None,
                                    ID=self.update_id)

    def receive_update(self, c, signal_json):
        signal = json.loads(signal_json)
        for message_type, message in signal.items():
            device_message = message.get(self.pd_name)
            if (message_type == 'record') and (device_message is not None):
                print(message_type, message)
                self.replot(device_message)
            elif (message_type == 'loading_rate') and (device_message
                                                       is not None):
                print(message_type, message)
                sample_rate = message.get('sample_rate')
                loading_rate, loss_rate, volt_to_number = process_signal(
                    sample_rate, device_message, message_type)
                # self.GetParameter()
                # self.GetValue()
                self.replot_loading(sample_rate, device_message, loading_rate,
                                    loss_rate)

    def replot(self, rel_data_path):
        abs_data_path = os.path.join(self.data_dir, rel_data_path) + '.hdf5'
        save_data_path = os.path.join(self.data_dir, rel_data_path) + '.png'
        with h5py.File(abs_data_path) as h5f:
            exp = h5f['exp']
            self.canvas.ax.clear()
            self.canvas.ax.plot(exp, label='exp')
            self.canvas.ax.legend()
            self.canvas.ax.set_xlabel('Points')
            self.canvas.ax.set_ylabel('Voltage [V]')
        self.canvas.fig.savefig(save_data_path)
        self.canvas.draw()

    def replot_loading(self, sample_rate, rel_data_path, loading_rate,
                       loss_rate):
        abs_data_path = os.path.join(self.data_dir, rel_data_path) + '.hdf5'
        save_data_path = os.path.join(self.data_dir, rel_data_path) + '.png'
        with h5py.File(abs_data_path) as h5f:
            exp = h5f['exp']
            self.canvas.ax.clear()
            x = np.linspace(0, len(exp) / sample_rate, len(exp))
            self.canvas.ax.plot(x, exp, label='exp', c='black')
            self.canvas.ax.plot(x,
                                fit_loading(x, loading_rate, loss_rate),
                                label='fitted',
                                c='red',
                                linestyle='dashed')
            self.canvas.ax.legend()
            self.canvas.ax.set_xlabel('Time [s]')
            self.canvas.ax.set_ylabel('Voltage [V]')
        self.canvas.fig.savefig(save_data_path)
        self.canvas.draw()

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