pymodaq 5.1.6__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.
Files changed (154) hide show
  1. pymodaq/__init__.py +98 -0
  2. pymodaq/control_modules/__init__.py +1 -0
  3. pymodaq/control_modules/daq_move.py +1238 -0
  4. pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
  5. pymodaq/control_modules/daq_move_ui/factory.py +48 -0
  6. pymodaq/control_modules/daq_move_ui/ui_base.py +359 -0
  7. pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
  8. pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
  9. pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
  10. pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
  11. pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
  12. pymodaq/control_modules/daq_viewer.py +1517 -0
  13. pymodaq/control_modules/daq_viewer_ui.py +407 -0
  14. pymodaq/control_modules/mocks.py +57 -0
  15. pymodaq/control_modules/move_utility_classes.py +1141 -0
  16. pymodaq/control_modules/thread_commands.py +137 -0
  17. pymodaq/control_modules/ui_utils.py +72 -0
  18. pymodaq/control_modules/utils.py +591 -0
  19. pymodaq/control_modules/viewer_utility_classes.py +670 -0
  20. pymodaq/daq_utils/__init__.py +0 -0
  21. pymodaq/daq_utils/daq_utils.py +6 -0
  22. pymodaq/dashboard.py +2396 -0
  23. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.aliases +3 -0
  24. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvlps +3 -0
  25. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvproj +32 -0
  26. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.vi +0 -0
  27. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_1Dgaussian.vi +0 -0
  28. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_2Dgaussian.vi +0 -0
  29. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_cmd.vi +0 -0
  30. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_float.vi +0 -0
  31. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_int.vi +0 -0
  32. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_data.vi +0 -0
  33. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_int.vi +0 -0
  34. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_scalar.vi +0 -0
  35. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_string.vi +0 -0
  36. pymodaq/examples/Labview_TCP_Client/client_state.ctl +0 -0
  37. pymodaq/examples/Labview_TCP_Client/cmd_types.ctl +0 -0
  38. pymodaq/examples/__init__.py +0 -0
  39. pymodaq/examples/function_plotter.py +160 -0
  40. pymodaq/examples/nonlinearscanner.py +126 -0
  41. pymodaq/examples/qt_less_standalone_module.py +165 -0
  42. pymodaq/examples/tcp_client.py +97 -0
  43. pymodaq/extensions/__init__.py +25 -0
  44. pymodaq/extensions/adaptive/__init__.py +2 -0
  45. pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
  46. pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
  47. pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
  48. pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
  49. pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
  50. pymodaq/extensions/adaptive/utils.py +123 -0
  51. pymodaq/extensions/bayesian/__init__.py +2 -0
  52. pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
  53. pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
  54. pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
  55. pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
  56. pymodaq/extensions/bayesian/utils.py +180 -0
  57. pymodaq/extensions/console.py +73 -0
  58. pymodaq/extensions/daq_logger/__init__.py +1 -0
  59. pymodaq/extensions/daq_logger/abstract.py +52 -0
  60. pymodaq/extensions/daq_logger/daq_logger.py +519 -0
  61. pymodaq/extensions/daq_logger/db/__init__.py +0 -0
  62. pymodaq/extensions/daq_logger/db/db_logger.py +300 -0
  63. pymodaq/extensions/daq_logger/db/db_logger_models.py +100 -0
  64. pymodaq/extensions/daq_logger/h5logging.py +84 -0
  65. pymodaq/extensions/daq_scan.py +1218 -0
  66. pymodaq/extensions/daq_scan_ui.py +241 -0
  67. pymodaq/extensions/data_mixer/__init__.py +0 -0
  68. pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
  69. pymodaq/extensions/data_mixer/data_mixer.py +262 -0
  70. pymodaq/extensions/data_mixer/model.py +108 -0
  71. pymodaq/extensions/data_mixer/models/__init__.py +0 -0
  72. pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
  73. pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
  74. pymodaq/extensions/data_mixer/parser.py +53 -0
  75. pymodaq/extensions/data_mixer/utils.py +23 -0
  76. pymodaq/extensions/h5browser.py +9 -0
  77. pymodaq/extensions/optimizers_base/__init__.py +0 -0
  78. pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
  79. pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
  80. pymodaq/extensions/optimizers_base/utils.py +427 -0
  81. pymodaq/extensions/pid/__init__.py +16 -0
  82. pymodaq/extensions/pid/actuator_controller.py +14 -0
  83. pymodaq/extensions/pid/daq_move_PID.py +154 -0
  84. pymodaq/extensions/pid/pid_controller.py +1016 -0
  85. pymodaq/extensions/pid/utils.py +189 -0
  86. pymodaq/extensions/utils.py +111 -0
  87. pymodaq/icon.ico +0 -0
  88. pymodaq/post_treatment/__init__.py +6 -0
  89. pymodaq/post_treatment/load_and_plot.py +352 -0
  90. pymodaq/resources/__init__.py +0 -0
  91. pymodaq/resources/config_template.toml +57 -0
  92. pymodaq/resources/preset_default.xml +1 -0
  93. pymodaq/resources/setup_plugin.py +73 -0
  94. pymodaq/splash.png +0 -0
  95. pymodaq/utils/__init__.py +0 -0
  96. pymodaq/utils/array_manipulation.py +6 -0
  97. pymodaq/utils/calibration_camera.py +180 -0
  98. pymodaq/utils/chrono_timer.py +203 -0
  99. pymodaq/utils/config.py +53 -0
  100. pymodaq/utils/conftests.py +5 -0
  101. pymodaq/utils/daq_utils.py +158 -0
  102. pymodaq/utils/data.py +128 -0
  103. pymodaq/utils/enums.py +6 -0
  104. pymodaq/utils/exceptions.py +38 -0
  105. pymodaq/utils/gui_utils/__init__.py +10 -0
  106. pymodaq/utils/gui_utils/loader_utils.py +75 -0
  107. pymodaq/utils/gui_utils/utils.py +18 -0
  108. pymodaq/utils/gui_utils/widgets/lcd.py +8 -0
  109. pymodaq/utils/h5modules/__init__.py +2 -0
  110. pymodaq/utils/h5modules/module_saving.py +526 -0
  111. pymodaq/utils/leco/__init__.py +25 -0
  112. pymodaq/utils/leco/daq_move_LECODirector.py +217 -0
  113. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +163 -0
  114. pymodaq/utils/leco/director_utils.py +74 -0
  115. pymodaq/utils/leco/leco_director.py +166 -0
  116. pymodaq/utils/leco/pymodaq_listener.py +364 -0
  117. pymodaq/utils/leco/rpc_method_definitions.py +43 -0
  118. pymodaq/utils/leco/utils.py +74 -0
  119. pymodaq/utils/logger.py +6 -0
  120. pymodaq/utils/managers/__init__.py +0 -0
  121. pymodaq/utils/managers/batchscan_manager.py +346 -0
  122. pymodaq/utils/managers/modules_manager.py +589 -0
  123. pymodaq/utils/managers/overshoot_manager.py +242 -0
  124. pymodaq/utils/managers/preset_manager.py +229 -0
  125. pymodaq/utils/managers/preset_manager_utils.py +262 -0
  126. pymodaq/utils/managers/remote_manager.py +484 -0
  127. pymodaq/utils/math_utils.py +6 -0
  128. pymodaq/utils/messenger.py +6 -0
  129. pymodaq/utils/parameter/__init__.py +10 -0
  130. pymodaq/utils/parameter/utils.py +6 -0
  131. pymodaq/utils/scanner/__init__.py +5 -0
  132. pymodaq/utils/scanner/scan_config.py +16 -0
  133. pymodaq/utils/scanner/scan_factory.py +259 -0
  134. pymodaq/utils/scanner/scan_selector.py +477 -0
  135. pymodaq/utils/scanner/scanner.py +324 -0
  136. pymodaq/utils/scanner/scanners/_1d_scanners.py +174 -0
  137. pymodaq/utils/scanner/scanners/_2d_scanners.py +299 -0
  138. pymodaq/utils/scanner/scanners/__init__.py +1 -0
  139. pymodaq/utils/scanner/scanners/sequential.py +224 -0
  140. pymodaq/utils/scanner/scanners/tabular.py +319 -0
  141. pymodaq/utils/scanner/utils.py +110 -0
  142. pymodaq/utils/svg/__init__.py +6 -0
  143. pymodaq/utils/svg/svg_renderer.py +20 -0
  144. pymodaq/utils/svg/svg_view.py +35 -0
  145. pymodaq/utils/svg/svg_viewer2D.py +50 -0
  146. pymodaq/utils/tcp_ip/__init__.py +6 -0
  147. pymodaq/utils/tcp_ip/mysocket.py +12 -0
  148. pymodaq/utils/tcp_ip/serializer.py +13 -0
  149. pymodaq/utils/tcp_ip/tcp_server_client.py +772 -0
  150. pymodaq-5.1.6.dist-info/METADATA +238 -0
  151. pymodaq-5.1.6.dist-info/RECORD +154 -0
  152. pymodaq-5.1.6.dist-info/WHEEL +4 -0
  153. pymodaq-5.1.6.dist-info/entry_points.txt +7 -0
  154. pymodaq-5.1.6.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,407 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 05/09/2022
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+
8
+
9
+ from typing import List
10
+ import sys
11
+
12
+ from qtpy import QtWidgets
13
+ from qtpy.QtCore import Signal
14
+ from qtpy.QtWidgets import QVBoxLayout, QWidget, QComboBox
15
+ from pymodaq.utils.daq_utils import ThreadCommand
16
+ from pymodaq.control_modules.ui_utils import ControlModuleUI
17
+
18
+ from pymodaq_gui.utils.widgets import PushButtonIcon, LabelWithFont, QLED
19
+ from pymodaq_gui.utils import Dock
20
+ from pymodaq_utils.config import Config as ConfigUtils
21
+ from pymodaq.control_modules.utils import DET_TYPES, DAQTypesEnum
22
+ from pymodaq_gui.plotting.data_viewers.viewer import ViewerFactory, ViewerDispatcher
23
+ from pymodaq_gui.plotting.data_viewers import ViewersEnum
24
+ from pymodaq_utils.enums import enum_checker
25
+ from pymodaq.utils.config import Config
26
+ from pymodaq.control_modules.thread_commands import UiToMainViewer
27
+
28
+
29
+ viewer_factory = ViewerFactory()
30
+ config = Config()
31
+ config_utils = ConfigUtils()
32
+
33
+
34
+ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
35
+ """DAQ_Viewer user interface.
36
+
37
+ This class manages the UI and emit dedicated signals depending on actions from the user
38
+
39
+ Attributes
40
+ ----------
41
+ command_sig: Signal[Threadcommand]
42
+ This signal is emitted whenever some actions done by the user has to be
43
+ applied on the main module. Possible commands are:
44
+ * init
45
+ * quit
46
+ * grab
47
+ * snap
48
+ * stop
49
+ * show_log
50
+ * detector_changed
51
+ * daq_type_changed
52
+ * save_current
53
+ * save_new
54
+
55
+ Methods
56
+ -------
57
+ display_value(value: float)
58
+ Update the display of the actuator's value on the UI
59
+ do_init()
60
+ Programmatic init
61
+
62
+ See Also
63
+ --------
64
+ pymodaq.utils.daq_utils.ThreadCommand
65
+ """
66
+
67
+ command_sig = Signal(ThreadCommand)
68
+
69
+ def __init__(self, parent, title="DAQ_Viewer", daq_type='DAQ2D', dock_settings=None, dock_viewer=None):
70
+ ControlModuleUI.__init__(self, parent)
71
+ ViewerDispatcher.__init__(self, self.dockarea, title=title, next_to_dock=dock_settings)
72
+
73
+ self.title = title
74
+
75
+ self._detector_widget = None
76
+ self._settings_widget = None
77
+ self._info_detector = None
78
+ self._daq_types_combo = None
79
+ self._detectors_combo = None
80
+ self._ini_det_pb = None
81
+ self._ini_state_led = None
82
+ self._do_bkg_cb = None
83
+ self._take_bkg_pb = None
84
+ self._settings_dock = dock_settings
85
+ self.setup_docks()
86
+
87
+ daq_type = enum_checker(DAQTypesEnum, daq_type)
88
+ self.daq_types = daq_type.names() # init the combobox through the daq_types attribute
89
+ self.daq_type = daq_type
90
+
91
+ self.detectors = [det['name'] for det in DET_TYPES[self.daq_type.name]]
92
+ self.setup_actions() # see ActionManager MixIn class
93
+ self.add_viewer(self.daq_type.to_viewer_type(), dock_viewer=dock_viewer)
94
+ self.connect_things()
95
+
96
+ self._enable_grab_buttons(False)
97
+ self._detector_widget.setVisible(False)
98
+ self._settings_widget.setVisible(False)
99
+
100
+ @property
101
+ def detector(self):
102
+ return self._detectors_combo.currentText()
103
+
104
+ @detector.setter
105
+ def detector(self, det_name: str):
106
+ self._detectors_combo.setCurrentText(det_name)
107
+ @property
108
+ def detectors(self):
109
+ return [self._detectors_combo.itemText(ind) for ind in range(self._detectors_combo.count())]
110
+
111
+ @detectors.setter
112
+ def detectors(self, detectors: List[str]):
113
+ self._detectors_combo.clear()
114
+ self._detectors_combo.addItems(detectors)
115
+
116
+ @property
117
+ def daq_type(self):
118
+ return DAQTypesEnum[self._daq_types_combo.currentText()]
119
+
120
+ @daq_type.setter
121
+ def daq_type(self, dtype: DAQTypesEnum):
122
+ dtype = enum_checker(DAQTypesEnum, dtype)
123
+ self._daq_types_combo.setCurrentText(dtype.name)
124
+
125
+ @property
126
+ def daq_types(self):
127
+ return self.daq_type.names()
128
+
129
+ @daq_types.setter
130
+ def daq_types(self, dtypes: List[str]):
131
+ self._daq_types_combo.clear()
132
+ self._daq_types_combo.addItems(dtypes)
133
+ self.daq_type = DAQTypesEnum[dtypes[0]]
134
+
135
+ def close(self):
136
+ for dock in self.viewer_docks:
137
+ dock.close()
138
+ self._settings_dock.close()
139
+
140
+ def setup_docks(self):
141
+ if self._settings_dock is None:
142
+ self._settings_dock = Dock(self.title + "_Settings", size=(150, 250))
143
+ self.dockarea.addDock(self._settings_dock)
144
+
145
+ widget = QWidget()
146
+ widget.setLayout(QVBoxLayout())
147
+ #widget.layout().setSizeConstraint(QHBoxLayout.SetFixedSize)
148
+ widget.layout().setContentsMargins(2, 2, 2, 2)
149
+ self._settings_dock.addWidget(widget)
150
+
151
+ info_ui = QWidget()
152
+ self._detector_widget = QWidget()
153
+ self._settings_widget = QWidget()
154
+ self._settings_widget.setLayout(QtWidgets.QVBoxLayout())
155
+
156
+ bkg_widget = QWidget()
157
+ bkg_widget.setLayout(QtWidgets.QHBoxLayout())
158
+
159
+ widget.layout().addWidget(info_ui)
160
+ widget.layout().addWidget(self.toolbar)
161
+ widget.layout().addWidget(self._detector_widget)
162
+ if not config('viewer', 'settings_as_popup'):
163
+ widget.layout().addWidget(self._settings_widget)
164
+ widget.layout().addStretch(0)
165
+
166
+ info_ui.setLayout(QtWidgets.QHBoxLayout())
167
+ info_ui.layout().addWidget(LabelWithFont(self.title, font_name="Tahoma", font_size=14, isbold=True,
168
+ isitalic=True))
169
+ self._info_detector = LabelWithFont('', font_name="Tahoma", font_size=8, isbold=True, isitalic=True)
170
+ info_ui.layout().addWidget(self._info_detector)
171
+
172
+ self._detector_widget.setLayout(QtWidgets.QGridLayout())
173
+ self._daq_types_combo = QComboBox()
174
+ self._daq_types_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
175
+ self._detectors_combo = QComboBox()
176
+ self._detectors_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
177
+ self._ini_det_pb = PushButtonIcon('ini', 'Init. Detector', True, 'Initialize selected detector')
178
+ self._ini_state_led = QLED(readonly=True)
179
+ self._do_bkg_cb = QtWidgets.QCheckBox('Do Bkg')
180
+ self._take_bkg_pb = QtWidgets.QPushButton('Take Bkg')
181
+ self._take_bkg_pb.setChecked(False)
182
+
183
+ self._detector_widget.layout().addWidget(LabelWithFont('DAQ type:'), 0, 0)
184
+ self._detector_widget.layout().addWidget(self._daq_types_combo, 0, 1)
185
+ self._detector_widget.layout().addWidget(LabelWithFont('Detector:'), 1, 0)
186
+ self._detector_widget.layout().addWidget(self._detectors_combo, 1, 1)
187
+ self._detector_widget.layout().addWidget(self._ini_det_pb, 0, 2)
188
+ self._detector_widget.layout().addWidget(self._ini_state_led, 1, 2)
189
+ self._detector_widget.layout().addWidget(bkg_widget, 2, 0, 1, 3)
190
+
191
+ bkg_widget.layout().addWidget(self._do_bkg_cb)
192
+ bkg_widget.layout().addWidget(self._take_bkg_pb)
193
+
194
+ self.statusbar = QtWidgets.QStatusBar()
195
+ self.statusbar.setMaximumHeight(30)
196
+ widget.layout().addWidget(self.statusbar)
197
+
198
+ def add_setting_tree(self, tree):
199
+ self._settings_widget.layout().addWidget(tree)
200
+
201
+ def setup_actions(self):
202
+ self.add_action('grab', 'Grab', 'run2', "Grab data from the detector", checkable=True)
203
+ self.add_action('snap', 'Snap', 'snap', "Take a snapshot from the detector")
204
+ self.add_action('stop', 'Stop', 'stop', "Stop grabing")
205
+ self.add_action('save_current', 'Save Current Data', 'SaveAs', "Save Current Data")
206
+ self.add_action('save_new', 'Save New Data', 'Snap&Save', "Save New Data")
207
+ self.add_action('open', 'Load Data', 'Open', "Load Saved Data")
208
+
209
+ self.add_action('show_controls', 'Show Controls', 'Settings', "Show Controls to set DAQ and Detector type",
210
+ checkable=True)
211
+ self.add_action('show_settings', 'Show Settings', 'tree', "Show Settings", checkable=True)
212
+
213
+ self.add_action('quit', 'Quit the module', 'close2')
214
+ self.add_action('show_config', 'Show Config', 'Settings', "Show PyMoDAQ Config", checkable=False,
215
+ toolbar=self.toolbar)
216
+ self.add_action('log', 'Show Log file', 'information2')
217
+
218
+ self._data_ready_led = QLED(readonly=True)
219
+ self.toolbar.addWidget(self._data_ready_led)
220
+
221
+ def connect_things(self):
222
+ self.connect_action('show_controls', lambda show: self._detector_widget.setVisible(show))
223
+ self.connect_action('show_settings', self._show_settings)
224
+ self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.QUIT, )))
225
+ self.connect_action('show_config', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SHOW_CONFIG, )))
226
+
227
+ self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SHOW_LOG, )))
228
+ self.connect_action('stop', self._stop)
229
+ self.connect_action('grab', self._grab)
230
+ self.connect_action('snap', lambda: self.command_sig.emit(ThreadCommand(UiToMainViewer.SNAP, )))
231
+
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, )))
235
+
236
+ self._ini_det_pb.clicked.connect(self.send_init)
237
+
238
+ self._detectors_combo.currentTextChanged.connect(
239
+ lambda mod: self.command_sig.emit(ThreadCommand(UiToMainViewer.DETECTOR_CHANGED, mod)))
240
+ self._daq_types_combo.currentTextChanged.connect(self._daq_type_changed)
241
+
242
+
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)))
245
+
246
+ def _show_settings(self, show: bool = True):
247
+ self._settings_widget.setVisible(show)
248
+ self._settings_widget.closeEvent = lambda event: self.set_action_checked('show_settings', False)
249
+
250
+ def update_viewers(self, viewers_type: List[ViewersEnum]):
251
+ super().update_viewers(viewers_type)
252
+ self.command_sig.emit(ThreadCommand(UiToMainViewer.VIEWERS_CHANGED,
253
+ attribute=dict(viewer_types=self.viewer_types,
254
+ viewers=self.viewers)))
255
+
256
+ @property
257
+ def data_ready(self):
258
+ return self._data_ready_led.get_state()
259
+
260
+ @data_ready.setter
261
+ def data_ready(self, status):
262
+ self._data_ready_led.set_as(status)
263
+
264
+ def _daq_type_changed(self, daq_type: DAQTypesEnum):
265
+ try:
266
+ daq_type = enum_checker(DAQTypesEnum, daq_type)
267
+
268
+ self.command_sig.emit(ThreadCommand(UiToMainViewer.DAQ_TYPE_CHANGED, daq_type))
269
+ if self.viewer_types != [daq_type.to_viewer_type()]:
270
+ self.update_viewers([daq_type.to_viewer_type()])
271
+ except ValueError as e:
272
+ pass
273
+
274
+ def show_settings(self, show=True):
275
+ if (self.is_action_checked('show_settings') and not show) or \
276
+ (not self.is_action_checked('show_settings') and show):
277
+ self.get_action('show_settings').trigger()
278
+
279
+ def show_controls(self, show=True):
280
+ if (self.is_action_checked('show_controls') and not show) or \
281
+ (not self.is_action_checked('show_controls') and show):
282
+ self.get_action('show_controls').trigger()
283
+
284
+ def _grab(self):
285
+ """Slot from the *grab* action"""
286
+ self.command_sig.emit(ThreadCommand(UiToMainViewer.GRAB, attribute=self.is_action_checked('grab')))
287
+ self._enable_ini_buttons(not self.is_action_checked('grab'))
288
+ if not self.config('viewer', 'allow_settings_edition'):
289
+ self._settings_widget.setEnabled(not self.is_action_checked('grab'))
290
+
291
+ def _stop(self):
292
+ """Slot from the *stop* action"""
293
+ self.command_sig.emit(ThreadCommand(UiToMainViewer.STOP, ))
294
+ self.get_action('grab').setChecked(False)
295
+ self._enable_ini_buttons(True)
296
+ self._settings_widget.setEnabled(True)
297
+
298
+ def do_init(self, do_init=True):
299
+ """Programmatically press the Init button
300
+ API entry
301
+ Parameters
302
+ ----------
303
+ do_init: bool
304
+ will fire the Init button depending on the argument value and the button check state
305
+ """
306
+ if do_init is not self._ini_det_pb.isChecked():
307
+ self._ini_det_pb.click()
308
+
309
+ def do_grab(self, do_grab=True):
310
+ """Programmatically press the Grab button
311
+ API entry
312
+ Parameters
313
+ ----------
314
+ do_grab: bool
315
+ will fire the Init button depending on the argument value and the button check state
316
+ """
317
+ if (do_grab and not self.is_action_checked('grab')) or ((not do_grab) and self.is_action_checked('grab')):
318
+ self.get_action('grab').trigger()
319
+
320
+ def do_snap(self):
321
+ """Programmatically press the Snap button
322
+ API entry
323
+ """
324
+ self.get_action('snap').trigger()
325
+
326
+ def do_stop(self):
327
+ """Programmatically press the Stop button
328
+ API entry
329
+ """
330
+ self.get_action('stop').trigger()
331
+ if self.is_action_checked('grab'):
332
+ self.get_action('grab').trigger()
333
+
334
+ def send_init(self, checked: bool):
335
+ self._enable_detchoices(not checked)
336
+ self.command_sig.emit(ThreadCommand(UiToMainViewer.INIT,
337
+ [checked,
338
+ self._daq_types_combo.currentText(),
339
+ self._detectors_combo.currentText()]))
340
+
341
+ def _enable_detchoices(self, enable=True):
342
+ self._detectors_combo.setEnabled(enable)
343
+ self._daq_types_combo.setEnabled(enable)
344
+
345
+ @property
346
+ def detector_init(self):
347
+ """bool: the status of the init LED."""
348
+ return self._ini_state_led.get_state()
349
+
350
+ @detector_init.setter
351
+ def detector_init(self, status):
352
+ if status:
353
+ self._info_detector.setText(f'{self.daq_type.name} : {self.detector}')
354
+ else:
355
+ self._info_detector.setText('')
356
+ self._ini_state_led.set_as(status)
357
+ self._enable_grab_buttons(status)
358
+
359
+ def _enable_grab_buttons(self, status):
360
+ self.get_action('grab').setEnabled(status)
361
+ self.get_action('snap').setEnabled(status)
362
+ self.get_action('stop').setEnabled(status)
363
+ self.get_action('save_current').setEnabled(status)
364
+ self.get_action('save_new').setEnabled(status)
365
+
366
+ def _enable_ini_buttons(self, status):
367
+ self._ini_det_pb.setEnabled(status)
368
+ self.get_action('quit').setEnabled(status)
369
+
370
+
371
+ def main(init_qt=True):
372
+ from pymodaq.utils.gui_utils.dock import DockArea
373
+ from pymodaq.utils.parameter import ParameterTree, Parameter
374
+ from pymodaq.control_modules.viewer_utility_classes import params as daq_viewer_params
375
+
376
+ if init_qt: # used for the test suite
377
+ app = QtWidgets.QApplication(sys.argv)
378
+
379
+ param = Parameter.create(name='settings', type='group', children=daq_viewer_params)
380
+ tree = ParameterTree()
381
+ tree.setParameters(param, showTop=False)
382
+
383
+ dockarea = DockArea()
384
+ prog = DAQ_Viewer_UI(dockarea)
385
+ dockarea.show()
386
+
387
+ def print_command_sig(cmd_sig):
388
+ print(cmd_sig)
389
+ prog.display_status(str(cmd_sig))
390
+ if cmd_sig.command == UiToMainViewer.INIT:
391
+ prog._enable_grab_buttons(cmd_sig.attribute[0])
392
+ prog.detector_init = cmd_sig.attribute[0]
393
+
394
+ # prog.detectors = detectors
395
+ prog.command_sig.connect(print_command_sig)
396
+
397
+ prog.add_setting_tree(tree)
398
+
399
+ prog.update_viewers([ViewersEnum['Viewer0D'], ViewersEnum['Viewer1D'], ViewersEnum['Viewer2D']])
400
+
401
+ if init_qt:
402
+ sys.exit(app.exec_())
403
+ return prog, dockarea
404
+
405
+
406
+ if __name__ == '__main__':
407
+ main()
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 16/03/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ from pymodaq.utils.parameter import Parameter
8
+ from pymodaq_gui.h5modules import saving
9
+ from pymodaq.utils.h5modules.module_saving import DetectorSaver, ActuatorTimeSaver, ScanSaver
10
+
11
+
12
+ class MockDAQViewer:
13
+ params = [{'title': 'mytitle', 'name': 'title', 'type': 'str', 'value': 'myviewervalue'}]
14
+
15
+ def __init__(self, h5saver: saving.H5Saver = None, title='MyDet0D'):
16
+ self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
17
+ self.h5saver = h5saver
18
+ self.title = title
19
+ self.module_and_data_saver = DetectorSaver(self)
20
+ self.module_and_data_saver.h5saver = h5saver
21
+ self._module_and_data_saver = self.module_and_data_saver
22
+ self.ui = None
23
+
24
+
25
+ class MockDAQMove:
26
+ params = [{'title': 'mytitle', 'name': 'title', 'type': 'str', 'value': 'myactuatorvalue'}]
27
+
28
+ def __init__(self, h5saver: saving.H5Saver = None, title='MyAct'):
29
+ self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
30
+ self.h5saver = h5saver
31
+ self.title = title
32
+ self.module_and_data_saver = ActuatorTimeSaver(self)
33
+ self.module_and_data_saver.h5saver = h5saver
34
+ self._module_and_data_saver = self.module_and_data_saver
35
+ self.ui = None
36
+
37
+
38
+ class ModulesManagerMock:
39
+ def __init__(self, actuators, detectors):
40
+ self.modules_all = actuators + detectors
41
+ self.modules = actuators + detectors
42
+ self.detectors_all = detectors
43
+ self.actuators_all = actuators
44
+
45
+
46
+ class MockScan:
47
+ params = [{'title': 'mytitle', 'name': 'title', 'type': 'str', 'value': 'myactuatorvalue'}]
48
+
49
+ def __init__(self, h5saver: saving.H5Saver = None):
50
+ self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
51
+ self.h5saver = h5saver
52
+ self.title = 'MyScan'
53
+ actuators = [MockDAQMove(self.h5saver)]
54
+ detectors = [MockDAQViewer(self.h5saver, 'Det0D'), MockDAQViewer(self.h5saver, 'Det1D')]
55
+ self.modules_manager = ModulesManagerMock(actuators, detectors)
56
+ self.module_and_data_saver = ScanSaver(self)
57
+ self.ui = None