Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
1908d2d6
Commit
1908d2d6
authored
May 17, 2019
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some changes to make it work on the real camera
parent
1dc78886
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
244 additions
and
233 deletions
+244
-233
MCDAQcontrolsignals.py
MCDAQcontrolsignals.py
+6
-2
cameraGui.py
cameraGui.py
+2
-0
controlGui.py
controlGui.py
+3
-4
andorzyla.py
drivers/andorzyla.py
+2
-1
main.py
main.py
+18
-18
webcams.py
resources/webcams.py
+2
-2
cameraParameterTree.py
subclasses/cameraParameterTree.py
+1
-1
controllayouts.py
subclasses/controllayouts.py
+206
-203
zylaCameraWorker.py
zylaCameraWorker.py
+4
-2
No files found.
MCDAQcontrolsignals.py
View file @
1908d2d6
...
...
@@ -2,7 +2,11 @@
"""
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
subclasses.controllayouts
import
LaserControlLayout
from
subclasses.controllayouts
import
LaserScanLayout
...
...
@@ -104,7 +108,7 @@ class anal_control_signal(QtCore.QObject):
class
digital_control_signal
(
QtCore
.
QObject
):
_registry
=
[]
def
__init__
(
self
,
name
,
channel
,
inverse
=
Fals
e
):
def
__init__
(
self
,
name
,
channel
,
inverse
=
Tru
e
):
super
()
.
__init__
()
self
.
_registry
.
append
(
self
)
...
...
cameraGui.py
View file @
1908d2d6
...
...
@@ -89,6 +89,7 @@ class CameraGuiMainWindow(QMainWindow):
# image layout
self
.
img
=
pg
.
ImageItem
(
border
=
"w"
)
self
.
img
.
rotate
(
90
)
self
.
imv
=
pg
.
ImageView
(
imageItem
=
self
.
img
,
view
=
self
.
imageView
)
self
.
imv
.
ui
.
roiBtn
.
setText
(
'Useless'
)
self
.
dCameraView
.
addWidget
(
self
.
imv
)
...
...
@@ -271,6 +272,7 @@ class CameraGuiMainWindow(QMainWindow):
#@QtCore.pyqtSlot()
def
measurement_ending
(
self
):
print
(
'entering gui measure ending'
)
self
.
cameraButton
.
setEnabled
(
True
)
self
.
measurementFrame
.
startMeasureButton
.
setEnabled
(
True
)
self
.
measurementFrame
.
saveMeasureButton
.
setEnabled
(
True
)
...
...
controlGui.py
View file @
1908d2d6
...
...
@@ -56,12 +56,12 @@ class ControlGui(QtGui.QFrame):
self
.
laser397_control_layout
=
LaserControlLayout
(
'397'
,
checkboxes
=
[
'shutter397'
],
spinboxes
=
[
'piezoA397'
,
'piezoB397'
])
self
.
laser397_scan_layout
=
LaserScanLayout
(
name
=
'piezo
A
397'
,
signal_to_scan_layout
=
self
.
laser397_control_layout
)
self
.
laser397_scan_layout
=
LaserScanLayout
(
name
=
'piezo
B
397'
,
signal_to_scan_layout
=
self
.
laser397_control_layout
)
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'
],
blinkCheckbox
=
[
'shutter866'
])
self
.
laser866_scan_layout
=
LaserScanLayout
(
name
=
'piezo
A
866'
,
signal_to_scan_layout
=
self
.
laser866_control_layout
)
self
.
laser866_control_layout
=
LaserControlLayout
(
'866'
,
checkboxes
=
[
'shutter866'
,
'shut
t
er866WM'
],
spinboxes
=
[
'piezoA866'
,
'piezoB866'
],
blinkCheckbox
=
[
'shutter866'
])
self
.
laser866_scan_layout
=
LaserScanLayout
(
name
=
'piezo
B
866'
,
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
)
...
...
@@ -87,7 +87,6 @@ class ControlGui(QtGui.QFrame):
self
.
electrodes_control_layout
.
addWidget
(
self
.
electrodes_control_layout
.
spinboxes
[
'compExYb'
],
1
,
5
)
self
.
toolbar
=
myToolbarMenu
(
self
)
self
.
toolbar
.
load
()
self
.
autosave_timer
=
QtCore
.
QTimer
()
self
.
autosave_timer
.
timeout
.
connect
(
lambda
:
self
.
toolbar
.
save
(
'config.ini'
))
self
.
autosave_timer
.
start
(
10000
)
...
...
drivers/andorzyla.py
View file @
1908d2d6
...
...
@@ -749,10 +749,11 @@ class AndorBase(SDK3Camera):
def
live_acquisition_loop
(
self
):
t
=
threading
.
currentThread
()
timeout
=
self
.
ExposureTime
.
getValue
()
*
5000
while
getattr
(
t
,
"do_run"
,
True
):
a_s
,
px_encoding
,
xs
,
ys
,
bufs
=
self
.
_live_acq_auxs
try
:
pData
,
lData
=
SDK3
.
WaitBuffer
(
self
.
handle
,
10000
)
pData
,
lData
=
SDK3
.
WaitBuffer
(
self
.
handle
,
int
(
timeout
)
)
except
:
return
img
=
create_aligned_array
(
xs
*
ys
,
'uint16'
)
...
...
main.py
View file @
1908d2d6
from
PyQt5
import
QtGui
,
QtCore
#
from drivers.andorzyla import AndorZyla
from
drivers.dummyAndor
import
AndorZyla
from
drivers.andorzyla
import
AndorZyla
#
from drivers.dummyAndor import AndorZyla
from
cameraGui
import
CameraGuiMainWindow
from
zylaCameraWorker
import
CameraWorker
#from measurement import MeasurementWorker, MeasurementGui
from
MCDAQcontrolsignals
import
anal_control_signal
from
MCDAQcontrolsignals
import
digital_control_signal
from
controlGui
import
ControlGui
...
...
@@ -20,24 +19,24 @@ if __name__ == "__main__":
camera
=
AndorZyla
(
0
)
piezoA397
=
anal_control_signal
(
'piezoA397'
,
channel
=
0
,
ao_type
=
'cavity_piezo'
,
out_minimum
=
0
,
out_maximum
=
4
)
piezoB397
=
anal_control_signal
(
'piezoB397'
,
channel
=
1
,
ao_type
=
'cavity_piezo'
)
piezoA866
=
anal_control_signal
(
'piezoA866'
,
channel
=
2
,
ao_type
=
'cavity_piezo'
,
out_minimum
=
0
,
out_maximum
=
4
)
piezoB866
=
anal_control_signal
(
'piezoB866'
,
channel
=
3
,
ao_type
=
'cavity_piezo'
)
piezo423
=
anal_control_signal
(
'piezo423'
,
channel
=
4
,
ao_type
=
'laser_piezo'
)
piezoA397
=
anal_control_signal
(
'piezoA397'
,
channel
=
13
,
ao_type
=
'cavity_piezo'
,
out_minimum
=
0
,
out_maximum
=
4
)
piezoB397
=
anal_control_signal
(
'piezoB397'
,
channel
=
7
,
ao_type
=
'cavity_piezo'
)
piezoA866
=
anal_control_signal
(
'piezoA866'
,
channel
=
14
,
ao_type
=
'cavity_piezo'
,
out_minimum
=
0
,
out_maximum
=
4
)
piezoB866
=
anal_control_signal
(
'piezoB866'
,
channel
=
9
,
ao_type
=
'cavity_piezo'
,
out_minimum
=
-
2
,
out_maximum
=
10
)
piezo423
=
anal_control_signal
(
'piezo423'
,
channel
=
3
,
ao_type
=
'laser_piezo'
)
trapDCA
=
anal_control_signal
(
'dcA'
,
channel
=
5
,
ao_type
=
'electrode'
)
trapDCB
=
anal_control_signal
(
'dcB'
,
channel
=
6
,
ao_type
=
'electrode'
)
trapCOMPC
=
anal_control_signal
(
'compC'
,
channel
=
7
,
ao_type
=
'electrode'
)
trapCOMPD
=
anal_control_signal
(
'compD'
,
channel
=
8
,
ao_type
=
'electrode'
)
trapOven
=
anal_control_signal
(
'compOven'
,
channel
=
9
,
ao_type
=
'electrode'
)
trapExYb
=
anal_control_signal
(
'compExYb'
,
channel
=
10
,
ao_type
=
'electrode'
)
trapDCA
=
anal_control_signal
(
'dcA'
,
channel
=
2
,
ao_type
=
'electrode'
)
trapDCB
=
anal_control_signal
(
'dcB'
,
channel
=
1
,
ao_type
=
'electrode'
)
trapCOMPC
=
anal_control_signal
(
'compC'
,
channel
=
4
,
ao_type
=
'electrode'
)
trapCOMPD
=
anal_control_signal
(
'compD'
,
channel
=
5
,
ao_type
=
'electrode'
)
trapOven
=
anal_control_signal
(
'compOven'
,
channel
=
0
,
ao_type
=
'electrode'
)
trapExYb
=
anal_control_signal
(
'compExYb'
,
channel
=
6
,
ao_type
=
'electrode'
)
shutter866
=
digital_control_signal
(
'shutter866'
,
channel
=
0
)
shutter397
=
digital_control_signal
(
'shutter397'
,
channel
=
1
)
shutter423
=
digital_control_signal
(
'shutter423'
,
channel
=
2
)
shutter866WM
=
digital_control_signal
(
'shutter866WM'
,
channel
=
3
)
shutter866
=
digital_control_signal
(
'shutter866'
,
channel
=
2
,
inverse
=
True
)
shutter397
=
digital_control_signal
(
'shutter397'
,
channel
=
0
,
inverse
=
True
)
shutter423
=
digital_control_signal
(
'shutter423'
,
channel
=
1
,
inverse
=
True
)
shutter866WM
=
digital_control_signal
(
'shutter866WM'
,
channel
=
3
,
inverse
=
True
)
controlGui
=
ControlGui
()
mcDAQthread
=
QtCore
.
QThread
()
...
...
@@ -65,5 +64,6 @@ if __name__ == "__main__":
cameraThread
.
start
()
mcDAQthread
.
start
()
controlGui
.
toolbar
.
load
()
sys
.
exit
(
app
.
exec_
())
resources/webcams.py
View file @
1908d2d6
...
...
@@ -7,8 +7,8 @@ This is a temporary script file.
import
cv2
cap
=
cv2
.
VideoCapture
(
0
)
cap1
=
cv2
.
VideoCapture
(
1
)
cap
=
cv2
.
VideoCapture
(
2
)
cap1
=
cv2
.
VideoCapture
(
3
)
while
(
True
):
# Capture frame-by-frame
...
...
subclasses/cameraParameterTree.py
View file @
1908d2d6
...
...
@@ -26,7 +26,7 @@ class BasicAcquisitonParameters(pTypes.GroupParameter):
[
'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'
:
'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'
:
'Temperature Status'
,
'type'
:
'str'
,
'value'
:
'?'
,
'readonly'
:
True
})
...
...
subclasses/controllayouts.py
View file @
1908d2d6
...
...
@@ -9,213 +9,216 @@ from resources.messages import show_warning
class
CustomSpinBox
(
pg
.
SpinBox
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
if
self
.
opts
[
'suffix'
]
==
'V'
:
# fixing a context menu with some scales
self
.
setContextMenuPolicy
(
QtCore
.
Qt
.
CustomContextMenu
)
self
.
customContextMenuRequested
.
connect
(
self
.
_on_context_menu
)
self
.
popMenu
=
QtGui
.
QMenu
(
self
)
self
.
act_2_step
=
QtGui
.
QAction
(
'2 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_100_step
=
QtGui
.
QAction
(
'100 mV step'
,
self
)
self
.
popMenu
.
addAction
(
self
.
act_2_step
)
self
.
popMenu
.
addAction
(
self
.
act_5_step
)
self
.
popMenu
.
addAction
(
self
.
act_10_step
)
self
.
popMenu
.
addAction
(
self
.
act_100_step
)
self
.
act_2_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.002
))
self
.
act_5_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.005
))
self
.
act_10_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.01
))
self
.
act_100_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.1
))
def
_on_context_menu
(
self
,
point
):
# show context menu
self
.
popMenu
.
exec_
(
self
.
mapToGlobal
(
point
))
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
if
self
.
opts
[
'suffix'
]
==
'V'
:
# fixing a context menu with some scales
self
.
setContextMenuPolicy
(
QtCore
.
Qt
.
CustomContextMenu
)
self
.
customContextMenuRequested
.
connect
(
self
.
_on_context_menu
)
self
.
popMenu
=
QtGui
.
QMenu
(
self
)
self
.
act_2_step
=
QtGui
.
QAction
(
'2 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_100_step
=
QtGui
.
QAction
(
'100 mV step'
,
self
)
self
.
popMenu
.
addAction
(
self
.
act_2_step
)
self
.
popMenu
.
addAction
(
self
.
act_5_step
)
self
.
popMenu
.
addAction
(
self
.
act_10_step
)
self
.
popMenu
.
addAction
(
self
.
act_100_step
)
self
.
act_2_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.002
))
self
.
act_5_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.005
))
self
.
act_10_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.01
))
self
.
act_100_step
.
triggered
.
connect
(
lambda
:
self
.
setSingleStep
(
0.1
))
def
_on_context_menu
(
self
,
point
):
# show context menu
self
.
popMenu
.
exec_
(
self
.
mapToGlobal
(
point
))
class
LaserControlLayout
(
pg
.
LayoutWidget
):
"""
A class for creating a layout with spinboxes and checkboxes to control a laser.
"""
_registry
=
[]
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
if
custom_geometry
!=
True
:
self
.
layout
.
addWidget
(
QtGui
.
QLabel
(
self
.
name
),
0
,
0
)
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
:
self
.
addWidget
(
QtGui
.
QLabel
(
sb_name
),
i
,
0
)
self
.
addWidget
(
self
.
spinboxes
[
sb_name
],
i
,
1
)
for
i
,
cb_name
in
enumerate
(
checkboxes
,
start
=
0
):
self
.
checkboxes
[
cb_name
]
=
QtGui
.
QCheckBox
()
if
custom_geometry
!=
True
:
row
=
len
(
spinboxes
)
+
1
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
freeze
(
self
):
for
sb
in
self
.
spinboxes
:
self
.
spinboxes
[
sb
]
.
setEnabled
(
False
)
for
cb
in
self
.
checkboxes
:
self
.
checkboxes
[
cb
]
.
setEnabled
(
False
)
def
unfreeze
(
self
):
for
sb
in
self
.
spinboxes
:
self
.
spinboxes
[
sb
]
.
setEnabled
(
True
)
for
cb
in
self
.
checkboxes
:
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
)
"""
A class for creating a layout with spinboxes and checkboxes to control a laser.
"""
_registry
=
[]
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
if
custom_geometry
!=
True
:
self
.
layout
.
addWidget
(
QtGui
.
QLabel
(
self
.
name
),
0
,
0
)
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
:
self
.
addWidget
(
QtGui
.
QLabel
(
sb_name
),
i
,
0
)
self
.
addWidget
(
self
.
spinboxes
[
sb_name
],
i
,
1
)
for
i
,
cb_name
in
enumerate
(
checkboxes
,
start
=
0
):
self
.
checkboxes
[
cb_name
]
=
QtGui
.
QCheckBox
()
if
custom_geometry
!=
True
:
row
=
len
(
spinboxes
)
+
1
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
freeze
(
self
):
for
sb
in
self
.
spinboxes
:
self
.
spinboxes
[
sb
]
.
setEnabled
(
False
)
for
cb
in
self
.
checkboxes
:
self
.
checkboxes
[
cb
]
.
setEnabled
(
False
)
def
unfreeze
(
self
):
for
sb
in
self
.
spinboxes
:
self
.
spinboxes
[
sb
]
.
setEnabled
(
True
)
for
cb
in
self
.
checkboxes
:
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.
It is important that the name parameter coincides with the name of the spinbox to scan.
"""
_registry
=
[]
scanActionSignal
=
QtCore
.
pyqtSignal
(
object
)
def
__init__
(
self
,
name
,
signal_to_scan_layout
):
super
()
.
__init__
()
self
.
_registry
.
append
(
self
)
self
.
name
=
name
self
.
signal_to_scan_layout
=
signal_to_scan_layout
self
.
addWidget
(
QtGui
.
QLabel
(
self
.
name
),
0
,
0
)
self
.
spinboxes
=
{}
self
.
spinboxes
[
'start'
]
=
CustomSpinBox
(
siPrefix
=
True
,
suffix
=
'V'
)
self
.
spinboxes
[
'stop'
]
=
CustomSpinBox
(
siPrefix
=
True
,
suffix
=
'V'
)
self
.
spinboxes
[
'period'
]
=
CustomSpinBox
(
siPrefix
=
True
,
suffix
=
's'
,
step
=
1
)
self
.
scan_button
=
QPushButton
(
'Start scan'
)
self
.
scanpBar
=
QProgressBar
(
self
)
self
.
scanLabelValue
=
QLabel
(
self
)
self
.
addWidget
(
QtGui
.
QLabel
(
'start'
),
1
,
0
),
self
.
addWidget
(
self
.
spinboxes
[
'start'
],
1
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'stop'
),
2
,
0
)
self
.
addWidget
(
self
.
spinboxes
[
'stop'
],
2
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'period'
),
3
,
0
),
self
.
addWidget
(
self
.
spinboxes
[
'period'
],
3
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'Scanning'
),
4
,
0
)
self
.
addWidget
(
self
.
scan_button
,
4
,
1
)
self
.
addWidget
(
self
.
scanLabelValue
,
5
,
0
)
self
.
addWidget
(
self
.
scanpBar
,
5
,
1
)
"""
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.
"""
_registry
=
[]
scanActionSignal
=
QtCore
.
pyqtSignal
(
object
)
def
__init__
(
self
,
name
,
signal_to_scan_layout
):
super
()
.
__init__
()
self
.
_registry
.
append
(
self
)
self
.
name
=
name
self
.
signal_to_scan_layout
=
signal_to_scan_layout
self
.
addWidget
(
QtGui
.
QLabel
(
self
.
name
),
0
,
0
)
self
.
spinboxes
=
{}
self
.
spinboxes
[
'start'
]
=
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'
]
.
setMinimum
(
0
)
self
.
scan_button
=
QPushButton
(
'Start scan'
)
self
.
scanpBar
=
QProgressBar
(
self
)
self
.
scanLabelValue
=
QLabel
(
self
)
self
.
addWidget
(
QtGui
.
QLabel
(
'start'
),
1
,
0
),
self
.
addWidget
(
self
.
spinboxes
[
'start'
],
1
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'stop'
),
2
,
0
)
self
.
addWidget
(
self
.
spinboxes
[
'stop'
],
2
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'period'
),
3
,
0
),
self
.
addWidget
(
self
.
spinboxes
[
'period'
],
3
,
1
)
self
.
addWidget
(
QtGui
.
QLabel
(
'Scanning'
),
4
,
0
)
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
)
def
name
(
self
):
return
self
.
name
@
QtCore
.
pyqtSlot
()
def
_scan_button_clicked
(
self
):
start
=
self
.
spinboxes
[
'start'
]
.
value
()
stop
=
self
.
spinboxes
[
'stop'
]
.
value
()
period
=
self
.
spinboxes
[
'period'
]
.
value
()
dt
=
5.0e-3
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_gen
=
scanFunctions
.
yield_scan_array
(
scan_array
)
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'
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
:
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
len
(
scan_array
))
)
elif
stop
==
start
:
show_warning
(
'Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.'
)
else
:
self
.
scanActionSignal
.
emit
(
scan_array_gen
)
self
.
scan_button
.
setText
(
'Stop scan'
)
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'start'
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'stop'
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'period'
]
.
setEnabled
(
False
)
self
.
scan_button
.
setStyleSheet
(
"background-color: green"
)
self
.
scan_button
.
setText
(
'Scanning'
)
@
QtCore
.
pyqtSlot
(
float
)
def
scan_step
(
self
,
val
):
self
.
pBarEvent
(
val
)
@
QtCore
.
pyqtSlot
(
float
)
def
scan_end
(
self
,
val
):
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setValue
(
val
)
self
.
scan_button
.
setText
(
'Start scan'
)
self
.
scan_button
.
setStyleSheet
(
'background-color: None'
)
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'start'
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'stop'
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'period'
]
.
setEnabled
(
True
)
def
pBarEvent
(
self
,
current_step
):
start
=
self
.
spinboxes
[
'start'
]
.
value
()
stop
=
self
.
spinboxes
[
'stop'
]
.
value
()
self
.
scanpBar
.
setValue
(
100
*
float
(
current_step
-
float
(
start
))
/
float
(
stop
-
start
)
)
self
.
scanLabelValue
.
setText
(
"
%.2
f"
%
current_step
+
' V'
)
def
freeze
(
self
):
self
.
scan_button
.
setEnabled
(
False
)
def
unfreeze
(
self
):
self
.
scan_button
.
setEnabled
(
True
)
self
.
scan_button
.
clicked
.
connect
(
self
.
_scan_button_clicked
)
def
name
(
self
):
return
self
.
name
@
QtCore
.
pyqtSlot
()
def
_scan_button_clicked
(
self
):
start
=
self
.
spinboxes
[
'start'
]
.
value
()
stop
=
self
.
spinboxes
[
'stop'
]
.
value
()
period
=
self
.
spinboxes
[
'period'
]
.
value
()
dt
=
5.0e-3
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_gen
=
scanFunctions
.
yield_scan_array
(
scan_array
)
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'
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
:
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
len
(
scan_array
))
)
elif
stop
==
start
:
show_warning
(
'Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.'
)
else
:
self
.
scanActionSignal
.
emit
(
scan_array_gen
)
self
.
scan_button
.
setText
(
'Stop scan'
)
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'start'
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'stop'
]
.
setEnabled
(
False
)
self
.
spinboxes
[
'period'
]
.
setEnabled
(
False
)
self
.
scan_button
.
setStyleSheet
(
"background-color: green"
)
self
.
scan_button
.
setText
(
'Scanning'
)
@
QtCore
.
pyqtSlot
(
float
)
def
scan_step
(
self
,
val
):
self
.
pBarEvent
(
val
)
@
QtCore
.
pyqtSlot
(
float
)
def
scan_end
(
self
,
val
):
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setValue
(
val
)
self
.
scan_button
.
setText
(
'Start scan'
)
self
.
scan_button
.
setStyleSheet
(
'background-color: None'
)
self
.
signal_to_scan_layout
.
spinboxes
[
self
.
name
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'start'
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'stop'
]
.
setEnabled
(
True
)
self
.
spinboxes
[
'period'
]
.
setEnabled
(
True
)
def
pBarEvent
(
self
,
current_step
):
start
=
self
.
spinboxes
[
'start'
]
.
value
()
stop
=
self
.
spinboxes
[
'stop'
]
.
value
()
self
.
scanpBar
.
setValue
(
100
*
float
(
current_step
-
float
(
start
))
/
float
(
stop
-
start
)
)
self
.
scanLabelValue
.
setText
(
"
%.2
f"
%
current_step
+
' V'
)
def
freeze
(
self
):
self
.
scan_button
.
setEnabled
(
False
)
def
unfreeze
(
self
):
self
.
scan_button
.
setEnabled
(
True
)
if
__name__
==
'__main__'
:
import
sys
from
PyQt5.QtWidgets
import
QMainWindow
sys
.
path
.
append
(
"/home/martindrech/Documents/total_control_app"
)
app
=
QtGui
.
QApplication
([])
frame
=
QtGui
.
QFrame
()
area
=
dockarea
.
DockArea
()
grid
=
QtGui
.
QGridLayout
()
frame
.
setLayout
(
grid
)
myDock
=
dockarea
.
Dock
(
'397'
,
(
100
,
100
))
area
.
addDock
(
myDock
)
grid
.
addWidget
(
area
,
0
,
0
)
l
=
LaserControlLayout
(
'397'
,
checkboxes
=
[
'cb1'
,
'cb2'
,
'cb3'
])
l_scan
=
LaserScanLayout
(
'397 scan'
)
myDock
.
addWidget
(
l
)
myDock
.
addWidget
(
l_scan
)
frame
.
show
()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
import
sys
from
PyQt5.QtWidgets
import
QMainWindow
sys
.
path
.
append
(
"/home/martindrech/Documents/total_control_app"
)
app
=
QtGui
.
QApplication
([])
frame
=
QtGui
.
QFrame
()
area
=
dockarea
.
DockArea
()
grid
=
QtGui
.
QGridLayout
()
frame
.
setLayout
(
grid
)
myDock
=
dockarea
.
Dock
(
'397'
,
(
100
,
100
))
area
.
addDock
(
myDock
)
grid
.
addWidget
(
area
,
0
,
0
)
l
=
LaserControlLayout
(
'397'
,
checkboxes
=
[
'cb1'
,
'cb2'
,
'cb3'
])
l_scan
=
LaserScanLayout
(
'397 scan'
)
myDock
.
addWidget
(
l
)
myDock
.
addWidget
(
l_scan
)
frame
.
show
()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
zylaCameraWorker.py
View file @
1908d2d6
...
...
@@ -110,9 +110,9 @@ class CameraWorker(QtCore.QObject):
)
self
.
cam
.
SimplePreAmpGainControl
.
setString
(
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Dynamic Range'
)
.
value
()
)
)
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
)
...
...
@@ -157,11 +157,13 @@ class CameraWorker(QtCore.QObject):
def
simple_scan_measurement_end
(
self
):
self
.
_stop_acquisition_loop
()
self
.
cam
.
TriggerMode
.
setString
(
'Internal'
)
self
.
cam
.
helper
.
imageAquiredSignal
.
disconnect
(
self
.
new_image_acquired_with_trigger
)
self
.
cam
.
helper
.
imageAquiredSignal
.
connect
(
self
.
new_image_acquired
)
self
.
measurementEndingSignal
.
emit
()
print
(
'exiting scan ending in worker'
)
def
simple_scan_measurement_step
(
self
):
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment