pymodaq 5.0.4__py3-none-any.whl → 5.1.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pymodaq might be problematic. Click here for more details.
- pymodaq/control_modules/daq_move.py +78 -65
- pymodaq/control_modules/daq_move_ui.py +16 -15
- pymodaq/control_modules/daq_viewer.py +95 -87
- pymodaq/control_modules/daq_viewer_ui.py +22 -23
- pymodaq/control_modules/mocks.py +2 -2
- pymodaq/control_modules/move_utility_classes.py +28 -19
- pymodaq/control_modules/thread_commands.py +138 -0
- pymodaq/control_modules/utils.py +88 -20
- pymodaq/control_modules/viewer_utility_classes.py +8 -17
- pymodaq/dashboard.py +90 -27
- pymodaq/examples/qt_less_standalone_module.py +48 -11
- pymodaq/extensions/__init__.py +7 -3
- pymodaq/extensions/adaptive/__init__.py +2 -0
- pymodaq/extensions/adaptive/adaptive_optimization.py +159 -0
- pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +86 -0
- pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
- pymodaq/extensions/adaptive/loss_function/loss_factory.py +106 -0
- pymodaq/extensions/adaptive/utils.py +97 -0
- pymodaq/extensions/bayesian/__init__.py +1 -1
- pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +71 -0
- pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +86 -0
- pymodaq/extensions/bayesian/bayesian_optimization.py +121 -0
- pymodaq/extensions/bayesian/utils.py +27 -286
- pymodaq/extensions/daq_logger/daq_logger.py +7 -12
- pymodaq/extensions/daq_logger/h5logging.py +1 -1
- pymodaq/extensions/daq_scan.py +18 -47
- pymodaq/extensions/h5browser.py +3 -34
- pymodaq/extensions/optimizers_base/__init__.py +0 -0
- pymodaq/extensions/{bayesian/bayesian_optimisation.py → optimizers_base/optimizer.py} +441 -334
- pymodaq/extensions/optimizers_base/thread_commands.py +20 -0
- pymodaq/extensions/optimizers_base/utils.py +378 -0
- pymodaq/extensions/pid/pid_controller.py +6 -10
- pymodaq/extensions/utils.py +12 -0
- pymodaq/utils/data.py +1 -0
- pymodaq/utils/gui_utils/loader_utils.py +2 -0
- pymodaq/utils/h5modules/module_saving.py +134 -22
- pymodaq/utils/leco/daq_move_LECODirector.py +73 -73
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +36 -84
- pymodaq/utils/leco/director_utils.py +25 -10
- pymodaq/utils/leco/leco_director.py +65 -26
- pymodaq/utils/leco/pymodaq_listener.py +118 -68
- pymodaq/utils/leco/utils.py +24 -24
- pymodaq/utils/managers/modules_manager.py +37 -8
- pymodaq/utils/scanner/scanners/_1d_scanners.py +0 -38
- pymodaq/utils/scanner/scanners/_2d_scanners.py +0 -58
- {pymodaq-5.0.4.dist-info → pymodaq-5.1.0a0.dist-info}/METADATA +4 -3
- {pymodaq-5.0.4.dist-info → pymodaq-5.1.0a0.dist-info}/RECORD +52 -38
- {pymodaq-5.0.4.dist-info → pymodaq-5.1.0a0.dist-info}/entry_points.txt +0 -2
- pymodaq/utils/leco/desktop.ini +0 -2
- {pymodaq-5.0.4.dist-info → pymodaq-5.1.0a0.dist-info}/WHEEL +0 -0
- {pymodaq-5.0.4.dist-info → pymodaq-5.1.0a0.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,9 +7,6 @@ Created on Wed Jan 10 16:54:14 2018
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
from importlib import import_module
|
|
9
9
|
|
|
10
|
-
from collections import OrderedDict
|
|
11
|
-
import copy
|
|
12
|
-
|
|
13
10
|
import os
|
|
14
11
|
from pathlib import Path
|
|
15
12
|
from random import randint
|
|
@@ -49,13 +46,16 @@ from pymodaq_gui.utils.utils import mkQApp
|
|
|
49
46
|
|
|
50
47
|
from pymodaq.utils.gui_utils import get_splash_sc
|
|
51
48
|
from pymodaq.control_modules.daq_viewer_ui import DAQ_Viewer_UI
|
|
52
|
-
from pymodaq.control_modules.utils import DET_TYPES, get_viewer_plugins, DAQTypesEnum,
|
|
49
|
+
from pymodaq.control_modules.utils import (DET_TYPES, get_viewer_plugins, DAQTypesEnum,
|
|
50
|
+
DetectorError)
|
|
51
|
+
from pymodaq.control_modules.thread_commands import (ThreadStatus, ThreadStatusViewer, ControlToHardwareViewer,
|
|
52
|
+
UiToMainViewer)
|
|
53
53
|
from pymodaq_gui.plotting.data_viewers.viewer import ViewerBase
|
|
54
54
|
from pymodaq_gui.plotting.data_viewers import ViewersEnum
|
|
55
55
|
from pymodaq_utils.enums import enum_checker
|
|
56
56
|
from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base
|
|
57
57
|
|
|
58
|
-
from pymodaq.utils.leco.pymodaq_listener import ViewerActorListener, LECOClientCommands
|
|
58
|
+
from pymodaq.utils.leco.pymodaq_listener import ViewerActorListener, LECOClientCommands, LECOViewerCommands
|
|
59
59
|
|
|
60
60
|
logger = set_logger(get_module_name(__file__))
|
|
61
61
|
config = Config()
|
|
@@ -121,6 +121,9 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
121
121
|
self._viewer_types: List[ViewersEnum] = []
|
|
122
122
|
self._viewers: List[ViewerBase] = []
|
|
123
123
|
|
|
124
|
+
self.override_grab_from_extension = False # boolean allowing an extension to tell to init a grab or not
|
|
125
|
+
# (see DataMixer for reasons and use case in ModulesManager and dashboard method add_det_from_extension)
|
|
126
|
+
|
|
124
127
|
if isinstance(parent, DockArea):
|
|
125
128
|
self.dockarea = parent
|
|
126
129
|
else:
|
|
@@ -145,9 +148,9 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
145
148
|
|
|
146
149
|
self._title = title
|
|
147
150
|
|
|
148
|
-
self.
|
|
151
|
+
self._module_and_data_saver: Union[None,
|
|
149
152
|
module_saving.DetectorSaver,
|
|
150
|
-
module_saving.
|
|
153
|
+
module_saving.DetectorTimeSaver,
|
|
151
154
|
module_saving.DetectorExtendedSaver] = None
|
|
152
155
|
self._h5saver_continuous: Optional[H5Saver] = None
|
|
153
156
|
self._ind_continuous_grab = 0
|
|
@@ -200,6 +203,8 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
200
203
|
def process_ui_cmds(self, cmd: utils.ThreadCommand):
|
|
201
204
|
"""Process commands sent by actions done in the ui
|
|
202
205
|
|
|
206
|
+
See pymodaq.control_modules.thread_commands.UiToMainViewer
|
|
207
|
+
|
|
203
208
|
Parameters
|
|
204
209
|
----------
|
|
205
210
|
cmd: ThreadCommand
|
|
@@ -220,38 +225,38 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
220
225
|
* show_config
|
|
221
226
|
"""
|
|
222
227
|
|
|
223
|
-
if cmd.command ==
|
|
228
|
+
if cmd.command == UiToMainViewer.INIT:
|
|
224
229
|
self.init_hardware(cmd.attribute[0])
|
|
225
|
-
elif cmd.command ==
|
|
230
|
+
elif cmd.command == UiToMainViewer.QUIT:
|
|
226
231
|
self.quit_fun()
|
|
227
|
-
elif cmd.command ==
|
|
232
|
+
elif cmd.command == UiToMainViewer.STOP:
|
|
228
233
|
self.stop()
|
|
229
|
-
elif cmd.command ==
|
|
234
|
+
elif cmd.command == UiToMainViewer.SHOW_LOG:
|
|
230
235
|
self.show_log()
|
|
231
|
-
elif cmd.command ==
|
|
236
|
+
elif cmd.command == UiToMainViewer.GRAB:
|
|
232
237
|
self.grab_data(cmd.attribute, snap_state=False)
|
|
233
|
-
elif cmd.command ==
|
|
238
|
+
elif cmd.command == UiToMainViewer.SNAP:
|
|
234
239
|
self.grab_data(False, snap_state=True)
|
|
235
|
-
elif cmd.command ==
|
|
240
|
+
elif cmd.command == UiToMainViewer.SAVE_NEW:
|
|
236
241
|
self.save_new()
|
|
237
|
-
elif cmd.command ==
|
|
242
|
+
elif cmd.command == UiToMainViewer.SAVE_CURRENT:
|
|
238
243
|
self.save_current()
|
|
239
|
-
elif cmd.command ==
|
|
244
|
+
elif cmd.command == UiToMainViewer.OPEN:
|
|
240
245
|
self.load_data()
|
|
241
|
-
elif cmd.command ==
|
|
246
|
+
elif cmd.command == UiToMainViewer.DETECTOR_CHANGED:
|
|
242
247
|
if cmd.attribute != '':
|
|
243
248
|
self.detector_changed_from_ui(cmd.attribute)
|
|
244
|
-
elif cmd.command ==
|
|
249
|
+
elif cmd.command == UiToMainViewer.DAQ_TYPE_CHANGED:
|
|
245
250
|
if cmd.attribute != '':
|
|
246
251
|
self.daq_type_changed_from_ui(cmd.attribute)
|
|
247
|
-
elif cmd.command ==
|
|
252
|
+
elif cmd.command == UiToMainViewer.TAKE_BKG:
|
|
248
253
|
self.take_bkg()
|
|
249
|
-
elif cmd.command ==
|
|
254
|
+
elif cmd.command == UiToMainViewer.DO_BKG:
|
|
250
255
|
self.do_bkg = cmd.attribute
|
|
251
|
-
elif cmd.command ==
|
|
256
|
+
elif cmd.command == UiToMainViewer.VIEWERS_CHANGED:
|
|
252
257
|
self._viewer_types: List[ViewersEnum] = cmd.attribute['viewer_types']
|
|
253
258
|
self.viewers = cmd.attribute['viewers']
|
|
254
|
-
elif cmd.command ==
|
|
259
|
+
elif cmd.command == UiToMainViewer.SHOW_CONFIG:
|
|
255
260
|
self.config = self.show_config(self.config)
|
|
256
261
|
self.ui.config = self.config
|
|
257
262
|
|
|
@@ -401,18 +406,17 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
401
406
|
pass
|
|
402
407
|
for ind_viewer, viewer in enumerate(viewers):
|
|
403
408
|
viewer.data_to_export_signal.connect(self._get_data_from_viewer)
|
|
404
|
-
|
|
405
|
-
viewer.ROI_select_signal.connect(
|
|
406
|
-
lambda roi_info: self.command_hardware.emit(ThreadCommand('ROISelect', roi_info)))
|
|
407
|
-
#use that now
|
|
409
|
+
|
|
408
410
|
viewer.roi_select_signal.connect(
|
|
409
411
|
lambda roi_info: self.command_hardware.emit(
|
|
410
|
-
ThreadCommand(
|
|
411
|
-
dict(roi_info=roi_info,
|
|
412
|
+
ThreadCommand(ControlToHardwareViewer.ROI_SELECT,
|
|
413
|
+
dict(roi_info=roi_info,
|
|
414
|
+
ind_viewer=ind_viewer))))
|
|
412
415
|
viewer.crosshair_dragged.connect(
|
|
413
416
|
lambda crosshair_info: self.command_hardware.emit(
|
|
414
|
-
ThreadCommand(
|
|
415
|
-
dict(crosshair_info=crosshair_info,
|
|
417
|
+
ThreadCommand(ControlToHardwareViewer.CROSSHAIR,
|
|
418
|
+
dict(crosshair_info=crosshair_info,
|
|
419
|
+
ind_viewer=ind_viewer))))
|
|
416
420
|
|
|
417
421
|
|
|
418
422
|
self._viewers = viewers
|
|
@@ -457,7 +461,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
457
461
|
"""
|
|
458
462
|
if not do_init:
|
|
459
463
|
try:
|
|
460
|
-
self.command_hardware.emit(ThreadCommand(
|
|
464
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareViewer.CLOSE))
|
|
461
465
|
QtWidgets.QApplication.processEvents()
|
|
462
466
|
if self.ui is not None:
|
|
463
467
|
self.ui.detector_init = False
|
|
@@ -481,8 +485,10 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
481
485
|
self._hardware_thread.hardware = hardware
|
|
482
486
|
if self.config('viewer', 'viewer_in_thread'):
|
|
483
487
|
self._hardware_thread.start()
|
|
484
|
-
self.command_hardware.emit(ThreadCommand(
|
|
485
|
-
|
|
488
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareViewer.INI_DETECTOR,
|
|
489
|
+
attribute=[
|
|
490
|
+
self.settings.child('detector_settings').saveState(),
|
|
491
|
+
self.controller]))
|
|
486
492
|
if self.ui is not None:
|
|
487
493
|
for dock in self.ui.viewer_docks:
|
|
488
494
|
dock.setEnabled(True)
|
|
@@ -490,15 +496,15 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
490
496
|
except Exception as e:
|
|
491
497
|
self.logger.exception(str(e))
|
|
492
498
|
|
|
493
|
-
def snap(self):
|
|
499
|
+
def snap(self, send_to_tcpip=False):
|
|
494
500
|
""" Launch a single grab """
|
|
495
|
-
self.grab_data(False, snap_state=True)
|
|
501
|
+
self.grab_data(False, snap_state=True, send_to_tcpip=send_to_tcpip)
|
|
496
502
|
|
|
497
|
-
def grab(self):
|
|
503
|
+
def grab(self, send_to_tcpip=False):
|
|
498
504
|
""" Launch a continuous grab """
|
|
499
505
|
if self.ui is not None:
|
|
500
506
|
self.manage_ui_actions('grab', 'setChecked', not self._grabing)
|
|
501
|
-
self.grab_data(not self._grabing, snap_state=False)
|
|
507
|
+
self.grab_data(not self._grabing, snap_state=False, send_to_tcpip=send_to_tcpip)
|
|
502
508
|
|
|
503
509
|
def snapshot(self, pathname=None, dosave=False, send_to_tcpip=False):
|
|
504
510
|
"""Do one single grab (snap) and eventually save the data.
|
|
@@ -545,16 +551,18 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
545
551
|
if snap_state:
|
|
546
552
|
self.update_status(f'{self._title}: Snap')
|
|
547
553
|
self.command_hardware.emit(
|
|
548
|
-
ThreadCommand(
|
|
554
|
+
ThreadCommand(ControlToHardwareViewer.SINGLE,
|
|
555
|
+
dict(Naverage=self.settings['main_settings', 'Naverage'])))
|
|
549
556
|
else:
|
|
550
557
|
if not grab_state:
|
|
551
558
|
self.update_status(f'{self._title}: Stop Grab')
|
|
552
|
-
self.command_hardware.emit(ThreadCommand(
|
|
559
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareViewer.STOP_GRAB, ))
|
|
553
560
|
else:
|
|
554
|
-
self.thread_status(ThreadCommand(
|
|
561
|
+
self.thread_status(ThreadCommand(ThreadStatusViewer.UPDATE_CHANNELS, ))
|
|
555
562
|
self.update_status(f'{self._title}: Continuous Grab')
|
|
556
563
|
self.command_hardware.emit(
|
|
557
|
-
ThreadCommand(
|
|
564
|
+
ThreadCommand(ControlToHardwareViewer.GRAB,
|
|
565
|
+
dict(Naverage=self.settings['main_settings', 'Naverage'])))
|
|
558
566
|
|
|
559
567
|
def take_bkg(self):
|
|
560
568
|
""" Do a snap and store data to be used as background into an attribute: `self._bkg`
|
|
@@ -578,7 +586,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
578
586
|
def stop(self):
|
|
579
587
|
""" Stop the current continuous grabbing """
|
|
580
588
|
self.update_status(f'{self._title}: Stop Grab')
|
|
581
|
-
self.command_hardware.emit(ThreadCommand(
|
|
589
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareViewer.STOP_ALL, ))
|
|
582
590
|
self._grabing = False
|
|
583
591
|
|
|
584
592
|
@Slot()
|
|
@@ -612,7 +620,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
612
620
|
def _init_continuous_save(self):
|
|
613
621
|
""" Initialize the continuous saving H5Saver object
|
|
614
622
|
|
|
615
|
-
Update the module_and_data_saver attribute as :class:`
|
|
623
|
+
Update the module_and_data_saver attribute as :class:`DetectorTimeSaver` object
|
|
616
624
|
"""
|
|
617
625
|
if self._h5saver_continuous.settings.child('do_save').value():
|
|
618
626
|
|
|
@@ -622,7 +630,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
622
630
|
self.module_and_data_saver.h5saver = self._h5saver_continuous
|
|
623
631
|
self._h5saver_continuous.init_file(update_h5=True)
|
|
624
632
|
|
|
625
|
-
self.module_and_data_saver = module_saving.
|
|
633
|
+
self.module_and_data_saver = module_saving.DetectorTimeSaver(self)
|
|
626
634
|
self.module_and_data_saver.h5saver = self._h5saver_continuous
|
|
627
635
|
self.module_and_data_saver.get_set_node()
|
|
628
636
|
|
|
@@ -637,8 +645,10 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
637
645
|
except Exception as e:
|
|
638
646
|
self.logger.exception(str(e))
|
|
639
647
|
|
|
640
|
-
def append_data(self, dte: DataToExport = None,
|
|
641
|
-
|
|
648
|
+
def append_data(self, dte: DataToExport = None,
|
|
649
|
+
where: Union[Node, str] = None,
|
|
650
|
+
**kwargs):
|
|
651
|
+
"""Appends current DataToExport to a DetectorTimeSaver
|
|
642
652
|
|
|
643
653
|
Method to be used when performing continuous saving into a h5file (continuous mode or DAQ_Logger)
|
|
644
654
|
|
|
@@ -647,14 +657,21 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
647
657
|
dte: DataToExport
|
|
648
658
|
not really used
|
|
649
659
|
where: Node or str
|
|
660
|
+
kwargs: dict
|
|
650
661
|
See Also
|
|
651
662
|
--------
|
|
652
|
-
:class:`
|
|
663
|
+
:class:`DetectorTimeSaver`
|
|
653
664
|
"""
|
|
654
665
|
if dte is None:
|
|
655
666
|
dte = self._data_to_save_export
|
|
656
|
-
|
|
657
|
-
|
|
667
|
+
init_step = kwargs.pop('init_step', None)
|
|
668
|
+
if init_step is None:
|
|
669
|
+
init_step = self._h5saver_continuous.settings['N_saved'] == 0
|
|
670
|
+
self._add_data_to_saver(dte,
|
|
671
|
+
init_step=init_step,
|
|
672
|
+
where=where,
|
|
673
|
+
**kwargs)
|
|
674
|
+
|
|
658
675
|
self._h5saver_continuous.settings.child('N_saved').setValue(self._h5saver_continuous.settings['N_saved'] + 1)
|
|
659
676
|
|
|
660
677
|
def insert_data(self, indexes: Tuple[int], where: Union[Node, str] = None,
|
|
@@ -693,7 +710,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
693
710
|
|
|
694
711
|
See Also
|
|
695
712
|
--------
|
|
696
|
-
DetectorSaver,
|
|
713
|
+
DetectorSaver, DetectorTimeSaver, DetectorExtendedSaver
|
|
697
714
|
|
|
698
715
|
"""
|
|
699
716
|
if dte is not None:
|
|
@@ -970,7 +987,8 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
970
987
|
self._h5saver_continuous.show_settings(param.value())
|
|
971
988
|
|
|
972
989
|
elif param.name() == 'wait_time':
|
|
973
|
-
self.command_hardware.emit(ThreadCommand(
|
|
990
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareViewer.UPDATE_WAIT_TIME,
|
|
991
|
+
[param.value()]))
|
|
974
992
|
|
|
975
993
|
self._update_settings(param=param)
|
|
976
994
|
|
|
@@ -1047,6 +1065,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1047
1065
|
scaling=self.settings['main_settings', 'axes', 'yaxis', 'yscaling'])
|
|
1048
1066
|
return scaled_xaxis, scaled_yaxis
|
|
1049
1067
|
|
|
1068
|
+
|
|
1050
1069
|
def thread_status(self, status: ThreadCommand):
|
|
1051
1070
|
"""Get back info (using the ThreadCommand object) from the hardware
|
|
1052
1071
|
|
|
@@ -1068,7 +1087,7 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1068
1087
|
"""
|
|
1069
1088
|
super().thread_status(status, 'detector')
|
|
1070
1089
|
|
|
1071
|
-
if status.command ==
|
|
1090
|
+
if status.command == ThreadStatusViewer.INI_DETECTOR:
|
|
1072
1091
|
self.update_status("detector initialized: " + str(status.attribute['initialized']))
|
|
1073
1092
|
if self.ui is not None:
|
|
1074
1093
|
self.ui.detector_init = status.attribute['initialized']
|
|
@@ -1080,13 +1099,13 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1080
1099
|
|
|
1081
1100
|
self.init_signal.emit(self._initialized_state)
|
|
1082
1101
|
|
|
1083
|
-
elif status.command ==
|
|
1102
|
+
elif status.command == ThreadStatusViewer.GRAB:
|
|
1084
1103
|
self.grab_status.emit(True)
|
|
1085
1104
|
|
|
1086
|
-
elif status.command ==
|
|
1105
|
+
elif status.command == ThreadStatusViewer.GRAB_STOPPED:
|
|
1087
1106
|
self.grab_status.emit(False)
|
|
1088
1107
|
|
|
1089
|
-
elif status.command ==
|
|
1108
|
+
elif status.command == ThreadStatusViewer.INI_LCD:
|
|
1090
1109
|
if self._lcd is not None:
|
|
1091
1110
|
try:
|
|
1092
1111
|
self._lcd.parent.close()
|
|
@@ -1098,11 +1117,11 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1098
1117
|
lcd.setVisible(True)
|
|
1099
1118
|
QtWidgets.QApplication.processEvents()
|
|
1100
1119
|
|
|
1101
|
-
elif status.command ==
|
|
1120
|
+
elif status.command == ThreadStatusViewer.LCD:
|
|
1102
1121
|
"""status.attribute should be a list of numpy arrays of shape (1,)"""
|
|
1103
1122
|
self._lcd.setvalues(status.attribute)
|
|
1104
1123
|
|
|
1105
|
-
elif status.command ==
|
|
1124
|
+
elif status.command == ThreadStatusViewer.STOP:
|
|
1106
1125
|
self.stop_grab()
|
|
1107
1126
|
|
|
1108
1127
|
def connect_tcp_ip(self):
|
|
@@ -1132,6 +1151,13 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1132
1151
|
return
|
|
1133
1152
|
if 'Send Data' in status.command:
|
|
1134
1153
|
self.snapshot('', send_to_tcpip=True)
|
|
1154
|
+
elif status.command == LECOViewerCommands.GRAB:
|
|
1155
|
+
self.grab(send_to_tcpip=True)
|
|
1156
|
+
elif status.command ==LECOViewerCommands.SNAP:
|
|
1157
|
+
self.snap( send_to_tcpip=True)
|
|
1158
|
+
|
|
1159
|
+
elif status.command == LECOViewerCommands.STOP:
|
|
1160
|
+
self.stop()
|
|
1135
1161
|
|
|
1136
1162
|
elif status.command == LECOClientCommands.LECO_CONNECTED:
|
|
1137
1163
|
self.settings.child('main_settings', 'leco', 'leco_connected').setValue(True)
|
|
@@ -1139,18 +1165,6 @@ class DAQ_Viewer(ParameterControlModule):
|
|
|
1139
1165
|
elif status.command == LECOClientCommands.LECO_DISCONNECTED:
|
|
1140
1166
|
self.settings.child('main_settings', 'leco', 'leco_connected').setValue(False)
|
|
1141
1167
|
|
|
1142
|
-
elif status.command == 'set_info':
|
|
1143
|
-
path_in_settings = status.attribute[0]
|
|
1144
|
-
param_as_xml = status.attribute[1]
|
|
1145
|
-
param_dict = ioxml.XML_string_to_parameter(param_as_xml)[0]
|
|
1146
|
-
param_tmp = Parameter.create(**param_dict)
|
|
1147
|
-
param = self.settings.child('detector_settings', *path_in_settings[1:])
|
|
1148
|
-
param.restoreState(param_tmp.saveState())
|
|
1149
|
-
|
|
1150
|
-
elif status.command == 'get_axis':
|
|
1151
|
-
raise DeprecationWarning('Do not use this, the axis are in the data objects')
|
|
1152
|
-
self.command_hardware.emit(
|
|
1153
|
-
ThreadCommand('get_axis', )) # tells the plugin to emit its axes so that the server will receive them
|
|
1154
1168
|
|
|
1155
1169
|
|
|
1156
1170
|
class DAQ_Detector(QObject):
|
|
@@ -1235,46 +1249,40 @@ class DAQ_Detector(QObject):
|
|
|
1235
1249
|
* get_axis
|
|
1236
1250
|
* any string that the hardware is able to understand
|
|
1237
1251
|
"""
|
|
1238
|
-
if command.command ==
|
|
1252
|
+
if command.command == ControlToHardwareViewer.INI_DETECTOR:
|
|
1239
1253
|
status = self.ini_detector(*command.attribute)
|
|
1240
|
-
self.status_sig.emit(ThreadCommand(
|
|
1254
|
+
self.status_sig.emit(ThreadCommand(ThreadStatusViewer.INI_DETECTOR, status))
|
|
1241
1255
|
|
|
1242
|
-
elif command.command ==
|
|
1256
|
+
elif command.command == ControlToHardwareViewer.CLOSE:
|
|
1243
1257
|
status = self.close()
|
|
1244
|
-
self.status_sig.emit(ThreadCommand(
|
|
1258
|
+
self.status_sig.emit(ThreadCommand(ThreadStatus.CLOSE, [status, 'log']))
|
|
1245
1259
|
|
|
1246
|
-
elif command.command ==
|
|
1260
|
+
elif command.command == ControlToHardwareViewer.GRAB:
|
|
1247
1261
|
self.single_grab = False
|
|
1248
1262
|
self.grab_state = True
|
|
1249
1263
|
self.grab_data(**command.attribute)
|
|
1250
1264
|
|
|
1251
|
-
elif command.command ==
|
|
1265
|
+
elif command.command == ControlToHardwareViewer.SINGLE:
|
|
1252
1266
|
self.single_grab = True
|
|
1253
1267
|
self.grab_state = True
|
|
1254
1268
|
self.single(**command.attribute)
|
|
1255
1269
|
|
|
1256
|
-
elif command.command ==
|
|
1270
|
+
elif command.command == ControlToHardwareViewer.STOP_GRAB:
|
|
1257
1271
|
self.grab_state = False
|
|
1258
|
-
self.status_sig.emit(ThreadCommand(
|
|
1272
|
+
self.status_sig.emit(ThreadCommand(ThreadStatus.UPDATE_STATUS, 'Stoping grab'))
|
|
1259
1273
|
|
|
1260
|
-
elif command.command ==
|
|
1274
|
+
elif command.command == ControlToHardwareViewer.STOP_ALL:
|
|
1261
1275
|
self.grab_state = False
|
|
1262
1276
|
self.detector.stop()
|
|
1263
1277
|
QtWidgets.QApplication.processEvents()
|
|
1264
|
-
self.status_sig.emit(ThreadCommand(
|
|
1278
|
+
self.status_sig.emit(ThreadCommand(ThreadStatus.UPDATE_STATUS, 'Stoping grab'))
|
|
1265
1279
|
|
|
1266
|
-
elif command.command ==
|
|
1280
|
+
elif command.command == ControlToHardwareViewer.UPDATE_SCANNER: # may be deprecated
|
|
1267
1281
|
self.detector.update_scanner(command.attribute[0])
|
|
1268
1282
|
|
|
1269
|
-
elif command.command ==
|
|
1270
|
-
self.detector.move_at_navigator(*command.attribute)
|
|
1271
|
-
|
|
1272
|
-
elif command.command == 'update_wait_time':
|
|
1283
|
+
elif command.command == ControlToHardwareViewer.UPDATE_WAIT_TIME:
|
|
1273
1284
|
self.wait_time = command.attribute[0]
|
|
1274
1285
|
|
|
1275
|
-
elif command.command == 'get_axis':
|
|
1276
|
-
self.detector.get_axis()
|
|
1277
|
-
|
|
1278
1286
|
else: # custom commands for particular plugins
|
|
1279
1287
|
if hasattr(self.detector, command.command):
|
|
1280
1288
|
cmd = getattr(self.detector, command.command)
|
|
@@ -22,6 +22,7 @@ from pymodaq.control_modules.utils import DET_TYPES, DAQTypesEnum
|
|
|
22
22
|
from pymodaq_gui.plotting.data_viewers.viewer import ViewerFactory, ViewerDispatcher
|
|
23
23
|
from pymodaq_gui.plotting.data_viewers import ViewersEnum
|
|
24
24
|
from pymodaq_utils.enums import enum_checker
|
|
25
|
+
from pymodaq.control_modules.thread_commands import UiToMainViewer
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
viewer_factory = ViewerFactory()
|
|
@@ -107,12 +108,8 @@ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
|
|
|
107
108
|
|
|
108
109
|
@detectors.setter
|
|
109
110
|
def detectors(self, detectors: List[str]):
|
|
110
|
-
#self._detectors_combo.currentTextChanged.disconnect()
|
|
111
111
|
self._detectors_combo.clear()
|
|
112
112
|
self._detectors_combo.addItems(detectors)
|
|
113
|
-
#self._detectors_combo.currentTextChanged.connect(
|
|
114
|
-
# lambda mod: self.command_sig.emit(ThreadCommand('detector_changed', mod)))
|
|
115
|
-
#self.detector = detectors[0]
|
|
116
113
|
|
|
117
114
|
@property
|
|
118
115
|
def daq_type(self):
|
|
@@ -220,36 +217,37 @@ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
|
|
|
220
217
|
def connect_things(self):
|
|
221
218
|
self.connect_action('show_controls', lambda show: self._detector_widget.setVisible(show))
|
|
222
219
|
self.connect_action('show_settings', lambda show: self._settings_widget.setVisible(show))
|
|
223
|
-
self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand(
|
|
224
|
-
self.connect_action('show_config', lambda: self.command_sig.emit(ThreadCommand(
|
|
220
|
+
self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.QUIT, )))
|
|
221
|
+
self.connect_action('show_config', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SHOW_CONFIG, )))
|
|
225
222
|
|
|
226
|
-
self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand(
|
|
227
|
-
self.connect_action('stop', lambda: self.command_sig.emit(ThreadCommand(
|
|
223
|
+
self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SHOW_LOG, )))
|
|
224
|
+
self.connect_action('stop', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.STOP, )))
|
|
228
225
|
self.connect_action('stop', lambda: self.get_action('grab').setChecked(False))
|
|
229
226
|
self.connect_action('stop', lambda: self._enable_ini_buttons(True))
|
|
230
227
|
self.connect_action('stop', lambda: self._settings_widget.setEnabled(True))
|
|
231
228
|
|
|
232
229
|
self.connect_action('grab', self._grab)
|
|
233
|
-
self.connect_action('snap', lambda: self.command_sig.emit(ThreadCommand(
|
|
230
|
+
self.connect_action('snap', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SNAP, )))
|
|
234
231
|
|
|
235
|
-
self.connect_action('save_current', lambda: self.command_sig.emit(ThreadCommand(
|
|
236
|
-
self.connect_action('save_new', lambda: self.command_sig.emit(ThreadCommand(
|
|
237
|
-
self.connect_action('open', lambda: self.command_sig.emit(ThreadCommand(
|
|
232
|
+
self.connect_action('save_current', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SAVE_CURRENT, )))
|
|
233
|
+
self.connect_action('save_new', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SAVE_NEW, )))
|
|
234
|
+
self.connect_action('open', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.OPEN, )))
|
|
238
235
|
|
|
239
236
|
self._ini_det_pb.clicked.connect(self.send_init)
|
|
240
237
|
|
|
241
238
|
self._detectors_combo.currentTextChanged.connect(
|
|
242
|
-
lambda mod: self.command_sig.emit(ThreadCommand(
|
|
239
|
+
lambda mod: self.command_sig.emit(ThreadCommand(UiToMainViewer.DETECTOR_CHANGED, mod)))
|
|
243
240
|
self._daq_types_combo.currentTextChanged.connect(self._daq_type_changed)
|
|
244
241
|
|
|
245
242
|
|
|
246
|
-
self._do_bkg_cb.clicked.connect(lambda checked: self.command_sig.emit(ThreadCommand(
|
|
247
|
-
self._take_bkg_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(
|
|
243
|
+
self._do_bkg_cb.clicked.connect(lambda checked: self.command_sig.emit(ThreadCommand(UiToMainViewer.DO_BKG, checked)))
|
|
244
|
+
self._take_bkg_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.TAKE_BKG)))
|
|
248
245
|
|
|
249
246
|
def update_viewers(self, viewers_type: List[ViewersEnum]):
|
|
250
247
|
super().update_viewers(viewers_type)
|
|
251
|
-
self.command_sig.emit(ThreadCommand(
|
|
252
|
-
|
|
248
|
+
self.command_sig.emit(ThreadCommand(UiToMainViewer.VIEWERS_CHANGED,
|
|
249
|
+
attribute=dict(viewer_types=self.viewer_types,
|
|
250
|
+
viewers=self.viewers)))
|
|
253
251
|
|
|
254
252
|
@property
|
|
255
253
|
def data_ready(self):
|
|
@@ -263,7 +261,7 @@ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
|
|
|
263
261
|
try:
|
|
264
262
|
daq_type = enum_checker(DAQTypesEnum, daq_type)
|
|
265
263
|
|
|
266
|
-
self.command_sig.emit(ThreadCommand(
|
|
264
|
+
self.command_sig.emit(ThreadCommand(UiToMainViewer.DAQ_TYPE_CHANGED, daq_type))
|
|
267
265
|
if self.viewer_types != [daq_type.to_viewer_type()]:
|
|
268
266
|
self.update_viewers([daq_type.to_viewer_type()])
|
|
269
267
|
except ValueError as e:
|
|
@@ -281,7 +279,7 @@ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
|
|
|
281
279
|
|
|
282
280
|
def _grab(self):
|
|
283
281
|
"""Slot from the *grab* action"""
|
|
284
|
-
self.command_sig.emit(ThreadCommand(
|
|
282
|
+
self.command_sig.emit(ThreadCommand(UiToMainViewer.GRAB, attribute=self.is_action_checked('grab')))
|
|
285
283
|
self._enable_ini_buttons(not self.is_action_checked('grab'))
|
|
286
284
|
if not self.config('viewer', 'allow_settings_edition'):
|
|
287
285
|
self._settings_widget.setEnabled(not self.is_action_checked('grab'))
|
|
@@ -324,9 +322,10 @@ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
|
|
|
324
322
|
|
|
325
323
|
def send_init(self, checked: bool):
|
|
326
324
|
self._enable_detchoices(not checked)
|
|
327
|
-
self.command_sig.emit(ThreadCommand(
|
|
328
|
-
|
|
329
|
-
|
|
325
|
+
self.command_sig.emit(ThreadCommand(UiToMainViewer.INIT,
|
|
326
|
+
[checked,
|
|
327
|
+
self._daq_types_combo.currentText(),
|
|
328
|
+
self._detectors_combo.currentText()]))
|
|
330
329
|
|
|
331
330
|
def _enable_detchoices(self, enable=True):
|
|
332
331
|
self._detectors_combo.setEnabled(enable)
|
|
@@ -377,7 +376,7 @@ def main(init_qt=True):
|
|
|
377
376
|
def print_command_sig(cmd_sig):
|
|
378
377
|
print(cmd_sig)
|
|
379
378
|
prog.display_status(str(cmd_sig))
|
|
380
|
-
if cmd_sig.command ==
|
|
379
|
+
if cmd_sig.command == UiToMainViewer.INIT:
|
|
381
380
|
prog._enable_grab_buttons(cmd_sig.attribute[0])
|
|
382
381
|
prog.detector_init = cmd_sig.attribute[0]
|
|
383
382
|
|
pymodaq/control_modules/mocks.py
CHANGED
|
@@ -6,7 +6,7 @@ Created the 16/03/2023
|
|
|
6
6
|
"""
|
|
7
7
|
from pymodaq.utils.parameter import Parameter
|
|
8
8
|
from pymodaq_gui.h5modules import saving
|
|
9
|
-
from pymodaq.utils.h5modules.module_saving import DetectorSaver,
|
|
9
|
+
from pymodaq.utils.h5modules.module_saving import DetectorSaver, ActuatorTimeSaver, ScanSaver
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class MockDAQViewer:
|
|
@@ -27,7 +27,7 @@ class MockDAQMove:
|
|
|
27
27
|
self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
|
|
28
28
|
self.h5saver = h5saver
|
|
29
29
|
self.title = title
|
|
30
|
-
self.module_and_data_saver =
|
|
30
|
+
self.module_and_data_saver = ActuatorTimeSaver(self)
|
|
31
31
|
self.ui = None
|
|
32
32
|
|
|
33
33
|
|