Commit 1dc78886 authored by Martin Drechsler's avatar Martin Drechsler

blinking enabled

parent 0d88326f
......@@ -124,4 +124,6 @@ class digital_control_signal(QtCore.QObject):
if state == QtCore.Qt.Checked:
self.DO.set_out(True)
else:
self.DO.set_out(False)
\ No newline at end of file
self.DO.set_out(False)
\ No newline at end of file
......@@ -60,7 +60,7 @@ class ControlGui(QtGui.QFrame):
self.dock_397.addWidget(self.laser397_control_layout, 0, 0)
self.dock_397_scan.addWidget(self.laser397_scan_layout, 0, 1)
self.laser866_control_layout = LaserControlLayout('866', checkboxes=['shutter866', 'shuter866WM'], spinboxes = ['piezoA866', 'piezoB866'])
self.laser866_control_layout = LaserControlLayout('866', checkboxes=['shutter866', 'shuter866WM'], spinboxes = ['piezoA866', 'piezoB866'], blinkCheckbox = ['shutter866'])
self.laser866_scan_layout = LaserScanLayout(name='piezoA866', signal_to_scan_layout=self.laser866_control_layout)
self.dock_866.addWidget(self.laser866_control_layout)
self.dock_866_scan.addWidget(self.laser866_scan_layout)
......
......@@ -39,7 +39,9 @@ class LaserControlLayout(pg.LayoutWidget):
A class for creating a layout with spinboxes and checkboxes to control a laser.
"""
_registry = []
def __init__(self, name, spinboxes = ['sbA', 'sbB'], checkboxes = ['cbA', 'cbB'], custom_geometry = False):
blinkSignal = QtCore.pyqtSignal(bool, float)
def __init__(self, name, spinboxes = ['sbA', 'sbB'], checkboxes = ['cbA', 'cbB'], custom_geometry = False, blinkCheckbox = []):
super().__init__()
self._registry.append(self)
self.name = name
......@@ -50,7 +52,6 @@ class LaserControlLayout(pg.LayoutWidget):
self.spinboxes = {}
self.checkboxes = {}
for i, sb_name in enumerate(spinboxes, start = 1):
self.spinboxes[sb_name] = CustomSpinBox(siPrefix=True, suffix='V')
if custom_geometry != True:
......@@ -64,10 +65,24 @@ class LaserControlLayout(pg.LayoutWidget):
self.addWidget(QtGui.QLabel(cb_name), row, 2*i)
self.addWidget(self.checkboxes[cb_name], row, 2*i + 1)
self.blinkCheckboxes = {}
self.blinkSpinboxes = {}
self.blinkTimers = {}
for i, cb_name in enumerate(blinkCheckbox, start=0):
self.blinkCheckboxes[cb_name] = QtGui.QCheckBox()
self.blinkCheckboxes[cb_name].stateChanged.connect(lambda: self.blink(cb_name))
self.blinkSpinboxes[cb_name] = CustomSpinBox(siPrefix=True, suffix='s', value = 1)
self.blinkSpinboxes[cb_name].setMinimum(0.01)
self.blinkTimers[cb_name] = QtCore.QTimer()
self.blinkTimers[cb_name].timeout.connect(self.checkboxes[cb_name].toggle)
if custom_geometry != True:
row = 2 + len(self.spinboxes)
self.addWidget(QtGui.QLabel('blink '+cb_name), row, 0)
self.addWidget(self.blinkCheckboxes[cb_name], row, 1)
self.addWidget(self.blinkSpinboxes[cb_name], row, 2)
def blink(self, cb):
pass
def freeze(self):
for sb in self.spinboxes:
self.spinboxes[sb].setEnabled(False)
......@@ -81,6 +96,17 @@ class LaserControlLayout(pg.LayoutWidget):
self.checkboxes[cb].setEnabled(True)
def blink(self, cb_name):
T = self.blinkSpinboxes[cb_name].value()
if self.blinkCheckboxes[cb_name].isChecked():
print(' '.join((cb_name, 'blinking with period: ')), T)
self._initial_state = self.checkboxes[cb_name].isChecked()
self.blinkTimers[cb_name].start(T*1e3)
else:
print(' '.join((cb_name, 'blinking stopped')))
self.blinkTimers[cb_name].stop()
self.checkboxes[cb_name].setChecked(self._initial_state)
class LaserScanLayout(pg.LayoutWidget):
"""
A class for creating a layout for scanning a laser piezo.
......@@ -89,7 +115,7 @@ class LaserScanLayout(pg.LayoutWidget):
_registry = []
scanActionSignal = QtCore.pyqtSignal(object)
def __init__(self, name, signal_to_scan_layout, feedforward_enables = False):
def __init__(self, name, signal_to_scan_layout):
super().__init__()
self._registry.append(self)
self.name = name
......
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