Commit 1908d2d6 authored by Martin Drechsler's avatar Martin Drechsler

some changes to make it work on the real camera

parent 1dc78886
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
""" """
Here the class of control signals are created. There are two types: analog and digital. Here the class of control signals are created. There are two types: analog and digital.
""" """
from drivers.ADoutputs import daq_AO, daq_DO import sys
if sys.platform == 'linux':
from drivers.ADoutputs_linux import daq_AO, daq_DO
else:
from drivers.ADoutputs import daq_AO, daq_DO
from PyQt5 import QtCore from PyQt5 import QtCore
from subclasses.controllayouts import LaserControlLayout from subclasses.controllayouts import LaserControlLayout
from subclasses.controllayouts import LaserScanLayout from subclasses.controllayouts import LaserScanLayout
...@@ -104,7 +108,7 @@ class anal_control_signal(QtCore.QObject): ...@@ -104,7 +108,7 @@ class anal_control_signal(QtCore.QObject):
class digital_control_signal(QtCore.QObject): class digital_control_signal(QtCore.QObject):
_registry = [] _registry = []
def __init__(self, name, channel, inverse=False): def __init__(self, name, channel, inverse=True):
super().__init__() super().__init__()
self._registry.append(self) self._registry.append(self)
......
...@@ -89,6 +89,7 @@ class CameraGuiMainWindow(QMainWindow): ...@@ -89,6 +89,7 @@ class CameraGuiMainWindow(QMainWindow):
# image layout # image layout
self.img = pg.ImageItem(border="w") self.img = pg.ImageItem(border="w")
self.img.rotate(90)
self.imv = pg.ImageView(imageItem=self.img, view=self.imageView) self.imv = pg.ImageView(imageItem=self.img, view=self.imageView)
self.imv.ui.roiBtn.setText('Useless') self.imv.ui.roiBtn.setText('Useless')
self.dCameraView.addWidget(self.imv) self.dCameraView.addWidget(self.imv)
...@@ -271,6 +272,7 @@ class CameraGuiMainWindow(QMainWindow): ...@@ -271,6 +272,7 @@ class CameraGuiMainWindow(QMainWindow):
#@QtCore.pyqtSlot() #@QtCore.pyqtSlot()
def measurement_ending(self): def measurement_ending(self):
print('entering gui measure ending')
self.cameraButton.setEnabled(True) self.cameraButton.setEnabled(True)
self.measurementFrame.startMeasureButton.setEnabled(True) self.measurementFrame.startMeasureButton.setEnabled(True)
self.measurementFrame.saveMeasureButton.setEnabled(True) self.measurementFrame.saveMeasureButton.setEnabled(True)
......
...@@ -56,12 +56,12 @@ class ControlGui(QtGui.QFrame): ...@@ -56,12 +56,12 @@ class ControlGui(QtGui.QFrame):
self.laser397_control_layout = LaserControlLayout('397', checkboxes=['shutter397'], spinboxes = ['piezoA397', 'piezoB397']) self.laser397_control_layout = LaserControlLayout('397', checkboxes=['shutter397'], spinboxes = ['piezoA397', 'piezoB397'])
self.laser397_scan_layout = LaserScanLayout(name='piezoA397', signal_to_scan_layout=self.laser397_control_layout) self.laser397_scan_layout = LaserScanLayout(name='piezoB397', signal_to_scan_layout=self.laser397_control_layout)
self.dock_397.addWidget(self.laser397_control_layout, 0, 0) self.dock_397.addWidget(self.laser397_control_layout, 0, 0)
self.dock_397_scan.addWidget(self.laser397_scan_layout, 0, 1) self.dock_397_scan.addWidget(self.laser397_scan_layout, 0, 1)
self.laser866_control_layout = LaserControlLayout('866', checkboxes=['shutter866', 'shuter866WM'], spinboxes = ['piezoA866', 'piezoB866'], blinkCheckbox = ['shutter866']) self.laser866_control_layout = LaserControlLayout('866', checkboxes=['shutter866', 'shutter866WM'], spinboxes = ['piezoA866', 'piezoB866'], blinkCheckbox = ['shutter866'])
self.laser866_scan_layout = LaserScanLayout(name='piezoA866', signal_to_scan_layout=self.laser866_control_layout) self.laser866_scan_layout = LaserScanLayout(name='piezoB866', signal_to_scan_layout=self.laser866_control_layout)
self.dock_866.addWidget(self.laser866_control_layout) self.dock_866.addWidget(self.laser866_control_layout)
self.dock_866_scan.addWidget(self.laser866_scan_layout) self.dock_866_scan.addWidget(self.laser866_scan_layout)
...@@ -87,7 +87,6 @@ class ControlGui(QtGui.QFrame): ...@@ -87,7 +87,6 @@ class ControlGui(QtGui.QFrame):
self.electrodes_control_layout.addWidget(self.electrodes_control_layout.spinboxes['compExYb'], 1, 5) self.electrodes_control_layout.addWidget(self.electrodes_control_layout.spinboxes['compExYb'], 1, 5)
self.toolbar = myToolbarMenu(self) self.toolbar = myToolbarMenu(self)
self.toolbar.load()
self.autosave_timer = QtCore.QTimer() self.autosave_timer = QtCore.QTimer()
self.autosave_timer.timeout.connect(lambda: self.toolbar.save('config.ini')) self.autosave_timer.timeout.connect(lambda: self.toolbar.save('config.ini'))
self.autosave_timer.start(10000) self.autosave_timer.start(10000)
......
...@@ -749,10 +749,11 @@ class AndorBase(SDK3Camera): ...@@ -749,10 +749,11 @@ class AndorBase(SDK3Camera):
def live_acquisition_loop(self): def live_acquisition_loop(self):
t = threading.currentThread() t = threading.currentThread()
timeout = self.ExposureTime.getValue() * 5000
while getattr(t, "do_run", True): while getattr(t, "do_run", True):
a_s, px_encoding, xs, ys, bufs = self._live_acq_auxs a_s, px_encoding, xs, ys, bufs = self._live_acq_auxs
try: try:
pData, lData = SDK3.WaitBuffer(self.handle, 10000) pData, lData = SDK3.WaitBuffer(self.handle, int(timeout))
except: except:
return return
img = create_aligned_array(xs*ys, 'uint16') img = create_aligned_array(xs*ys, 'uint16')
......
from PyQt5 import QtGui, QtCore from PyQt5 import QtGui, QtCore
#from drivers.andorzyla import AndorZyla from drivers.andorzyla import AndorZyla
from drivers.dummyAndor import AndorZyla #from drivers.dummyAndor import AndorZyla
from cameraGui import CameraGuiMainWindow from cameraGui import CameraGuiMainWindow
from zylaCameraWorker import CameraWorker from zylaCameraWorker import CameraWorker
#from measurement import MeasurementWorker, MeasurementGui
from MCDAQcontrolsignals import anal_control_signal from MCDAQcontrolsignals import anal_control_signal
from MCDAQcontrolsignals import digital_control_signal from MCDAQcontrolsignals import digital_control_signal
from controlGui import ControlGui from controlGui import ControlGui
...@@ -20,24 +19,24 @@ if __name__ == "__main__": ...@@ -20,24 +19,24 @@ if __name__ == "__main__":
camera = AndorZyla(0) camera = AndorZyla(0)
piezoA397 = anal_control_signal('piezoA397', channel=0, ao_type='cavity_piezo', out_minimum = 0, out_maximum = 4) piezoA397 = anal_control_signal('piezoA397', channel=13, ao_type='cavity_piezo', out_minimum = 0, out_maximum = 4)
piezoB397 = anal_control_signal('piezoB397', channel=1, ao_type='cavity_piezo') piezoB397 = anal_control_signal('piezoB397', channel=7, ao_type='cavity_piezo')
piezoA866 = anal_control_signal('piezoA866', channel=2, ao_type='cavity_piezo', out_minimum = 0, out_maximum = 4) piezoA866 = anal_control_signal('piezoA866', channel=14, ao_type='cavity_piezo', out_minimum = 0, out_maximum = 4)
piezoB866 = anal_control_signal('piezoB866', channel=3, ao_type='cavity_piezo') piezoB866 = anal_control_signal('piezoB866', channel=9, ao_type='cavity_piezo', out_minimum = -2, out_maximum = 10)
piezo423 = anal_control_signal('piezo423', channel=4, ao_type='laser_piezo') piezo423 = anal_control_signal('piezo423', channel=3, ao_type='laser_piezo')
trapDCA = anal_control_signal('dcA', channel = 5, ao_type='electrode') trapDCA = anal_control_signal('dcA', channel = 2, ao_type='electrode')
trapDCB = anal_control_signal('dcB', channel = 6, ao_type='electrode') trapDCB = anal_control_signal('dcB', channel = 1, ao_type='electrode')
trapCOMPC = anal_control_signal('compC', channel = 7, ao_type='electrode') trapCOMPC = anal_control_signal('compC', channel = 4, ao_type='electrode')
trapCOMPD = anal_control_signal('compD', channel = 8, ao_type='electrode') trapCOMPD = anal_control_signal('compD', channel = 5, ao_type='electrode')
trapOven = anal_control_signal('compOven', channel = 9, ao_type='electrode') trapOven = anal_control_signal('compOven', channel = 0, ao_type='electrode')
trapExYb = anal_control_signal('compExYb', channel = 10, ao_type='electrode') trapExYb = anal_control_signal('compExYb', channel = 6, ao_type='electrode')
shutter866 = digital_control_signal('shutter866', channel = 0) shutter866 = digital_control_signal('shutter866', channel = 2, inverse=True)
shutter397 = digital_control_signal('shutter397', channel = 1) shutter397 = digital_control_signal('shutter397', channel = 0, inverse=True)
shutter423 = digital_control_signal('shutter423', channel = 2) shutter423 = digital_control_signal('shutter423', channel = 1, inverse=True)
shutter866WM = digital_control_signal('shutter866WM', channel = 3) shutter866WM = digital_control_signal('shutter866WM', channel = 3, inverse=True)
controlGui = ControlGui() controlGui = ControlGui()
mcDAQthread = QtCore.QThread() mcDAQthread = QtCore.QThread()
...@@ -65,5 +64,6 @@ if __name__ == "__main__": ...@@ -65,5 +64,6 @@ if __name__ == "__main__":
cameraThread.start() cameraThread.start()
mcDAQthread.start() mcDAQthread.start()
controlGui.toolbar.load()
sys.exit(app.exec_()) sys.exit(app.exec_())
...@@ -7,8 +7,8 @@ This is a temporary script file. ...@@ -7,8 +7,8 @@ This is a temporary script file.
import cv2 import cv2
cap = cv2.VideoCapture(0) cap = cv2.VideoCapture(2)
cap1 = cv2.VideoCapture(1) cap1 = cv2.VideoCapture(3)
while(True): while(True):
# Capture frame-by-frame # Capture frame-by-frame
......
...@@ -26,7 +26,7 @@ class BasicAcquisitonParameters(pTypes.GroupParameter): ...@@ -26,7 +26,7 @@ class BasicAcquisitonParameters(pTypes.GroupParameter):
['12-bit (high well capacity)', '12-bit (low noise)', '16-bit (low noise & high well capacity)']} ['12-bit (high well capacity)', '12-bit (low noise)', '16-bit (low noise & high well capacity)']}
) )
self.addChild({'name': 'Readout Time', 'type': 'float', 'value': 0, 'readonly': True}) self.addChild({'name': 'Readout Time', 'type': 'float', 'value': 0, 'readonly': True})
self.addChild({'name': 'Spurious Noise Filter', 'type': 'list', 'values': ['True', 'False']}) self.addChild({'name': 'Spurious Noise Filter', 'type': 'list', 'values': [True, False]})
self.addChild({'name': 'Sensor Temperature', 'type': 'float', 'value': 25, 'readonly': True}) self.addChild({'name': 'Sensor Temperature', 'type': 'float', 'value': 25, 'readonly': True})
self.addChild({'name': 'Temperature Status', 'type': 'str', 'value': '?', 'readonly': True}) self.addChild({'name': 'Temperature Status', 'type': 'str', 'value': '?', 'readonly': True})
......
...@@ -9,213 +9,216 @@ from resources.messages import show_warning ...@@ -9,213 +9,216 @@ from resources.messages import show_warning
class CustomSpinBox(pg.SpinBox): class CustomSpinBox(pg.SpinBox):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if self.opts['suffix'] == 'V': # fixing a context menu with some scales if self.opts['suffix'] == 'V': # fixing a context menu with some scales
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._on_context_menu) self.customContextMenuRequested.connect(self._on_context_menu)
self.popMenu = QtGui.QMenu(self) self.popMenu = QtGui.QMenu(self)
self.act_2_step = QtGui.QAction('2 mV step', self) self.act_2_step = QtGui.QAction('2 mV step', self)
self.act_5_step = QtGui.QAction('5 mV step', self) self.act_5_step = QtGui.QAction('5 mV step', self)
self.act_10_step = QtGui.QAction('10 mV step', self) self.act_10_step = QtGui.QAction('10 mV step', self)
self.act_100_step = QtGui.QAction('100 mV step', self) self.act_100_step = QtGui.QAction('100 mV step', self)
self.popMenu.addAction(self.act_2_step) self.popMenu.addAction(self.act_2_step)
self.popMenu.addAction(self.act_5_step) self.popMenu.addAction(self.act_5_step)
self.popMenu.addAction(self.act_10_step) self.popMenu.addAction(self.act_10_step)
self.popMenu.addAction(self.act_100_step) self.popMenu.addAction(self.act_100_step)
self.act_2_step.triggered.connect(lambda: self.setSingleStep(0.002)) self.act_2_step.triggered.connect(lambda: self.setSingleStep(0.002))
self.act_5_step.triggered.connect(lambda: self.setSingleStep(0.005)) self.act_5_step.triggered.connect(lambda: self.setSingleStep(0.005))
self.act_10_step.triggered.connect(lambda: self.setSingleStep(0.01)) self.act_10_step.triggered.connect(lambda: self.setSingleStep(0.01))
self.act_100_step.triggered.connect(lambda: self.setSingleStep(0.1)) self.act_100_step.triggered.connect(lambda: self.setSingleStep(0.1))
def _on_context_menu(self, point): def _on_context_menu(self, point):
# show context menu # show context menu
self.popMenu.exec_(self.mapToGlobal(point)) self.popMenu.exec_(self.mapToGlobal(point))
class LaserControlLayout(pg.LayoutWidget): class LaserControlLayout(pg.LayoutWidget):
""" """
A class for creating a layout with spinboxes and checkboxes to control a laser. A class for creating a layout with spinboxes and checkboxes to control a laser.
""" """
_registry = [] _registry = []
blinkSignal = QtCore.pyqtSignal(bool, float) blinkSignal = QtCore.pyqtSignal(bool, float)
def __init__(self, name, spinboxes = ['sbA', 'sbB'], checkboxes = ['cbA', 'cbB'], custom_geometry = False, blinkCheckbox = []): def __init__(self, name, spinboxes = ['sbA', 'sbB'], checkboxes = ['cbA', 'cbB'], custom_geometry = False, blinkCheckbox = []):
super().__init__() super().__init__()
self._registry.append(self) self._registry.append(self)
self.name = name self.name = name
if custom_geometry != True: if custom_geometry != True:
self.layout.addWidget(QtGui.QLabel(self.name), 0, 0) self.layout.addWidget(QtGui.QLabel(self.name), 0, 0)
self.spinboxes = {} self.spinboxes = {}
self.checkboxes = {} self.checkboxes = {}
for i, sb_name in enumerate(spinboxes, start = 1): for i, sb_name in enumerate(spinboxes, start = 1):
self.spinboxes[sb_name] = CustomSpinBox(siPrefix=True, suffix='V') self.spinboxes[sb_name] = CustomSpinBox(siPrefix=True, suffix='V')
if custom_geometry != True: if custom_geometry != True:
self.addWidget(QtGui.QLabel(sb_name), i, 0) self.addWidget(QtGui.QLabel(sb_name), i, 0)
self.addWidget(self.spinboxes[sb_name], i, 1) self.addWidget(self.spinboxes[sb_name], i, 1)
for i, cb_name in enumerate(checkboxes, start = 0): for i, cb_name in enumerate(checkboxes, start = 0):
self.checkboxes[cb_name] = QtGui.QCheckBox() self.checkboxes[cb_name] = QtGui.QCheckBox()
if custom_geometry != True: if custom_geometry != True:
row = len(spinboxes) + 1 row = len(spinboxes) + 1
self.addWidget(QtGui.QLabel(cb_name), row, 2*i) self.addWidget(QtGui.QLabel(cb_name), row, 2*i)
self.addWidget(self.checkboxes[cb_name], row, 2*i + 1) self.addWidget(self.checkboxes[cb_name], row, 2*i + 1)
self.blinkCheckboxes = {} self.blinkCheckboxes = {}
self.blinkSpinboxes = {} self.blinkSpinboxes = {}
self.blinkTimers = {} self.blinkTimers = {}
for i, cb_name in enumerate(blinkCheckbox, start=0): for i, cb_name in enumerate(blinkCheckbox, start=0):
self.blinkCheckboxes[cb_name] = QtGui.QCheckBox() self.blinkCheckboxes[cb_name] = QtGui.QCheckBox()
self.blinkCheckboxes[cb_name].stateChanged.connect(lambda: self.blink(cb_name)) 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] = CustomSpinBox(siPrefix=True, suffix='s', value = 1)
self.blinkSpinboxes[cb_name].setMinimum(0.01) self.blinkSpinboxes[cb_name].setMinimum(0.01)
self.blinkTimers[cb_name] = QtCore.QTimer() self.blinkTimers[cb_name] = QtCore.QTimer()
self.blinkTimers[cb_name].timeout.connect(self.checkboxes[cb_name].toggle) self.blinkTimers[cb_name].timeout.connect(self.checkboxes[cb_name].toggle)
if custom_geometry != True: if custom_geometry != True:
row = 2 + len(self.spinboxes) row = 2 + len(self.spinboxes)
self.addWidget(QtGui.QLabel('blink '+cb_name), row, 0) self.addWidget(QtGui.QLabel('blink '+cb_name), row, 0)
self.addWidget(self.blinkCheckboxes[cb_name], row, 1) self.addWidget(self.blinkCheckboxes[cb_name], row, 1)
self.addWidget(self.blinkSpinboxes[cb_name], row, 2) self.addWidget(self.blinkSpinboxes[cb_name], row, 2)
def freeze(self): def freeze(self):
for sb in self.spinboxes: for sb in self.spinboxes:
self.spinboxes[sb].setEnabled(False) self.spinboxes[sb].setEnabled(False)
for cb in self.checkboxes: for cb in self.checkboxes:
self.checkboxes[cb].setEnabled(False) self.checkboxes[cb].setEnabled(False)
def unfreeze(self): def unfreeze(self):
for sb in self.spinboxes: for sb in self.spinboxes:
self.spinboxes[sb].setEnabled(True) self.spinboxes[sb].setEnabled(True)
for cb in self.checkboxes: for cb in self.checkboxes:
self.checkboxes[cb].setEnabled(True) self.checkboxes[cb].setEnabled(True)
def blink(self, cb_name): def blink(self, cb_name):
T = self.blinkSpinboxes[cb_name].value() T = self.blinkSpinboxes[cb_name].value()
if self.blinkCheckboxes[cb_name].isChecked(): if self.blinkCheckboxes[cb_name].isChecked():
print(' '.join((cb_name, 'blinking with period: ')), T) print(' '.join((cb_name, 'blinking with period: ')), T)
self._initial_state = self.checkboxes[cb_name].isChecked() self._initial_state = self.checkboxes[cb_name].isChecked()
self.blinkTimers[cb_name].start(T*1e3) self.blinkTimers[cb_name].start(T*1e3)
else: else:
print(' '.join((cb_name, 'blinking stopped'))) print(' '.join((cb_name, 'blinking stopped')))
self.blinkTimers[cb_name].stop() self.blinkTimers[cb_name].stop()
self.checkboxes[cb_name].setChecked(self._initial_state) self.checkboxes[cb_name].setChecked(self._initial_state)
class LaserScanLayout(pg.LayoutWidget): class LaserScanLayout(pg.LayoutWidget):
""" """
A class for creating a layout for scanning a laser piezo. A class for creating a layout for scanning a laser piezo.
It is important that the name parameter coincides with the name of the spinbox to scan. It is important that the name parameter coincides with the name of the spinbox to scan.
""" """
_registry = [] _registry = []
scanActionSignal = QtCore.pyqtSignal(object) scanActionSignal = QtCore.pyqtSignal(object)
def __init__(self, name, signal_to_scan_layout): def __init__(self, name, signal_to_scan_layout):
super().__init__() super().__init__()
self._registry.append(self) self._registry.append(self)
self.name = name self.name = name
self.signal_to_scan_layout = signal_to_scan_layout self.signal_to_scan_layout = signal_to_scan_layout
self.addWidget(QtGui.QLabel(self.name), 0, 0) self.addWidget(QtGui.QLabel(self.name), 0, 0)
self.spinboxes = {} self.spinboxes = {}
self.spinboxes['start'] = CustomSpinBox(siPrefix=True, suffix='V') self.spinboxes['start'] = CustomSpinBox(siPrefix=True, suffix='V')
self.spinboxes['stop'] = CustomSpinBox(siPrefix=True, suffix='V') self.spinboxes['stop'] = CustomSpinBox(siPrefix=True, suffix='V')
self.spinboxes['period'] = CustomSpinBox(siPrefix=True, suffix='s', step=1) self.spinboxes['period'] = CustomSpinBox(siPrefix=True, suffix='s', step=1)
self.scan_button = QPushButton('Start scan')
self.scanpBar = QProgressBar(self) self.spinboxes['period'].setMinimum(0)
self.scanLabelValue = QLabel(self)
self.scan_button = QPushButton('Start scan')
self.addWidget(QtGui.QLabel('start'), 1, 0), self.scanpBar = QProgressBar(self)
self.addWidget(self.spinboxes['start'], 1, 1) self.scanLabelValue = QLabel(self)
self.addWidget(QtGui.QLabel('stop'), 2, 0)
self.addWidget(self.spinboxes['stop'], 2, 1) self.addWidget(QtGui.QLabel('start'), 1, 0),
self.addWidget(QtGui.QLabel('period'), 3, 0), self.addWidget(self.spinboxes['start'], 1, 1)
self.addWidget(self.spinboxes['period'], 3, 1) self.addWidget(QtGui.QLabel('stop'), 2, 0)
self.addWidget(QtGui.QLabel('Scanning'), 4, 0) self.addWidget(self.spinboxes['stop'], 2, 1)
self.addWidget(self.scan_button, 4, 1) self.addWidget(QtGui.QLabel('period'), 3, 0),
self.addWidget(self.spinboxes['period'], 3, 1)
self.addWidget(self.scanLabelValue, 5, 0) self.addWidget(QtGui.QLabel('Scanning'), 4, 0)
self.addWidget(self.scanpBar, 5, 1) self.addWidget(self.scan_button, 4, 1)
self.addWidget(self.scanLabelValue, 5, 0)
self.addWidget(self.scanpBar, 5, 1)
self.scan_button.clicked.connect(self._scan_button_clicked) self.scan_button.clicked.connect(self._scan_button_clicked)
def name(self): def name(self):
return self.name return self.name
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def _scan_button_clicked(self): def _scan_button_clicked(self):
start = self.spinboxes['start'].value() start = self.spinboxes['start'].value()
stop = self.spinboxes['stop'].value() stop = self.spinboxes['stop'].value()
period = self.spinboxes['period'].value() period = self.spinboxes['period'].value()
dt = 5.0e-3 dt = 5.0e-3
first_value = float(self.signal_to_scan_layout.spinboxes[self.name].value()) first_value = float(self.signal_to_scan_layout.spinboxes[self.name].value())
scan_array = scanFunctions.create_scan_array(start, stop, period, first_value, dt) scan_array = scanFunctions.create_scan_array(start, stop, period, first_value, dt)
scan_array_gen = scanFunctions.yield_scan_array(scan_array) scan_array_gen = scanFunctions.yield_scan_array(scan_array)
if first_value > float(stop) or first_value < float(start): if first_value > float(stop) or first_value < float(start):
details = 'Remember remember the fifth of November.' + '\n' + 'Also remember that scan starts from the value of the corresponding spin box' details = 'Remember remember the fifth of November.' + '\n' + 'Also remember that scan starts from the value of the corresponding spin box'
show_warning('Scan can not start outside scan range and scan start should be lower than scan stop', details_text= details) show_warning('Scan can not start outside scan range and scan start should be lower than scan stop', details_text= details)
elif len(scan_array) < 5: elif len(scan_array) < 5:
show_warning('%i steps are too few, you need at least 5 steps' % (len(scan_array)) ) show_warning('%i steps are too few, you need at least 5 steps' % (len(scan_array)) )
elif stop==start: elif stop==start:
show_warning('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.') show_warning('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.')
else: else:
self.scanActionSignal.emit(scan_array_gen) self.scanActionSignal.emit(scan_array_gen)
self.scan_button.setText('Stop scan') self.scan_button.setText('Stop scan')
self.signal_to_scan_layout.spinboxes[self.name].setEnabled(False) self.signal_to_scan_layout.spinboxes[self.name].setEnabled(False)
self.spinboxes['start'].setEnabled(False) self.spinboxes['start'].setEnabled(False)
self.spinboxes['stop'].setEnabled(False) self.spinboxes['stop'].setEnabled(False)
self.spinboxes['period'].setEnabled(False) self.spinboxes['period'].setEnabled(False)
self.scan_button.setStyleSheet("background-color: green") self.scan_button.setStyleSheet("background-color: green")
self.scan_button.setText('Scanning') self.scan_button.setText('Scanning')
@QtCore.pyqtSlot(float) @QtCore.pyqtSlot(float)
def scan_step(self, val): def scan_step(self, val):
self.pBarEvent(val) self.pBarEvent(val)
@QtCore.pyqtSlot(float) @QtCore.pyqtSlot(float)
def scan_end(self, val): def scan_end(self, val):
self.signal_to_scan_layout.spinboxes[self.name].setValue(val) self.signal_to_scan_layout.spinboxes[self.name].setValue(val)
self.scan_button.setText('Start scan') self.scan_button.setText('Start scan')
self.scan_button.setStyleSheet('background-color: None') self.scan_button.setStyleSheet('background-color: None')
self.signal_to_scan_layout.spinboxes[self.name].setEnabled(True) self.signal_to_scan_layout.spinboxes[self.name].setEnabled(True)
self.spinboxes['start'].setEnabled(True) self.spinboxes['start'].setEnabled(True)
self.spinboxes['stop'].setEnabled(True) self.spinboxes['stop'].setEnabled(True)
self.spinboxes['period'].setEnabled(True) self.spinboxes['period'].setEnabled(True)
def pBarEvent(self, current_step): def pBarEvent(self, current_step):
start = self.spinboxes['start'].value() start = self.spinboxes['start'].value()
stop = self.spinboxes['stop'].value() stop = self.spinboxes['stop'].value()
self.scanpBar.setValue( 100 * float(current_step-float(start))/float(stop-start) ) self.scanpBar.setValue( 100 * float(current_step-float(start))/float(stop-start) )
self.scanLabelValue.setText("%.2f" % current_step + ' V') self.scanLabelValue.setText("%.2f" % current_step + ' V')
def freeze(self): def freeze(self):
self.scan_button.setEnabled(False) self.scan_button.setEnabled(False)
def unfreeze(self): def unfreeze(self):
self.scan_button.setEnabled(True) self.scan_button.setEnabled(True)
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
from PyQt5.QtWidgets import QMainWindow from PyQt5.QtWidgets import QMainWindow
sys.path.append("/home/martindrech/Documents/total_control_app") sys.path.append("/home/martindrech/Documents/total_control_app")
app = QtGui.QApplication([]) app = QtGui.QApplication([])
frame = QtGui.QFrame() frame = QtGui.QFrame()
area = dockarea.DockArea() area = dockarea.DockArea()
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
frame.setLayout(grid) frame.setLayout(grid)
myDock = dockarea.Dock('397', (100, 100)) myDock = dockarea.Dock('397', (100, 100))
area.addDock(myDock) area.addDock(myDock)
grid.addWidget(area, 0, 0) grid.addWidget(area, 0, 0)
l = LaserControlLayout('397', checkboxes = ['cb1', 'cb2', 'cb3']) l = LaserControlLayout('397', checkboxes = ['cb1', 'cb2', 'cb3'])
l_scan = LaserScanLayout('397 scan') l_scan = LaserScanLayout('397 scan')
myDock.addWidget(l) myDock.addWidget(l)
myDock.addWidget(l_scan) myDock.addWidget(l_scan)
frame.show() frame.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
\ No newline at end of file \ No newline at end of file
...@@ -110,9 +110,9 @@ class CameraWorker(QtCore.QObject): ...@@ -110,9 +110,9 @@ class CameraWorker(QtCore.QObject):
) )
self.cam.SimplePreAmpGainControl.setString( self.cam.SimplePreAmpGainControl.setString(
params.child('Basic acq parameters').child('Dynamic Range').value() params.child('Basic acq parameters').child('Dynamic Range').value()
) )
self.cam.SpuriousNoiseFilter.setValue( self.cam.SpuriousNoiseFilter.setValue(
params.child('Basic acq parameters').child('Spurious Noise Filter').value() params.child('Basic acq parameters').child('Spurious Noise Filter').value()=='True'
) )
@QtCore.pyqtSlot(int) @QtCore.pyqtSlot(int)
...@@ -157,11 +157,13 @@ class CameraWorker(QtCore.QObject): ...@@ -157,11 +157,13 @@ class CameraWorker(QtCore.QObject):
def simple_scan_measurement_end(self): def simple_scan_measurement_end(self):
self._stop_acquisition_loop() self._stop_acquisition_loop()
self.cam.TriggerMode.setString('Internal') self.cam.TriggerMode.setString('Internal')
self.cam.helper.imageAquiredSignal.disconnect(self.new_image_acquired_with_trigger) self.cam.helper.imageAquiredSignal.disconnect(self.new_image_acquired_with_trigger)
self.cam.helper.imageAquiredSignal.connect(self.new_image_acquired) self.cam.helper.imageAquiredSignal.connect(self.new_image_acquired)
self.measurementEndingSignal.emit() self.measurementEndingSignal.emit()
print('exiting scan ending in worker')
def simple_scan_measurement_step(self): def simple_scan_measurement_step(self):
try: try:
......
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