pymodaq 3.6.13__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.13.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
  139. {pymodaq-3.6.13.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 -686
  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.13.dist-info/METADATA +0 -39
  205. pymodaq-3.6.13.dist-info/entry_points.txt +0 -8
  206. pymodaq-3.6.13.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.13.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
@@ -1,2 +0,0 @@
1
- cd "C:\Users\Weber\Labo\Programmes Python\PyMoDAQ_Git\pymodaq\pymodaq\daq_viewer"
2
- C:\Miniconda3\envs\pyqt5tools\Scripts\pyuic5.exe -x daq_gui_settings.ui -o daq_gui_settings.py
@@ -1,673 +0,0 @@
1
- import os
2
- from qtpy import QtWidgets
3
- from qtpy.QtCore import QObject, Slot, Signal
4
-
5
- from pymodaq.daq_utils.parameter import ioxml
6
- from pymodaq.daq_utils.parameter.utils import get_param_path, get_param_from_name, iter_children
7
- from pyqtgraph.parametertree import Parameter
8
- from easydict import EasyDict as edict
9
-
10
- import numpy as np
11
- from pymodaq.daq_utils.daq_utils import gauss1D, gauss2D
12
- from pymodaq.daq_utils.daq_utils import ThreadCommand, getLineInfo
13
- from pymodaq.daq_utils.config import Config, get_set_local_dir
14
- from pymodaq.daq_utils.scanner import ScanParameters
15
- from pymodaq.daq_utils.tcp_server_client import TCPServer, tcp_parameters, Socket
16
-
17
- comon_parameters = [{'title': 'Controller Status:', 'name': 'controller_status', 'type': 'list', 'value': 'Master',
18
- 'limits': ['Master', 'Slave']}, ]
19
-
20
- local_path = get_set_local_dir()
21
- # look for eventual calibration files
22
- calibs = ['None']
23
- if local_path.joinpath('camera_calibrations').is_dir():
24
- for ind_file, file in enumerate(local_path.joinpath('camera_calibrations').iterdir()):
25
- if 'xml' in file.suffix:
26
- calibs.append(file.stem)
27
-
28
-
29
- config = Config()
30
-
31
- params = [
32
- {'title': 'Main Settings:', 'name': 'main_settings', 'expanded': False, 'type': 'group', 'children': [
33
- {'title': 'DAQ type:', 'name': 'DAQ_type', 'type': 'list', 'limits': ['DAQ0D', 'DAQ1D', 'DAQ2D', 'DAQND'],
34
- 'readonly': True},
35
- {'title': 'Detector type:', 'name': 'detector_type', 'type': 'str', 'value': '', 'readonly': True},
36
- {'title': 'Nviewers:', 'name': 'Nviewers', 'type': 'int', 'value': 1, 'min': 1, 'default': 1, 'readonly': True},
37
- {'title': 'Controller ID:', 'name': 'controller_ID', 'type': 'int', 'value': 0, 'default': 0, 'readonly': False},
38
- {'title': 'Show data and process:', 'name': 'show_data', 'type': 'bool', 'value': True, },
39
- {'title': 'Refresh time (ms):', 'name': 'refresh_time', 'type': 'float', 'value': 50., 'min': 0.},
40
- {'title': 'Naverage', 'name': 'Naverage', 'type': 'int', 'default': 1, 'value': 1, 'min': 1},
41
- {'title': 'Show averaging:', 'name': 'show_averaging', 'type': 'bool', 'default': False, 'value': False},
42
- {'title': 'Live averaging:', 'name': 'live_averaging', 'type': 'bool', 'default': False, 'value': False},
43
- {'title': 'N Live aver.:', 'name': 'N_live_averaging', 'type': 'int', 'default': 0, 'value': 0,
44
- 'visible': False},
45
- {'title': 'Wait time (ms):', 'name': 'wait_time', 'type': 'int', 'default': 0, 'value': 00, 'min': 0},
46
- {'title': 'Continuous saving:', 'name': 'continuous_saving_opt', 'type': 'bool', 'default': False,
47
- 'value': False},
48
- {'title': 'TCP/IP options:', 'name': 'tcpip', 'type': 'group', 'visible': True, 'expanded': False, 'children': [
49
- {'title': 'Connect to server:', 'name': 'connect_server', 'type': 'bool_push', 'label': 'Connect',
50
- 'value': False},
51
- {'title': 'Connected?:', 'name': 'tcp_connected', 'type': 'led', 'value': False},
52
- {'title': 'IP address:', 'name': 'ip_address', 'type': 'str',
53
- 'value': config('network', 'tcp-server', 'ip')},
54
- {'title': 'Port:', 'name': 'port', 'type': 'int', 'value': config('network', 'tcp-server', 'port')},
55
- ]},
56
- {'title': 'Overshoot options:', 'name': 'overshoot', 'type': 'group', 'visible': True, 'expanded': False,
57
- 'children': [
58
- {'title': 'Overshoot:', 'name': 'stop_overshoot', 'type': 'bool', 'value': False},
59
- {'title': 'Overshoot value:', 'name': 'overshoot_value', 'type': 'float', 'value': 0}]},
60
- {'title': 'Axis options:', 'name': 'axes', 'type': 'group', 'visible': False, 'expanded': False, 'children': [
61
- {'title': 'Use calibration?:', 'name': 'use_calib', 'type': 'list', 'limits': calibs},
62
- {'title': 'X axis:', 'name': 'xaxis', 'type': 'group', 'children': [
63
- {'title': 'Label:', 'name': 'xlabel', 'type': 'str', 'value': "x axis"},
64
- {'title': 'Units:', 'name': 'xunits', 'type': 'str', 'value': "pxls"},
65
- {'title': 'Offset:', 'name': 'xoffset', 'type': 'float', 'default': 0., 'value': 0.},
66
- {'title': 'Scaling', 'name': 'xscaling', 'type': 'float', 'default': 1., 'value': 1.},
67
- ]},
68
- {'title': 'Y axis:', 'name': 'yaxis', 'type': 'group', 'children': [
69
- {'title': 'Label:', 'name': 'ylabel', 'type': 'str', 'value': "y axis"},
70
- {'title': 'Units:', 'name': 'yunits', 'type': 'str', 'value': "pxls"},
71
- {'title': 'Offset:', 'name': 'yoffset', 'type': 'float', 'default': 0., 'value': 0.},
72
- {'title': 'Scaling', 'name': 'yscaling', 'type': 'float', 'default': 1., 'value': 1.},
73
- ]},
74
- ]},
75
-
76
- ]},
77
- {'title': 'Detector Settings', 'name': 'detector_settings', 'type': 'group', 'children': [
78
- {'title': 'ROI select:', 'name': 'ROIselect', 'type': 'group', 'visible': False, 'children': [
79
- {'title': 'Use ROI:', 'name': 'use_ROI', 'type': 'bool', 'value': False},
80
- {'title': 'x0:', 'name': 'x0', 'type': 'int', 'value': 0, 'min': 0},
81
- {'title': 'y0:', 'name': 'y0', 'type': 'int', 'value': 0, 'min': 0},
82
- {'title': 'width:', 'name': 'width', 'type': 'int', 'value': 10, 'min': 1},
83
- {'title': 'height:', 'name': 'height', 'type': 'int', 'value': 10, 'min': 1},
84
- ]}
85
- ]}
86
- ]
87
-
88
- def main(plugin_file=None, init=True):
89
- """
90
- this method start a DAQ_Viewer object with this defined plugin as detector
91
- Returns
92
- -------
93
- """
94
- import sys
95
- from qtpy import QtWidgets
96
- from pymodaq.daq_utils.gui_utils import DockArea
97
- from pymodaq.daq_viewer.daq_viewer_main import DAQ_Viewer
98
- from pathlib import Path
99
-
100
- app = QtWidgets.QApplication(sys.argv)
101
- if config('style', 'darkstyle'):
102
- import qdarkstyle
103
- app.setStyleSheet(qdarkstyle.load_stylesheet())
104
-
105
- win = QtWidgets.QMainWindow()
106
- area = DockArea()
107
- win.setCentralWidget(area)
108
- win.resize(1000, 500)
109
- win.setWindowTitle('PyMoDAQ Viewer')
110
- if plugin_file is None:
111
- detector = 'Mock'
112
- det_type = f'DAQ0D'
113
- else:
114
- detector = Path(plugin_file).stem[13:]
115
- det_type = f'DAQ{Path(plugin_file).stem[4:6].upper()}'
116
- prog = DAQ_Viewer(area, title="Testing", DAQ_type=det_type)
117
- win.show()
118
- prog.detector = detector
119
- if init:
120
- prog.init_det()
121
-
122
- sys.exit(app.exec_())
123
-
124
-
125
- class DAQ_Viewer_base(QObject):
126
- """
127
- ===================== ===================================
128
- **Attributes** **Type**
129
- *hardware_averaging* boolean
130
- *data_grabed_signal* instance of Signal
131
- *params* list
132
- *settings* instance of pyqtgraph Parameter
133
- *parent* ???
134
- *status* dictionnary
135
- ===================== ===================================
136
-
137
- See Also
138
- --------
139
- send_param_status
140
- """
141
- hardware_averaging = False
142
- live_mode_available = False
143
- data_grabed_signal = Signal(list)
144
- data_grabed_signal_temp = Signal(list)
145
-
146
- params = []
147
-
148
- def __init__(self, parent=None, params_state=None):
149
- QObject.__init__(self)
150
- self.parent_parameters_path = [] # this is to be added in the send_param_status to take into account when the current class instance parameter list is a child of some other class
151
- self.settings = Parameter.create(name='Settings', type='group', children=self.params)
152
- if params_state is not None:
153
- if isinstance(params_state, dict):
154
- self.settings.restoreState(params_state)
155
- elif isinstance(params_state, Parameter):
156
- self.settings.restoreState(params_state.saveState())
157
-
158
- if '0D' in str(self.__class__):
159
- self.plugin_type = '0D'
160
- elif '1D' in str(self.__class__):
161
- self.plugin_type = '1D'
162
- else:
163
- self.plugin_type = '2D'
164
-
165
- self.settings.sigTreeStateChanged.connect(self.send_param_status)
166
-
167
- self.parent = parent
168
- self.status = edict(info="", controller=None, initialized=False)
169
- self.scan_parameters = None
170
-
171
- self.x_axis = None
172
- self.y_axis = None
173
-
174
- self.controller = None
175
-
176
- self.ini_attributes()
177
-
178
- def ini_attributes(self):
179
- """
180
- To be reimplemented in subclass
181
- """
182
- pass
183
-
184
- def ini_detector(self, controller=None):
185
- """
186
- Mandatory
187
- To be reimplemented in subclass
188
- """
189
- raise NotImplemented
190
-
191
- def close(self):
192
- """
193
- Mandatory
194
- To be reimplemented in subclass
195
- """
196
- raise NotImplemented
197
-
198
- def grab_data(self, Naverage=1, **kwargs):
199
- """
200
- Mandatory
201
- To be reimplemented in subclass
202
- """
203
- raise NotImplemented
204
-
205
- def stop(self):
206
- """
207
- Mandatory
208
- To be reimplemented in subclass
209
- """
210
- raise NotImplemented
211
-
212
- def commit_settings(self, param):
213
- """
214
- To be reimplemented in subclass
215
- """
216
- pass
217
-
218
- def update_com(self):
219
- """
220
- If some communications settings have to be re init
221
- To be reimplemented in subclass
222
- -------
223
-
224
- """
225
- pass
226
-
227
- def get_axis(self):
228
- if self.plugin_type == '1D' or self.plugin_type == '2D':
229
- self.emit_x_axis()
230
-
231
- if self.plugin_type == '2D':
232
- self.emit_y_axis()
233
-
234
- def emit_status(self, status):
235
- """
236
- Emit the status signal from the given status.
237
-
238
- =============== ============ =====================================
239
- **Parameters** **Type** **Description**
240
- *status* the status information to transmit
241
- =============== ============ =====================================
242
- """
243
- if self.parent is not None:
244
- self.parent.status_sig.emit(status)
245
- QtWidgets.QApplication.processEvents()
246
- else:
247
- print(*status)
248
-
249
- @Slot(ScanParameters)
250
- def update_scanner(self, scan_parameters):
251
- self.scan_parameters = scan_parameters
252
-
253
-
254
-
255
- @Slot(edict)
256
- def update_settings(self, settings_parameter_dict):
257
- """
258
- Update the settings tree from settings_parameter_dict.
259
- Finally do a commit to activate changes.
260
-
261
- ========================== ============= =====================================================
262
- **Parameters** **Type** **Description**
263
- *settings_parameter_dict* dictionnnary a dictionnary listing path and associated parameter
264
- ========================== ============= =====================================================
265
-
266
- See Also
267
- --------
268
- send_param_status, commit_settings
269
- """
270
- # settings_parameter_dict=edict(path=path,param=param)
271
- try:
272
- path = settings_parameter_dict['path']
273
- param = settings_parameter_dict['param']
274
- change = settings_parameter_dict['change']
275
- try:
276
- self.settings.sigTreeStateChanged.disconnect(self.send_param_status)
277
- except Exception:
278
- pass
279
- if change == 'value':
280
- self.settings.child(*path[1:]).setValue(param.value()) # blocks signal back to main UI
281
- elif change == 'childAdded':
282
- child = Parameter.create(name='tmp')
283
- child.restoreState(param)
284
- self.settings.child(*path[1:]).addChild(child) # blocks signal back to main UI
285
- param = child
286
-
287
- elif change == 'parent':
288
- children = get_param_from_name(self.settings, param.name())
289
-
290
- if children is not None:
291
- path = get_param_path(children)
292
- self.settings.child(*path[1:-1]).removeChild(children)
293
-
294
- self.settings.sigTreeStateChanged.connect(self.send_param_status)
295
-
296
- self.commit_settings(param)
297
- except Exception as e:
298
- self.emit_status(ThreadCommand("Update_Status", [str(e), 'log']))
299
-
300
- def send_param_status(self, param, changes):
301
- """
302
- Check for changes in the given (parameter,change,information) tuple list.
303
- In case of value changed, send the 'update_settings' ThreadCommand with concerned path,data and change as attributes.
304
-
305
- =============== ============================================ ============================
306
- **Parameters** **Type** **Description**
307
- *param* instance of pyqtgraph parameter The parameter to check
308
- *changes* (parameter,change,information) tuple list The changes list to course
309
- =============== ============================================ ============================
310
-
311
- See Also
312
- --------
313
- daq_utils.ThreadCommand
314
- """
315
- for param, change, data in changes:
316
- path = self.settings.childPath(param)
317
- if change == 'childAdded':
318
- # first create a "copy" of the actual parameter and send this "copy", to be restored in the main UI
319
- self.emit_status(ThreadCommand('update_settings',
320
- [self.parent_parameters_path + path, [data[0].saveState(), data[1]],
321
- change])) # send parameters values/limits back to the GUI. Send kind of a copy back the GUI otherwise the child reference will be the same in both th eUI and the plugin so one of them will be removed
322
-
323
- elif change == 'value' or change == 'limits' or change == 'options':
324
- self.emit_status(ThreadCommand('update_settings', [self.parent_parameters_path + path, data,
325
- change])) # send parameters values/limits back to the GUI
326
- elif change == 'parent':
327
- pass
328
-
329
- pass
330
-
331
- def emit_x_axis(self, x_axis=None):
332
- """
333
- Convenience function
334
- Emit the thread command "x_axis" with x_axis as an attribute.
335
-
336
- See Also
337
- --------
338
- daq_utils.ThreadCommand
339
- """
340
- if x_axis is None:
341
- x_axis = self.x_axis
342
- self.emit_status(ThreadCommand("x_axis", [x_axis]))
343
-
344
- def emit_y_axis(self):
345
- """
346
- Emit the thread command "y_axis" with y_axis as an attribute.
347
-
348
- See Also
349
- --------
350
- daq_utils.ThreadCommand
351
- """
352
- self.emit_status(ThreadCommand("y_axis", [self.y_axis]))
353
-
354
- def ini_detector_init(self, old_controller=None, new_controller=None):
355
- """Manage the Master/Slave controller issue
356
-
357
- First initialize the status dictionnary
358
- Then check whether this stage is controlled by a multiaxe controller (to be defined for each plugin)
359
- if it is a multiaxes controller then:
360
- * if it is Master: init the controller here
361
- * if it is Slave: use an already initialized controller (defined in the preset of the dashboard)
362
-
363
- Parameters
364
- ----------
365
- old_controller: object
366
- The particular object that allow the communication with the hardware, in general a python wrapper around the
367
- hardware library. In case of Slave this one comes from a previously initialized plugin
368
- new_controller: object
369
- The particular object that allow the communication with the hardware, in general a python wrapper around the
370
- hardware library. In case of Master it is the new instance of your plugin controller
371
- """
372
- self.status.update(edict(info="", controller=None, initialized=False))
373
- if self.settings.child('controller_status').value() == "Slave":
374
- if old_controller is None:
375
- raise Exception('no controller has been defined externally while this axe is a slave one')
376
- else:
377
- controller = old_controller
378
- else: # Master stage
379
- controller = new_controller
380
- self.controller = controller
381
- return controller
382
-
383
-
384
-
385
- class DAQ_Viewer_TCP_server(DAQ_Viewer_base, TCPServer):
386
- """
387
- ================= ==============================
388
- **Attributes** **Type**
389
- *command_server* instance of Signal
390
- *x_axis* 1D numpy array
391
- *y_axis* 1D numpy array
392
- *data* double precision float array
393
- ================= ==============================
394
-
395
- See Also
396
- --------
397
- utility_classes.DAQ_TCP_server
398
- """
399
- params_GRABBER = [] # parameters of a client grabber
400
- command_server = Signal(list)
401
-
402
- message_list = ["Quit", "Send Data 0D", "Send Data 1D", "Send Data 2D", "Send Data ND", "Status", "Done",
403
- "Server Closed", "Info",
404
- "Infos",
405
- "Info_xml", 'x_axis', 'y_axis']
406
- socket_types = ["GRABBER"]
407
- params = comon_parameters + tcp_parameters
408
-
409
- def __init__(self, parent=None, params_state=None, grabber_type='2D'):
410
- """
411
-
412
- Parameters
413
- ----------
414
- parent
415
- params_state
416
- grabber_type: (str) either '0D', '1D' or '2D'
417
- """
418
- self.client_type = "GRABBER"
419
- DAQ_Viewer_base.__init__(self, parent, params_state) # initialize base class with commom attributes and methods
420
- TCPServer.__init__(self, self.client_type)
421
-
422
- self.x_axis = None
423
- self.y_axis = None
424
- self.data = None
425
- self.grabber_type = grabber_type
426
- self.ind_data = 0
427
- self.data_mock = None
428
-
429
- def command_to_from_client(self, command):
430
- sock: Socket = self.find_socket_within_connected_clients(self.client_type)
431
- if sock is not None: # if client self.client_type is connected then send it the command
432
-
433
- if command == 'x_axis':
434
- x_axis = dict(data=sock.get_array())
435
- x_axis['label'] = sock.get_string()
436
- x_axis['units'] = sock.get_string()
437
- self.x_axis = x_axis.copy()
438
- self.emit_x_axis()
439
- elif command == 'y_axis':
440
- y_axis = dict(data=sock.get_array())
441
- y_axis['label'] = sock.get_string()
442
- y_axis['units'] = sock.get_string()
443
- self.y_axis = y_axis.copy()
444
- self.emit_y_axis()
445
-
446
- else:
447
- self.send_command(sock, command)
448
-
449
- else: # else simulate mock data
450
- if command == "Send Data 0D":
451
- self.set_1D_Mock_data()
452
- self.data_mock = np.array([self.data_mock[0]])
453
- elif command == "Send Data 1D":
454
- self.set_1D_Mock_data()
455
- data = self.data_mock
456
- elif command == "Send Data 2D":
457
- self.set_2D_Mock_data()
458
- data = self.data_mock
459
- self.process_cmds('Done')
460
-
461
- def send_data(self, sock: Socket, data):
462
- """
463
- To match digital and labview, send again a command.
464
-
465
- =============== ============================== ====================
466
- **Parameters** **Type** **Description**
467
- *sock* the socket receipt
468
- *data* double precision float array the data to be sent
469
- =============== ============================== ====================
470
-
471
- See Also
472
- --------
473
- send_command, check_send_data
474
- """
475
- self.send_command(sock, 'Done')
476
-
477
- sock.send_array(data)
478
- # if len(data.shape) == 0:
479
- # Nrow = 1
480
- # Ncol = 0
481
- # elif len(data.shape) == 1:
482
- # Nrow = data.shape[0]
483
- # Ncol = 0
484
- # elif len(data.shape) == 2:
485
- # Nrow = data.shape[0]
486
- # Ncol = data.shape[1]
487
- # data_bytes = data.tobytes()
488
- # check_sended(sock, np.array([len(data_bytes)],
489
- # dtype='>i4').tobytes()) # first send length of data after reshaping as 1D bytes array
490
- # check_sended(sock, np.array([Nrow], dtype='>i4').tobytes()) # then send dimension of lines
491
- # check_sended(sock, np.array([Ncol], dtype='>i4').tobytes()) # then send dimensions of columns
492
- #
493
- # check_sended(sock, data_bytes) # then send data
494
-
495
- def read_data(self, sock: Socket):
496
- """
497
- Read the unsigned 32bits int data contained in the given socket in five steps :
498
- * get back the message
499
- * get the list length
500
- * get the data length
501
- * get the number of row
502
- * get the number of column
503
- * get data
504
-
505
- =============== ===================== =========================
506
- **Parameters** **Type** **Description**
507
- *sock* ??? the socket to be readed
508
- *dtype* numpy unint 32bits ???
509
- =============== ===================== =========================
510
-
511
- See Also
512
- --------
513
- check_received_length
514
- """
515
-
516
- data_list = sock.get_list()
517
-
518
- return data_list
519
-
520
- def data_ready(self, data):
521
- """
522
- Send the grabed data signal. to be written in the detailed plugin using this base class
523
-
524
- for instance:
525
- self.data_grabed_signal.emit([OrderedDict(name=self.client_type,data=[data], type='Data2D')]) #to be overloaded
526
- """
527
- pass
528
-
529
- def command_done(self, command_sock):
530
- try:
531
- sock: Socket = self.find_socket_within_connected_clients(self.client_type)
532
- if sock is not None: # if client self.client_type is connected then send it the command
533
- data = self.read_data(sock)
534
- else:
535
- data = self.data_mock
536
-
537
- if command_sock is None:
538
- # self.data_grabed_signal.emit([OrderedDict(data=[data],name='TCP GRABBER', type='Data2D')]) #to be directly send to a viewer
539
- self.data_ready(data)
540
- # print(data)
541
- else:
542
- self.send_data(command_sock, data) # to be send to a client
543
-
544
- except Exception as e:
545
- self.emit_status(ThreadCommand("Update_Status", [str(e), 'log']))
546
-
547
- def commit_settings(self, param):
548
-
549
- if param.name() in iter_children(self.settings.child(('settings_client')), []):
550
- grabber_socket = \
551
- [client['socket'] for client in self.connected_clients if client['type'] == self.client_type][0]
552
- grabber_socket.send_string('set_info')
553
-
554
- path = get_param_path(param)[2:] # get the path of this param as a list starting at parent 'infos'
555
- grabber_socket.send_list(path)
556
-
557
- # send value
558
- data = ioxml.parameter_to_xml_string(param)
559
- grabber_socket.send_string(data)
560
-
561
- def ini_detector(self, controller=None):
562
- """
563
- | Initialisation procedure of the detector updating the status dictionnary.
564
- |
565
- | Init axes from image , here returns only None values (to tricky to di it with the server and not really
566
- necessary for images anyway)
567
-
568
- See Also
569
- --------
570
- utility_classes.DAQ_TCP_server.init_server, get_xaxis, get_yaxis
571
- """
572
- self.status.update(edict(initialized=False, info="", x_axis=None, y_axis=None, controller=None))
573
- try:
574
- self.settings.child(('infos')).addChildren(self.params_GRABBER)
575
-
576
- self.init_server()
577
-
578
- # %%%%%%% init axes from image , here returns only None values (to tricky to di it with the server and not really necessary for images anyway)
579
- self.x_axis = self.get_xaxis()
580
- self.y_axis = self.get_yaxis()
581
- self.status.x_axis = self.x_axis
582
- self.status.y_axis = self.y_axis
583
- self.status.initialized = True
584
- self.status.controller = self.serversocket
585
- return self.status
586
-
587
- except Exception as e:
588
- self.status.info = getLineInfo() + str(e)
589
- self.status.initialized = False
590
- return self.status
591
-
592
- def close(self):
593
- """
594
- Should be used to uninitialize hardware.
595
-
596
- See Also
597
- --------
598
- utility_classes.DAQ_TCP_server.close_server
599
- """
600
- self.listening = False
601
- self.close_server()
602
-
603
- def get_xaxis(self):
604
- """
605
- Obtain the horizontal axis of the image.
606
-
607
- Returns
608
- -------
609
- 1D numpy array
610
- Contains a vector of integer corresponding to the horizontal camera pixels.
611
- """
612
- pass
613
- return self.x_axis
614
-
615
- def get_yaxis(self):
616
- """
617
- Obtain the vertical axis of the image.
618
-
619
- Returns
620
- -------
621
- 1D numpy array
622
- Contains a vector of integer corresponding to the vertical camera pixels.
623
- """
624
- pass
625
- return self.y_axis
626
-
627
- def grab_data(self, Naverage=1, **kwargs):
628
- """
629
- Start new acquisition.
630
- Grabbed indice is used to keep track of the current image in the average.
631
-
632
- ============== ========== ==============================
633
- **Parameters** **Type** **Description**
634
-
635
- *Naverage* int Number of images to average
636
- ============== ========== ==============================
637
-
638
- See Also
639
- --------
640
- utility_classes.DAQ_TCP_server.process_cmds
641
- """
642
- try:
643
- self.ind_grabbed = 0 # to keep track of the current image in the average
644
- self.Naverage = Naverage
645
- self.process_cmds("Send Data {:s}".format(self.grabber_type))
646
- # self.command_server.emit(["process_cmds","Send Data 2D"])
647
-
648
- except Exception as e:
649
- self.emit_status(ThreadCommand('Update_Status', [getLineInfo() + str(e), "log"]))
650
-
651
- def stop(self):
652
- """
653
- not implemented.
654
- """
655
- pass
656
- return ""
657
-
658
- def set_1D_Mock_data(self):
659
- self.data_mock
660
- x = np.linspace(0, 99, 100)
661
- data_tmp = 10 * gauss1D(x, 50, 10, 1) + 1 * np.random.rand((100))
662
- self.ind_data += 1
663
- self.data_mock = np.roll(data_tmp, self.ind_data)
664
-
665
- def set_2D_Mock_data(self):
666
- self.x_axis = np.linspace(0, 50, 50, endpoint=False)
667
- self.y_axis = np.linspace(0, 30, 30, endpoint=False)
668
- self.data_mock = 10 * gauss2D(self.x_axis, 20, 10,
669
- self.y_axis, 15, 7, 1) + 2 * np.random.rand(len(self.y_axis), len(self.x_axis))
670
-
671
-
672
- if __name__ == '__main__':
673
- prog = DAQ_Viewer_TCP_server()
File without changes