Commit 014be47f authored by Martin Drechsler's avatar Martin Drechsler

coherent wavemeter doesnt crashes the gui. Now it closes if error occurs, and...

coherent wavemeter doesnt crashes the gui. Now it closes if error occurs, and there is a reconnection button
parent c3350f58
......@@ -173,8 +173,8 @@ class GuiMainWindow(QMainWindow):
self.layout866.addWidget(QtGui.QLabel(self.piezoA866.name), 1, 0), self.layout866.addWidget(self.piezoA866.sb, 1, 1)
self.layout866.addWidget(QtGui.QLabel(self.piezoB866.name), 2, 0), self.layout866.addWidget(self.piezoB866.sb, 2, 1)
self.layout866.addWidget(QtGui.QLabel(self.shutter866.name), 3, 0), self.layout866.addWidget(self.shutter866.cb, 3, 1)
self.layout866.addWidget(QtGui.QLabel("Blink"), 3, 2), self.layout866.addWidget(self.shutter866.blink_cb, 3, 3)
self.layout866.addWidget(QtGui.QLabel("866 WM"), 3, 2), self.layout866.addWidget(self.shutterLED.cb, 3, 3)
self.layout866.addWidget(QtGui.QLabel("Blink"), 4, 0), self.layout866.addWidget(self.shutter866.blink_cb, 4, 1)
self.layout866_scan.addWidget(QtGui.QLabel('866 Scan piezo B'), 0, 0)
self.layout866_scan.addWidget(QtGui.QLabel('start'), 1, 0), self.layout866_scan.addWidget(self.piezoB866.scan_sb_start, 1, 1)
......@@ -189,7 +189,7 @@ class GuiMainWindow(QMainWindow):
self.layoutPI.addWidget(QtGui.QLabel('Photoion'), 0, 0)
self.layoutPI.addWidget(QtGui.QLabel(self.piezoA423.name), 1, 0), self.layoutPI.addWidget(self.piezoA423.sb, 1, 1)
self.layoutPI.addWidget(QtGui.QLabel(self.shutter423.name), 2, 0), self.layoutPI.addWidget(self.shutter423.cb, 2, 1)
self.layoutPI.addWidget(QtGui.QLabel(self.shutterLED.name), 3, 0), self.layoutPI.addWidget(self.shutterLED.cb, 3, 1)
#self.layoutPI.addWidget(QtGui.QLabel(self.shutterLED.name), 3, 0), self.layoutPI.addWidget(self.shutterLED.cb, 3, 1)
self.layout423_scan.addWidget(QtGui.QLabel('423 Scan piezo A'), 0, 0)
self.layout423_scan.addWidget(QtGui.QLabel('start'), 1, 0), self.layout423_scan.addWidget(self.piezoA423.scan_sb_start, 1, 1)
......
......@@ -213,11 +213,11 @@ class digital_control_signal(QWidget):
if self.blink_cb.isChecked():
self.blink_variable = self.cb.isChecked()
self.blink_timer.start(1000)
self.blink_timer.start(500)
print("starting blinkin")
else:
self.blink_timer.stop()
self.DO.set_out( self.cb.isChecked() )
self.DO.set_out( not self.cb.isChecked() )
print("finishing blink")
def _blinkEvent(self):
......@@ -319,9 +319,15 @@ class coherentWM(QWidget):
def update_label():
try:
value = wav_coherent.read_measurement(wavCoh)
unit = wav_coherent.check_unit(wavCoh)
except:
print("coherent wm problem, closing communication")
wavCoh.close()
self.layoutWM.timer.stop()
try:
lcd.display(value + ' ' + unit)
......@@ -336,6 +342,17 @@ class coherentWM(QWidget):
self.layoutWM.timer.start(500) # every 10,000 milliseconds
self.layoutWM.setGeometry(300, 300, 250, 150)
def reconnect():
try:
wavCoh= serial.Serial('COM11', timeout=1, rtscts=True)
wavCoh.close()
self.layoutWM.timer.start(500)
except:
print("cannot reconnect")
self.reactivateButton = QPushButton('Reconnect')
self.reactivateButton.clicked.connect(reconnect)
combo = QComboBox()
......@@ -363,4 +380,4 @@ class coherentWM(QWidget):
self.layoutWM.addWidget(lcd, 0, 0)
self.layoutWM.addWidget(combo, 1, 0)
self.dockWM.addWidget(self.layoutWM)
\ No newline at end of file
self.dockWM.addWidget(self.reactivateButton)
\ No newline at end of file
......@@ -34,6 +34,8 @@ def set_unit(wm, unit):
"""
with wm as w:
string_to_write = b'UNI ' + unit + b'\n'
w.write(string_to_write)
def check_unit(wm):
......@@ -53,14 +55,17 @@ if __name__ == '__main__':
import serial
import time
wavCoh=serial.Serial('COM11', timeout=1, rtscts=True)
wavCoh.close()
set_unit(wavCoh, b'F')
print(read_measurement(wavCoh))
read_measurement(wavCoh)
print(a[12:20])
check_unit(wavCoh)
import os
scriptDirectory = os.path.dirname(os.path.realpath(__file__))
while(1):
print(read_measurement(wavCoh))
time.sleep(0.5)
# print(a[12:20])
# check_unit(wavCoh)
# import os
# scriptDirectory = os.path.dirname(os.path.realpath(__file__))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment