pymodaq 3.6.12__py3-none-any.whl → 4.0.1__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.

Files changed (233) hide show
  1. pymodaq/__init__.py +13 -6
  2. pymodaq/control_modules/__init__.py +0 -7
  3. pymodaq/control_modules/daq_move.py +965 -2
  4. pymodaq/control_modules/daq_move_ui.py +319 -0
  5. pymodaq/control_modules/daq_viewer.py +1573 -3
  6. pymodaq/control_modules/daq_viewer_ui.py +393 -0
  7. pymodaq/control_modules/mocks.py +51 -0
  8. pymodaq/control_modules/move_utility_classes.py +709 -8
  9. pymodaq/control_modules/utils.py +256 -0
  10. pymodaq/control_modules/viewer_utility_classes.py +663 -6
  11. pymodaq/daq_utils.py +89 -0
  12. pymodaq/dashboard.py +91 -72
  13. pymodaq/examples/custom_app.py +12 -11
  14. pymodaq/examples/custom_viewer.py +10 -10
  15. pymodaq/examples/function_plotter.py +16 -13
  16. pymodaq/examples/nonlinearscanner.py +8 -6
  17. pymodaq/examples/parameter_ex.py +7 -7
  18. pymodaq/examples/preset_MockCamera.xml +1 -0
  19. pymodaq/extensions/__init__.py +16 -0
  20. pymodaq/extensions/console.py +76 -0
  21. pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
  22. pymodaq/extensions/daq_scan.py +1339 -0
  23. pymodaq/extensions/daq_scan_ui.py +240 -0
  24. pymodaq/extensions/h5browser.py +23 -0
  25. pymodaq/{pid → extensions/pid}/__init__.py +4 -2
  26. pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
  27. pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
  28. pymodaq/{pid → extensions/pid}/utils.py +52 -6
  29. pymodaq/extensions/utils.py +40 -0
  30. pymodaq/post_treatment/__init__.py +6 -0
  31. pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
  32. pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
  33. pymodaq/post_treatment/load_and_plot.py +219 -0
  34. pymodaq/post_treatment/process_to_scalar.py +263 -0
  35. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  36. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  37. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
  38. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
  39. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
  40. pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
  41. pymodaq/resources/VERSION +1 -1
  42. pymodaq/resources/config_template.toml +32 -13
  43. pymodaq/resources/preset_default.xml +1 -1
  44. pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
  45. pymodaq/utils/__init__.py +0 -29
  46. pymodaq/utils/abstract/__init__.py +48 -0
  47. pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
  48. pymodaq/utils/array_manipulation.py +379 -8
  49. pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
  50. pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
  51. pymodaq/utils/config.py +448 -0
  52. pymodaq/utils/conftests.py +5 -0
  53. pymodaq/utils/daq_utils.py +828 -8
  54. pymodaq/utils/data.py +1873 -7
  55. pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
  56. pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
  57. pymodaq/{daq_utils → utils}/enums.py +12 -7
  58. pymodaq/utils/exceptions.py +37 -0
  59. pymodaq/utils/factory.py +82 -0
  60. pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
  61. pymodaq/utils/gui_utils/custom_app.py +129 -0
  62. pymodaq/utils/gui_utils/file_io.py +66 -0
  63. pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
  64. pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
  65. pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
  66. pymodaq/utils/gui_utils/widgets/label.py +24 -0
  67. pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
  68. pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
  69. pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
  70. pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
  71. pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
  72. pymodaq/utils/h5modules/__init__.py +1 -0
  73. pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
  74. pymodaq/utils/h5modules/browsing.py +683 -0
  75. pymodaq/utils/h5modules/data_saving.py +839 -0
  76. pymodaq/utils/h5modules/h5logging.py +110 -0
  77. pymodaq/utils/h5modules/module_saving.py +350 -0
  78. pymodaq/utils/h5modules/saving.py +914 -0
  79. pymodaq/utils/h5modules/utils.py +85 -0
  80. pymodaq/utils/logger.py +64 -6
  81. pymodaq/utils/managers/action_manager.py +460 -0
  82. pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
  83. pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
  84. pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
  85. pymodaq/utils/managers/parameter_manager.py +110 -0
  86. pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
  87. pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
  88. pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
  89. pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
  90. pymodaq/utils/math_utils.py +546 -10
  91. pymodaq/{daq_utils → utils}/messenger.py +5 -1
  92. pymodaq/utils/parameter/__init__.py +2 -15
  93. pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
  94. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
  95. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
  96. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
  97. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
  98. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
  99. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
  100. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
  101. pymodaq/utils/parameter/utils.py +206 -11
  102. pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
  103. pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
  104. pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
  105. pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
  106. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
  107. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
  108. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
  109. pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
  110. pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
  111. pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
  112. pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
  113. pymodaq/utils/plotting/navigator.py +355 -0
  114. pymodaq/utils/plotting/scan_selector.py +480 -0
  115. pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
  116. pymodaq/utils/plotting/utils/filter.py +538 -0
  117. pymodaq/utils/plotting/utils/lineout.py +224 -0
  118. pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
  119. pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
  120. pymodaq/utils/plotting/widgets.py +76 -0
  121. pymodaq/utils/scanner/__init__.py +10 -0
  122. pymodaq/utils/scanner/scan_factory.py +204 -0
  123. pymodaq/utils/scanner/scanner.py +271 -0
  124. pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
  125. pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
  126. pymodaq/utils/scanner/scanners/sequential.py +192 -0
  127. pymodaq/utils/scanner/scanners/tabular.py +294 -0
  128. pymodaq/utils/scanner/utils.py +83 -0
  129. pymodaq/utils/slicing.py +47 -0
  130. pymodaq/utils/svg/__init__.py +6 -0
  131. pymodaq/utils/svg/svg_renderer.py +20 -0
  132. pymodaq/utils/svg/svg_view.py +35 -0
  133. pymodaq/utils/svg/svg_viewer2D.py +51 -0
  134. pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
  135. pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
  136. pymodaq/utils/units.py +216 -0
  137. pymodaq-4.0.1.dist-info/METADATA +159 -0
  138. {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
  139. {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
  140. pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
  141. pymodaq/daq_move/daq_move_gui.py +0 -279
  142. pymodaq/daq_move/daq_move_gui.ui +0 -534
  143. pymodaq/daq_move/daq_move_main.py +0 -1042
  144. pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
  145. pymodaq/daq_move/utility_classes.py +0 -671
  146. pymodaq/daq_scan.py +0 -2160
  147. pymodaq/daq_utils/array_manipulation.py +0 -386
  148. pymodaq/daq_utils/config.py +0 -273
  149. pymodaq/daq_utils/conftests.py +0 -7
  150. pymodaq/daq_utils/custom_parameter_tree.py +0 -9
  151. pymodaq/daq_utils/daq_enums.py +0 -133
  152. pymodaq/daq_utils/daq_utils.py +0 -1402
  153. pymodaq/daq_utils/exceptions.py +0 -71
  154. pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
  155. pymodaq/daq_utils/gui_utils/file_io.py +0 -75
  156. pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
  157. pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
  158. pymodaq/daq_utils/h5exporters.py +0 -242
  159. pymodaq/daq_utils/h5modules.py +0 -1559
  160. pymodaq/daq_utils/h5utils.py +0 -241
  161. pymodaq/daq_utils/managers/action_manager.py +0 -236
  162. pymodaq/daq_utils/managers/parameter_manager.py +0 -57
  163. pymodaq/daq_utils/math_utils.py +0 -705
  164. pymodaq/daq_utils/parameter/__init__.py +0 -1
  165. pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
  166. pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
  167. pymodaq/daq_utils/parameter/utils.py +0 -136
  168. pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
  169. pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
  170. pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
  171. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
  172. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
  173. pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
  174. pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
  175. pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
  176. pymodaq/daq_utils/plotting/items/__init__.py +0 -0
  177. pymodaq/daq_utils/plotting/navigator.py +0 -500
  178. pymodaq/daq_utils/plotting/scan_selector.py +0 -289
  179. pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
  180. pymodaq/daq_utils/plotting/utils/filter.py +0 -236
  181. pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
  182. pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
  183. pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
  184. pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
  185. pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
  186. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
  187. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
  188. pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
  189. pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
  190. pymodaq/daq_utils/scanner.py +0 -1289
  191. pymodaq/daq_utils/tree_layout/__init__.py +0 -0
  192. pymodaq/daq_viewer/__init__.py +0 -0
  193. pymodaq/daq_viewer/daq_gui_settings.py +0 -237
  194. pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
  195. pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
  196. pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
  197. pymodaq/daq_viewer/utility_classes.py +0 -673
  198. pymodaq/examples/logger_image/__init__.py +0 -0
  199. pymodaq/examples/logger_image/logger_displayer.py +0 -121
  200. pymodaq/examples/logger_image/setup.svg +0 -3119
  201. pymodaq/examples/logger_image/setup_svg.py +0 -114
  202. pymodaq/h5browser.py +0 -39
  203. pymodaq/utils/scanner.py +0 -15
  204. pymodaq-3.6.12.dist-info/METADATA +0 -39
  205. pymodaq-3.6.12.dist-info/entry_points.txt +0 -8
  206. pymodaq-3.6.12.dist-info/top_level.txt +0 -1
  207. /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
  208. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
  209. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
  210. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
  211. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
  212. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
  213. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
  214. /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
  215. /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
  216. /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
  217. /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
  218. /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
  219. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
  220. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
  221. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
  222. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
  223. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
  224. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
  225. /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
  226. /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
  227. /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
  228. /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
  229. /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
  230. /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
  231. /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
  232. /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
  233. {pymodaq-3.6.12.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,393 @@
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.utils import ControlModuleUI
17
+
18
+ from pymodaq.utils.gui_utils.widgets import PushButtonIcon, LabelWithFont, QLED
19
+ from pymodaq.utils.gui_utils import Dock
20
+ from pymodaq.utils.config import Config
21
+ from pymodaq.control_modules.utils import DET_TYPES, DAQTypesEnum
22
+ from pymodaq.utils.plotting.data_viewers.viewer import ViewerFactory, ViewersEnum, ViewerDispatcher
23
+ from pymodaq.utils.enums import enum_checker
24
+
25
+
26
+ viewer_factory = ViewerFactory()
27
+ config = Config()
28
+
29
+
30
+ class DAQ_Viewer_UI(ControlModuleUI, ViewerDispatcher):
31
+ """DAQ_Viewer user interface.
32
+
33
+ This class manages the UI and emit dedicated signals depending on actions from the user
34
+
35
+ Attributes
36
+ ----------
37
+ command_sig: Signal[Threadcommand]
38
+ This signal is emitted whenever some actions done by the user has to be
39
+ applied on the main module. Possible commands are:
40
+ * init
41
+ * quit
42
+ * grab
43
+ * snap
44
+ * stop
45
+ * show_log
46
+ * detector_changed
47
+ * daq_type_changed
48
+ * save_current
49
+ * save_new
50
+
51
+ Methods
52
+ -------
53
+ display_value(value: float)
54
+ Update the display of the actuator's value on the UI
55
+ do_init()
56
+ Programmatic init
57
+
58
+ See Also
59
+ --------
60
+ pymodaq.utils.daq_utils.ThreadCommand
61
+ """
62
+
63
+ command_sig = Signal(ThreadCommand)
64
+
65
+ def __init__(self, parent, title="DAQ_Viewer", daq_type='DAQ2D', dock_settings=None, dock_viewer=None):
66
+ ControlModuleUI.__init__(self, parent)
67
+ ViewerDispatcher.__init__(self, self.dockarea, title=title, next_to_dock=dock_settings)
68
+
69
+ self.title = title
70
+
71
+ self._detector_widget = None
72
+ self._settings_widget = None
73
+ self._info_detector = None
74
+ self._daq_types_combo = None
75
+ self._detectors_combo = None
76
+ self._ini_det_pb = None
77
+ self._ini_state_led = None
78
+ self._do_bkg_cb = None
79
+ self._take_bkg_pb = None
80
+ self._settings_dock = dock_settings
81
+ self.setup_docks()
82
+
83
+ daq_type = enum_checker(DAQTypesEnum, daq_type)
84
+ self.daq_types = daq_type.names() # init the combobox through the daq_types attribute
85
+ self.daq_type = daq_type
86
+
87
+ self.detectors = [det['name'] for det in DET_TYPES[self.daq_type.name]]
88
+ self.setup_actions() # see ActionManager MixIn class
89
+ self.add_viewer(self.daq_type.to_viewer_type(), dock_viewer=dock_viewer)
90
+ self.connect_things()
91
+
92
+ self._enable_grab_buttons(False)
93
+ self._detector_widget.setVisible(False)
94
+ self._settings_widget.setVisible(False)
95
+
96
+ @property
97
+ def detector(self):
98
+ return self._detectors_combo.currentText()
99
+
100
+ @detector.setter
101
+ def detector(self, det_name: str):
102
+ self._detectors_combo.setCurrentText(det_name)
103
+ @property
104
+ def detectors(self):
105
+ return [self._detectors_combo.itemText(ind) for ind in range(self._detectors_combo.count())]
106
+
107
+ @detectors.setter
108
+ def detectors(self, detectors: List[str]):
109
+ #self._detectors_combo.currentTextChanged.disconnect()
110
+ self._detectors_combo.clear()
111
+ self._detectors_combo.addItems(detectors)
112
+ #self._detectors_combo.currentTextChanged.connect(
113
+ # lambda mod: self.command_sig.emit(ThreadCommand('detector_changed', mod)))
114
+ #self.detector = detectors[0]
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
+ bkg_widget = QWidget()
156
+ bkg_widget.setLayout(QtWidgets.QHBoxLayout())
157
+
158
+ widget.layout().addWidget(info_ui)
159
+ widget.layout().addWidget(self.toolbar)
160
+ widget.layout().addWidget(self._detector_widget)
161
+ widget.layout().addWidget(self._settings_widget)
162
+ widget.layout().addStretch(0)
163
+
164
+ info_ui.setLayout(QtWidgets.QHBoxLayout())
165
+ info_ui.layout().addWidget(LabelWithFont(self.title, font_name="Tahoma", font_size=14, isbold=True,
166
+ isitalic=True))
167
+ self._info_detector = LabelWithFont('', font_name="Tahoma", font_size=8, isbold=True, isitalic=True)
168
+ info_ui.layout().addWidget(self._info_detector)
169
+
170
+ self._detector_widget.setLayout(QtWidgets.QGridLayout())
171
+ self._daq_types_combo = QComboBox()
172
+ self._daq_types_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
173
+ self._detectors_combo = QComboBox()
174
+ self._detectors_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
175
+ self._ini_det_pb = PushButtonIcon('ini', 'Init. Detector', True, 'Initialize selected detector')
176
+ self._ini_state_led = QLED(readonly=True)
177
+ self._do_bkg_cb = QtWidgets.QCheckBox('Do Bkg')
178
+ self._take_bkg_pb = QtWidgets.QPushButton('Take Bkg')
179
+ self._take_bkg_pb.setChecked(False)
180
+
181
+ self._detector_widget.layout().addWidget(LabelWithFont('DAQ type:'), 0, 0)
182
+ self._detector_widget.layout().addWidget(self._daq_types_combo, 0, 1)
183
+ self._detector_widget.layout().addWidget(LabelWithFont('Detector:'), 1, 0)
184
+ self._detector_widget.layout().addWidget(self._detectors_combo, 1, 1)
185
+ self._detector_widget.layout().addWidget(self._ini_det_pb, 0, 2)
186
+ self._detector_widget.layout().addWidget(self._ini_state_led, 1, 2)
187
+ self._detector_widget.layout().addWidget(bkg_widget, 2, 0, 1, 3)
188
+
189
+ bkg_widget.layout().addWidget(self._do_bkg_cb)
190
+ bkg_widget.layout().addWidget(self._take_bkg_pb)
191
+
192
+ self.statusbar = QtWidgets.QStatusBar()
193
+ self.statusbar.setMaximumHeight(30)
194
+ widget.layout().addWidget(self.statusbar)
195
+
196
+ def add_setting_tree(self, tree):
197
+ self._settings_widget.layout().addWidget(tree)
198
+
199
+ def setup_actions(self):
200
+ self.add_action('grab', 'Grab', 'run2', "Grab data from the detector", checkable=True)
201
+ self.add_action('snap', 'Snap', 'snap', "Take a snapshot from the detector")
202
+ self.add_action('stop', 'Stop', 'stop', "Stop grabing")
203
+ self.add_action('save_current', 'Save Current Data', 'SaveAs', "Save Current Data")
204
+ self.add_action('save_new', 'Save New Data', 'Snap&Save', "Save New Data")
205
+ self.add_action('open', 'Load Data', 'Open', "Load Saved Data")
206
+
207
+ self.add_action('show_controls', 'Show Controls', 'Settings', "Show Controls to set DAQ and Detector type",
208
+ checkable=True)
209
+ self.add_action('show_settings', 'Show Settings', 'Settings', "Show Settings", checkable=True)
210
+
211
+ self.add_action('quit', 'Quit the module', 'close2')
212
+ self.add_action('log', 'Show Log file', 'information2')
213
+
214
+ self._data_ready_led = QLED(readonly=True)
215
+ self.toolbar.addWidget(self._data_ready_led)
216
+
217
+ def connect_things(self):
218
+ self.connect_action('show_controls', lambda show: self._detector_widget.setVisible(show))
219
+ self.connect_action('show_settings', lambda show: self._settings_widget.setVisible(show))
220
+ self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand('quit', )))
221
+
222
+ self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand('show_log', )))
223
+ self.connect_action('stop', lambda: self.command_sig.emit(ThreadCommand('stop', )))
224
+ self.connect_action('stop', lambda: self.get_action('grab').setChecked(False))
225
+ self.connect_action('stop', lambda: self._enable_ini_buttons(True))
226
+ self.connect_action('stop', lambda: self._settings_widget.setEnabled(True))
227
+
228
+ self.connect_action('grab', self._grab)
229
+ self.connect_action('snap', lambda: self.command_sig.emit(ThreadCommand('snap', )))
230
+
231
+ self.connect_action('save_current', lambda: self.command_sig.emit(ThreadCommand('save_current', )))
232
+ self.connect_action('save_new', lambda: self.command_sig.emit(ThreadCommand('save_new', )))
233
+ self.connect_action('open', lambda: self.command_sig.emit(ThreadCommand('open', )))
234
+
235
+ self._ini_det_pb.clicked.connect(self._send_init)
236
+
237
+ self._detectors_combo.currentTextChanged.connect(
238
+ lambda mod: self.command_sig.emit(ThreadCommand('detector_changed', mod)))
239
+ self._daq_types_combo.currentTextChanged.connect(self._daq_type_changed)
240
+
241
+
242
+ self._do_bkg_cb.clicked.connect(lambda checked: self.command_sig.emit(ThreadCommand('do_bkg', checked)))
243
+ self._take_bkg_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand('take_bkg')))
244
+
245
+ def update_viewers(self, viewers_type: List[ViewersEnum]):
246
+ super().update_viewers(viewers_type)
247
+ self.command_sig.emit(ThreadCommand('viewers_changed', attribute=dict(viewer_types=self.viewer_types,
248
+ viewers=self.viewers)))
249
+
250
+ @property
251
+ def data_ready(self):
252
+ return self._data_ready_led.get_state()
253
+
254
+ @data_ready.setter
255
+ def data_ready(self, status):
256
+ self._data_ready_led.set_as(status)
257
+
258
+ def _daq_type_changed(self, daq_type: DAQTypesEnum):
259
+ try:
260
+ daq_type = enum_checker(DAQTypesEnum, daq_type)
261
+
262
+ self.command_sig.emit(ThreadCommand('daq_type_changed', daq_type))
263
+ if self.viewer_types != [daq_type.to_viewer_type()]:
264
+ self.update_viewers([daq_type.to_viewer_type()])
265
+ except ValueError as e:
266
+ pass
267
+
268
+ def show_settings(self, show=True):
269
+ if (self.is_action_checked('show_settings') and not show) or \
270
+ (not self.is_action_checked('show_settings') and show):
271
+ self.get_action('show_settings').trigger()
272
+
273
+ def show_controls(self, show=True):
274
+ if (self.is_action_checked('show_controls') and not show) or \
275
+ (not self.is_action_checked('show_controls') and show):
276
+ self.get_action('show_controls').trigger()
277
+
278
+ def _grab(self):
279
+ """Slot from the *grab* action"""
280
+ self.command_sig.emit(ThreadCommand('grab', attribute=self.is_action_checked('grab')))
281
+ self._enable_ini_buttons(not self.is_action_checked('grab'))
282
+ self._settings_widget.setEnabled(not self.is_action_checked('grab'))
283
+
284
+ def do_init(self, do_init=True):
285
+ """Programmatically press the Init button
286
+ API entry
287
+ Parameters
288
+ ----------
289
+ do_init: bool
290
+ will fire the Init button depending on the argument value and the button check state
291
+ """
292
+ if (do_init and not self._ini_det_pb.isChecked()) or ((not do_init) and self._ini_det_pb.isChecked()):
293
+ self._ini_det_pb.click()
294
+
295
+ def do_grab(self, do_grab=True):
296
+ """Programmatically press the Grab button
297
+ API entry
298
+ Parameters
299
+ ----------
300
+ do_grab: bool
301
+ will fire the Init button depending on the argument value and the button check state
302
+ """
303
+ if (do_grab and not self.is_action_checked('grab')) or ((not do_grab) and self.is_action_checked('grab')):
304
+ self.get_action('grab').trigger()
305
+
306
+ def do_snap(self):
307
+ """Programmatically press the Snap button
308
+ API entry
309
+ """
310
+ self.get_action('snap').trigger()
311
+
312
+ def do_stop(self):
313
+ """Programmatically press the Stop button
314
+ API entry
315
+ """
316
+ self.get_action('stop').trigger()
317
+ if self.is_action_checked('grab'):
318
+ self.get_action('grab').trigger()
319
+
320
+ def _send_init(self):
321
+ self._enable_detchoices(not self._ini_det_pb.isChecked())
322
+ self._ini_det_pb.isChecked()
323
+ self.command_sig.emit(ThreadCommand('init', [self._ini_det_pb.isChecked(),
324
+ self._daq_types_combo.currentText(),
325
+ self._detectors_combo.currentText()]))
326
+
327
+ def _enable_detchoices(self, enable=True):
328
+ self._detectors_combo.setEnabled(enable)
329
+ self._daq_types_combo.setEnabled(enable)
330
+
331
+ @property
332
+ def detector_init(self):
333
+ """bool: the status of the init LED."""
334
+ return self._ini_state_led.get_state()
335
+
336
+ @detector_init.setter
337
+ def detector_init(self, status):
338
+ if status:
339
+ self._info_detector.setText(f'{self.daq_type.name} : {self.detector}')
340
+ else:
341
+ self._info_detector.setText('')
342
+ self._ini_state_led.set_as(status)
343
+ self._enable_grab_buttons(status)
344
+
345
+ def _enable_grab_buttons(self, status):
346
+ self.get_action('grab').setEnabled(status)
347
+ self.get_action('snap').setEnabled(status)
348
+ self.get_action('stop').setEnabled(status)
349
+ self.get_action('save_current').setEnabled(status)
350
+ self.get_action('save_new').setEnabled(status)
351
+
352
+ def _enable_ini_buttons(self, status):
353
+ self._ini_det_pb.setEnabled(status)
354
+ self.get_action('quit').setEnabled(status)
355
+
356
+
357
+ def main(init_qt=True):
358
+ from pymodaq.utils.gui_utils.dock import DockArea
359
+ from pymodaq.utils.managers.parameter_manager import ParameterTree, Parameter
360
+ from pymodaq.control_modules.viewer_utility_classes import params as daq_viewer_params
361
+
362
+ if init_qt: # used for the test suite
363
+ app = QtWidgets.QApplication(sys.argv)
364
+
365
+ param = Parameter.create(name='settings', type='group', children=daq_viewer_params)
366
+ tree = ParameterTree()
367
+ tree.setParameters(param, showTop=False)
368
+
369
+ dockarea = DockArea()
370
+ prog = DAQ_Viewer_UI(dockarea)
371
+ dockarea.show()
372
+
373
+ def print_command_sig(cmd_sig):
374
+ print(cmd_sig)
375
+ prog.display_status(str(cmd_sig))
376
+ if cmd_sig.command == 'init':
377
+ prog._enable_grab_buttons(cmd_sig.attribute[0])
378
+ prog.detector_init = cmd_sig.attribute[0]
379
+
380
+ # prog.detectors = detectors
381
+ prog.command_sig.connect(print_command_sig)
382
+
383
+ prog.add_setting_tree(tree)
384
+
385
+ prog.update_viewers([ViewersEnum['Viewer0D'], ViewersEnum['Viewer1D'], ViewersEnum['Viewer2D']])
386
+
387
+ if init_qt:
388
+ sys.exit(app.exec_())
389
+ return prog, dockarea
390
+
391
+
392
+ if __name__ == '__main__':
393
+ main()
@@ -0,0 +1,51 @@
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.utils.h5modules import saving
9
+ from pymodaq.utils.h5modules.module_saving import DetectorSaver, ActuatorSaver, 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.ui = None
21
+
22
+
23
+ class MockDAQMove:
24
+ params = [{'title': 'mytitle', 'name': 'title', 'type': 'str', 'value': 'myactuatorvalue'}]
25
+
26
+ def __init__(self, h5saver: saving.H5Saver = None, title='MyAct'):
27
+ self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
28
+ self.h5saver = h5saver
29
+ self.title = title
30
+ self.module_and_data_saver = ActuatorSaver(self)
31
+ self.ui = None
32
+
33
+
34
+ class ModulesManagerMock:
35
+ def __init__(self, actuators, detectors):
36
+ self.modules_all = actuators + detectors
37
+ self.modules = actuators + detectors
38
+
39
+
40
+ class MockScan:
41
+ params = [{'title': 'mytitle', 'name': 'title', 'type': 'str', 'value': 'myactuatorvalue'}]
42
+
43
+ def __init__(self, h5saver: saving.H5Saver = None):
44
+ self.settings = Parameter.create(name='settings', type='group', children=self.params) # create a Parameter
45
+ self.h5saver = h5saver
46
+ self.title = 'MyScan'
47
+ actuators = [MockDAQMove(self.h5saver)]
48
+ detectors = [MockDAQViewer(self.h5saver, 'Det0D'), MockDAQViewer(self.h5saver, 'Det1D')]
49
+ self.modules_manager = ModulesManagerMock(actuators, detectors)
50
+ self.module_and_data_saver = ScanSaver(self)
51
+ self.ui = None