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
@@ -1,2 +0,0 @@
1
- cd "C:\Users\Weber\Labo\Programmes Python\PyMoDAQ_Git\pymodaq\pymodaq\daq_move"
2
- C:\Miniconda3\envs\pyqt5tools\Scripts\pyuic5.exe -x daq_move_gui.ui -o daq_move_gui.py
@@ -1,671 +0,0 @@
1
- from qtpy import QtWidgets
2
- from qtpy.QtCore import QObject, Slot, QThread, Signal, QTimer
3
-
4
- from easydict import EasyDict as edict
5
- import pymodaq.daq_utils.daq_utils as utils
6
- import pymodaq.daq_utils.parameter.utils as putils
7
- from pymodaq.daq_utils.parameter import ioxml
8
- from pyqtgraph.parametertree import Parameter
9
- from pymodaq.daq_utils.daq_utils import ThreadCommand, getLineInfo
10
- from pymodaq.daq_utils.config import Config
11
- from pymodaq.daq_utils.tcp_server_client import TCPServer, tcp_parameters
12
- from pymodaq.daq_utils.messenger import deprecation_msg
13
- import numpy as np
14
- from time import perf_counter
15
-
16
- logger = utils.set_logger(utils.get_module_name(__file__))
17
- config = Config()
18
-
19
-
20
- def comon_parameters(epsilon=config('actuator', 'epsilon_default')):
21
- return [{'title': 'Units:', 'name': 'units', 'type': 'str', 'value': '', 'readonly': True},
22
- {'title': 'Epsilon:', 'name': 'epsilon', 'type': 'float',
23
- 'value': epsilon,
24
- 'tip': 'Differential Value at which the controller considers it reached the target position'},
25
- {'title': 'Timeout (s):', 'name': 'timeout', 'type': 'int',
26
- 'value': config('actuator', 'polling_timeout_s')},
27
- {'title': 'Bounds:', 'name': 'bounds', 'type': 'group', 'children': [
28
- {'title': 'Set Bounds:', 'name': 'is_bounds', 'type': 'bool', 'value': False},
29
- {'title': 'Min:', 'name': 'min_bound', 'type': 'float', 'value': 0, 'default': 0},
30
- {'title': 'Max:', 'name': 'max_bound', 'type': 'float', 'value': 1, 'default': 1}, ]},
31
- {'title': 'Scaling:', 'name': 'scaling', 'type': 'group', 'children': [
32
- {'title': 'Use scaling:', 'name': 'use_scaling', 'type': 'bool', 'value': False,
33
- 'default': False},
34
- {'title': 'Scaling factor:', 'name': 'scaling', 'type': 'float', 'value': 1., 'default': 1.},
35
- {'title': 'Offset factor:', 'name': 'offset', 'type': 'float', 'value': 0., 'default': 0.}]}]
36
-
37
-
38
- MOVE_COMMANDS = ['abs', 'rel', 'home']
39
-
40
-
41
- class MoveCommand:
42
- def __init__(self, move_type, value=0):
43
- if move_type not in MOVE_COMMANDS:
44
- raise ValueError(f'The allowed move types fro an actuator are {MOVE_COMMANDS}')
45
- self.move_type = move_type
46
- self.value = value
47
-
48
-
49
- def comon_parameters_fun(is_multiaxes=False, axes_names=[], master=True, epsilon=config('actuator', 'epsilon_default')):
50
- """Function returning the common and mandatory parameters that should be on the actuator plugin level
51
-
52
- Parameters
53
- ----------
54
- is_multiaxes: bool
55
- If True, display the particular settings to define which axis the controller is driving
56
- axes_names: list of str
57
- The string identifier of every axis the controller can drive
58
- master: bool
59
- If True consider this plugin has to init the controller, otherwise use an already initialized instance
60
- """
61
- params = [{'title': 'MultiAxes:', 'name': 'multiaxes', 'type': 'group', 'visible': is_multiaxes, 'children': [
62
- {'title': 'is Multiaxes:', 'name': 'ismultiaxes', 'type': 'bool', 'value': is_multiaxes,
63
- 'default': False},
64
- {'title': 'Status:', 'name': 'multi_status', 'type': 'list', 'value': 'Master' if master else 'Slave',
65
- 'limits': ['Master', 'Slave']},
66
- {'title': 'Axis:', 'name': 'axis', 'type': 'list', 'limits': axes_names},
67
-
68
- ]}] + comon_parameters(epsilon)
69
- return params
70
-
71
-
72
- params = [
73
- {'title': 'Main Settings:', 'name': 'main_settings', 'type': 'group', 'children': [
74
- {'title': 'Actuator type:', 'name': 'move_type', 'type': 'str', 'value': '', 'readonly': True},
75
- {'title': 'Controller ID:', 'name': 'controller_ID', 'type': 'int', 'value': 0, 'default': 0},
76
- {'title': 'TCP/IP options:', 'name': 'tcpip', 'type': 'group', 'visible': True, 'expanded': False,
77
- 'children': [
78
- {'title': 'Connect to server:', 'name': 'connect_server', 'type': 'bool_push', 'label': 'Connect',
79
- 'value': False},
80
- {'title': 'Connected?:', 'name': 'tcp_connected', 'type': 'led', 'value': False},
81
- {'title': 'IP address:', 'name': 'ip_address', 'type': 'str',
82
- 'value': config('network', 'tcp-server', 'ip')},
83
- {'title': 'Port:', 'name': 'port', 'type': 'int', 'value': config('network', 'tcp-server', 'port')},
84
- ]},
85
- ]},
86
- {'title': 'Actuator Settings:', 'name': 'move_settings', 'type': 'group'}
87
- ]
88
-
89
-
90
- def main(plugin_file, init=True, title='test'):
91
- """
92
- this method start a DAQ_Move object with this defined plugin as actuator
93
- Returns
94
- -------
95
-
96
- """
97
- import sys
98
- from qtpy import QtWidgets
99
- from pymodaq.daq_move.daq_move_main import DAQ_Move
100
- from pathlib import Path
101
- app = QtWidgets.QApplication(sys.argv)
102
- if config('style', 'darkstyle'):
103
- import qdarkstyle
104
- app.setStyleSheet(qdarkstyle.load_stylesheet())
105
-
106
- Form = QtWidgets.QWidget()
107
- prog = DAQ_Move(Form, title=title,)
108
- Form.show()
109
- prog.actuator = Path(plugin_file).stem[9:]
110
- if init:
111
- prog.init()
112
-
113
- sys.exit(app.exec_())
114
-
115
-
116
- class DAQ_Move_base(QObject):
117
- """ The base class to be inherited by all actuator modules
118
-
119
- This base class implements all necessary parameters and methods for the plugin to communicate with its parent (the
120
- DAQ_Move module)
121
-
122
- Parameters
123
- ----------
124
- parent : DAQ_Move_stage instance (see daq_viewer_main module)
125
- params_state : Parameter instance (pyqtgraph) from which the module will get the initial settings (as defined in the managers)
126
-
127
-
128
- :ivar Move_Done_signal: Signal signal represented by a float. Is emitted each time the hardware reached the target
129
- position within the epsilon precision (see comon_parameters variable)
130
-
131
- :ivar controller: the object representing the hardware in the plugin. Used to access hardware functionality
132
-
133
- :ivar status: easydict instance to set information (str), controller object, stage object (if required) and initialized
134
- state (bool) to return to parent after initialization
135
-
136
- :ivar settings: Parameter instance representing the hardware settings defined from the params attribute. Modifications
137
- on the GUI settings will be transferred to this attribute. It stores at all times the current state of the hardware/plugin
138
-
139
- :ivar params: class level attribute. List of dict used to create a Parameter object. Its definition on the class level enable
140
- the automatic update of the GUI settings when changing plugins (even in managers mode creation). To be populated
141
- on the plugin level as the base class does't represents a real hardware
142
-
143
- :ivar is_multiaxes: class level attribute (bool). Defines if the plugin controller controls multiple axes. If True, one has to define
144
- a Master instance of this plugin and slave instances of this plugin (all sharing the same controller_ID Parameter)
145
-
146
- :ivar current_position: (float) stores the current position after each call to the get_actuator_value in the child module
147
-
148
- :ivar target_position: (float) stores the target position the controller should reach within epsilon
149
-
150
- """
151
-
152
- Move_Done_signal = Signal(float)
153
- is_multiaxes = False
154
- stage_names = [] #deprecated
155
- axes_names = []
156
- params = []
157
- _controller_units = ''
158
- _epsilon = 1
159
-
160
- def __init__(self, parent=None, params_state=None):
161
- QObject.__init__(self) # to make sure this is the parent class
162
- self.move_is_done = False
163
- self.parent = parent
164
- self.shamrock_controller = None
165
- self.stage = None
166
- self.status = edict(info="", controller=None, stage=None, initialized=False)
167
- self.current_position = 0.
168
- self.target_position = 0.
169
- self._ispolling = True
170
- self.parent_parameters_path = [] # this is to be added in the send_param_status to take into account when the
171
- # current class instance parameter list is a child of some other class
172
- self.settings = Parameter.create(name='Settings', type='group', children=self.params)
173
- if params_state is not None:
174
- if isinstance(params_state, dict):
175
- self.settings.restoreState(params_state)
176
- elif isinstance(params_state, Parameter):
177
- self.settings.restoreState(params_state.saveState())
178
-
179
- self.settings.sigTreeStateChanged.connect(self.send_param_status)
180
- self.controller_units = self._controller_units
181
- self.controller = None
182
- #
183
- # if self.settings['epsilon'] == config('actuator', 'epsilon_default'):
184
- # self.settings.child('epsilon').setValue(self._epsilon)
185
-
186
- self.poll_timer = QTimer()
187
- self.poll_timer.setInterval(config('actuator', 'polling_interval_ms'))
188
- self._poll_timeout = config('actuator', 'polling_timeout_s')
189
- self.poll_timer.timeout.connect(self.check_target_reached)
190
-
191
- self.ini_attributes()
192
-
193
- def ini_attributes(self):
194
- pass
195
-
196
- def ini_stage_init(self, old_controller=None, new_controller=None):
197
- """Manage the Master/Slave controller issue
198
-
199
- First initialize the status dictionnary
200
- Then check whether this stage is controlled by a multiaxe controller (to be defined for each plugin)
201
- if it is a multiaxes controller then:
202
- * if it is Master: init the controller here
203
- * if it is Slave: use an already initialized controller (defined in the preset of the dashboard)
204
-
205
- Parameters
206
- ----------
207
- old_controller: object
208
- The particular object that allow the communication with the hardware, in general a python wrapper around the
209
- hardware library. In case of Slave this one comes from a previously initialized plugin
210
- new_controller: object
211
- The particular object that allow the communication with the hardware, in general a python wrapper around the
212
- hardware library. In case of Master it is the new instance of your plugin controller
213
- """
214
- self.status.update(edict(info="", controller=None, initialized=False))
215
- if self.settings['multiaxes', 'ismultiaxes'] and self.settings['multiaxes', 'multi_status'] == "Slave":
216
- if old_controller is None:
217
- raise Exception('no controller has been defined externally while this axe is a slave one')
218
- else:
219
- controller = old_controller
220
- else: # Master stage
221
- controller = new_controller
222
- self.controller = controller
223
- return controller
224
-
225
- @property
226
- def controller_units(self):
227
- return self._controller_units
228
-
229
- @controller_units.setter
230
- def controller_units(self, units: str = ''):
231
- self._controller_units = units
232
- try:
233
- self.settings.child('units').setValue(units)
234
- except Exception:
235
- pass
236
-
237
- @property
238
- def ispolling(self):
239
- return self._ispolling
240
-
241
- @ispolling.setter
242
- def ispolling(self, polling=True):
243
- self._ispolling = polling
244
-
245
- def check_bound(self, position):
246
- """
247
-
248
- Parameters
249
- ----------
250
- position
251
-
252
- Returns
253
- -------
254
-
255
- """
256
- if self.settings.child('bounds', 'is_bounds').value():
257
- if position > self.settings.child('bounds', 'max_bound').value():
258
- position = self.settings.child('bounds', 'max_bound').value()
259
- self.emit_status(ThreadCommand('outofbounds', []))
260
- elif position < self.settings.child('bounds', 'min_bound').value():
261
- position = self.settings.child('bounds', 'min_bound').value()
262
- self.emit_status(ThreadCommand('outofbounds', []))
263
- return position
264
-
265
- def get_actuator_value(self):
266
- if hasattr(self, 'check_position'):
267
- deprecation_msg('check_position method in plugins is deprecated, use get_actuator_value',3)
268
- return self.check_position()
269
- else:
270
- raise NotImplementedError
271
-
272
- def move_abs(self, value):
273
- if hasattr(self, 'move_Abs'):
274
- deprecation_msg('move_Abs method in plugins is deprecated, use move_abs',3)
275
- self.move_Abs(value)
276
- else:
277
- raise NotImplementedError
278
-
279
- def move_rel(self, value):
280
- if hasattr(self, 'move_Rel'):
281
- deprecation_msg('move_Rel method in plugins is deprecated, use move_rel',3)
282
- self.move_Rel(value)
283
- else:
284
- raise NotImplementedError
285
-
286
- def move_home(self):
287
- if hasattr(self, 'move_Home'):
288
- deprecation_msg('move_Home method in plugins is deprecated, use move_home', 3)
289
- self.move_Home()
290
- else:
291
- raise NotImplementedError
292
-
293
- def emit_status(self, status):
294
- """
295
- | Emit the statut signal from the given status parameter.
296
- |
297
- | The signal is sended to the gui to update the user interface.
298
-
299
- =============== ===================== ========================================================================================================================================
300
- **Parameters** **Type** **Description**
301
- *status* ordered dictionnary dictionnary containing keys:
302
- * *info* : string displaying various info
303
- * *controller*: instance of the controller object in order to control other axes without the need to init the same controller twice
304
- * *stage*: instance of the stage (axis or whatever) object
305
- * *initialized*: boolean indicating if initialization has been done corretly
306
- =============== ===================== ========================================================================================================================================
307
- """
308
- if self.parent is not None:
309
- self.parent.status_sig.emit(status)
310
- QtWidgets.QApplication.processEvents()
311
- else:
312
- print(status)
313
-
314
- def commit_settings(self, param):
315
- """
316
- to subclass to transfer parameters to hardware
317
- """
318
- pass
319
-
320
- def commit_common_settings(self, param):
321
- pass
322
-
323
- def get_position_with_scaling(self, pos):
324
- """
325
- Get the current position from the hardware with scaling conversion.
326
-
327
- =============== ========= =====================
328
- **Parameters** **Type** **Description**
329
- *pos* float the current position
330
- =============== ========= =====================
331
-
332
- Returns
333
- =======
334
- float
335
- the computed position.
336
- """
337
- if self.settings.child('scaling', 'use_scaling').value():
338
- pos = (pos - self.settings.child('scaling', 'offset').value()) * self.settings.child('scaling',
339
- 'scaling').value()
340
- return pos
341
-
342
- def move_done(self, position=None): # the position argument is just there to match some signature of child classes
343
- """
344
- | Emit a move done signal transmitting the float position to hardware.
345
- | The position argument is just there to match some signature of child classes.
346
-
347
- =============== ========== =============================================================================
348
- **Arguments** **Type** **Description**
349
- *position* float The position argument is just there to match some signature of child classes
350
- =============== ========== =============================================================================
351
-
352
- """
353
- if position is None:
354
- position = self.get_actuator_value()
355
- self.Move_Done_signal.emit(position)
356
- self.move_is_done = True
357
-
358
- def poll_moving(self):
359
- """
360
- Poll the current moving. In case of timeout emit the raise timeout Thread command.
361
-
362
- See Also
363
- --------
364
- DAQ_utils.ThreadCommand, move_done
365
- """
366
- if 'TCPServer' not in self.__class__.__name__:
367
- self.start_time = perf_counter()
368
- if self.ispolling:
369
- self.poll_timer.start()
370
- else:
371
- self.current_position = self.get_actuator_value()
372
- logger.debug(f'Current position: {self.current_position}')
373
- self.move_done(self.current_position)
374
-
375
- def check_target_reached(self):
376
- if np.abs(self.current_position - self.target_position) > self.settings.child('epsilon').value():
377
- logger.debug(f'Check move_is_done: {self.move_is_done}')
378
- if self.move_is_done:
379
- self.emit_status(ThreadCommand('Move has been stopped'))
380
- logger.info(f'Move has been stopped')
381
-
382
- self.current_position = self.get_actuator_value()
383
- self.emit_status(ThreadCommand('check_position', [self.current_position]))
384
- logger.debug(f'Current position: {self.current_position}')
385
-
386
- if perf_counter() - self.start_time >= self.settings.child('timeout').value():
387
- self.poll_timer.stop()
388
- self.emit_status(ThreadCommand('raise_timeout'))
389
- logger.info(f'Timeout activated')
390
- else:
391
- self.poll_timer.stop()
392
- logger.debug(f'Current position: {self.current_position}')
393
- self.move_done(self.current_position)
394
-
395
- def send_param_status(self, param, changes):
396
- """
397
- | Send changes value updates to the gui to update consequently the User Interface.
398
- | The message passing is made via the Thread Command "update_settings".
399
-
400
- =============== =================================== ==================================================
401
- **Parameters** **Type** **Description**
402
- *param* instance of pyqtgraph parameter The parameter to be checked
403
- *changes* (parameter,change,infos)tuple list The (parameter,change,infos) list to be treated
404
- =============== =================================== ==================================================
405
-
406
- See Also
407
- ========
408
- DAQ_utils.ThreadCommand
409
- """
410
-
411
- for param, change, data in changes:
412
- path = self.settings.childPath(param)
413
- if change == 'childAdded':
414
- self.emit_status(ThreadCommand('update_settings',
415
- [self.parent_parameters_path + path, [data[0].saveState(), data[1]],
416
- 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
417
- elif change == 'value' or change == 'limits' or change == 'options':
418
- self.emit_status(ThreadCommand('update_settings', [self.parent_parameters_path + path, data,
419
- change])) # send parameters values/limits back to the GUI
420
- elif change == 'parent':
421
- pass
422
-
423
- def set_position_with_scaling(self, pos):
424
- """
425
- Set the current position from the parameter and hardware with scaling conversion.
426
-
427
- =============== ========= ==========================
428
- **Parameters** **Type** **Description**
429
- *pos* float the position to be setted
430
- =============== ========= ==========================
431
-
432
- Returns
433
- =======
434
- float
435
- the computed position.
436
- """
437
- if self.settings.child('scaling', 'use_scaling').value():
438
- pos = pos / self.settings.child('scaling', 'scaling').value() + self.settings.child('scaling',
439
- 'offset').value()
440
- return pos
441
-
442
- def set_position_relative_with_scaling(self, pos):
443
- """
444
- Set the scaled positions in case of relative moves
445
- """
446
- if self.settings.child('scaling', 'use_scaling').value():
447
- pos = pos / self.settings.child('scaling', 'scaling').value()
448
- return pos
449
-
450
- @Slot(edict)
451
- def update_settings(self, settings_parameter_dict): # settings_parameter_dict=edict(path=path,param=param)
452
- """
453
- Receive the settings_parameter signal from the param_tree_changed method and make hardware updates of mmodified values.
454
-
455
- ========================== =========== ==========================================================================================================
456
- **Arguments** **Type** **Description**
457
- *settings_parameter_dict* dictionnary Dictionnary with the path of the parameter in hardware structure as key and the parameter name as element
458
- ========================== =========== ==========================================================================================================
459
-
460
- See Also
461
- --------
462
- send_param_status, commit_settings
463
- """
464
- path = settings_parameter_dict['path']
465
- param = settings_parameter_dict['param']
466
- change = settings_parameter_dict['change']
467
- try:
468
- self.settings.sigTreeStateChanged.disconnect(self.send_param_status)
469
- except Exception:
470
- pass
471
- if change == 'value':
472
- self.settings.child(*path[1:]).setValue(param.value()) # blocks signal back to main UI
473
- elif change == 'childAdded':
474
- child = Parameter.create(name='tmp')
475
- child.restoreState(param)
476
- self.settings.child(*path[1:]).addChild(child) # blocks signal back to main UI
477
- param = child
478
-
479
- elif change == 'parent':
480
- children = putils.get_param_from_name(self.settings, param.name())
481
-
482
- if children is not None:
483
- path = putils.get_param_path(children)
484
- self.settings.child(*path[1:-1]).removeChild(children)
485
-
486
- self.settings.sigTreeStateChanged.connect(self.send_param_status)
487
- self.commit_common_settings(param)
488
- self.commit_settings(param)
489
-
490
-
491
- class DAQ_Move_TCP_server(DAQ_Move_base, TCPServer):
492
- """
493
- ================= ==============================
494
- **Attributes** **Type**
495
- *command_server* instance of Signal
496
- *x_axis* 1D numpy array
497
- *y_axis* 1D numpy array
498
- *data* double precision float array
499
- ================= ==============================
500
-
501
- See Also
502
- --------
503
- utility_classes.DAQ_TCP_server
504
- """
505
- params_client = [] # parameters of a client grabber
506
- command_server = Signal(list)
507
-
508
- message_list = ["Quit", "Status", "Done", "Server Closed", "Info", "Infos", "Info_xml", "move_abs",
509
- 'move_home', 'move_rel', 'get_actuator_value', 'stop_motion', 'position_is', 'move_done']
510
- socket_types = ["ACTUATOR"]
511
- params = comon_parameters() + tcp_parameters
512
-
513
- def __init__(self, parent=None, params_state=None):
514
- """
515
-
516
- Parameters
517
- ----------
518
- parent
519
- params_state
520
- """
521
- self.client_type = "ACTUATOR"
522
- DAQ_Move_base.__init__(self, parent, params_state) # initialize base class with commom attributes and methods
523
- self.settings.child(('bounds')).hide()
524
- self.settings.child(('scaling')).hide()
525
- self.settings.child(('epsilon')).setValue(1)
526
-
527
- TCPServer.__init__(self, self.client_type)
528
-
529
- def command_to_from_client(self, command):
530
- sock = self.find_socket_within_connected_clients(self.client_type)
531
- if sock is not None: # if client 'ACTUATOR' is connected then send it the command
532
-
533
- if command == 'position_is':
534
- pos = sock.get_scalar()
535
-
536
- pos = self.get_position_with_scaling(pos)
537
- self.current_position = pos
538
- self.emit_status(ThreadCommand('get_actuator_value', [pos]))
539
-
540
- elif command == 'move_done':
541
- pos = sock.get_scalar()
542
- pos = self.get_position_with_scaling(pos)
543
- self.current_position = pos
544
- self.emit_status(ThreadCommand('move_done', [pos]))
545
- else:
546
- self.send_command(sock, command)
547
-
548
- def commit_settings(self, param):
549
-
550
- if param.name() in putils.iter_children(self.settings.child(('settings_client')), []):
551
- actuator_socket = [client['socket'] for client in self.connected_clients if client['type'] == 'ACTUATOR'][0]
552
- actuator_socket.send_string('set_info')
553
- path = putils.get_param_path(param)[2:]
554
- # get the path of this param as a list starting at parent 'infos'
555
-
556
- actuator_socket.send_list(path)
557
-
558
- # send value
559
- data = ioxml.parameter_to_xml_string(param)
560
- actuator_socket.send_string(data)
561
-
562
- def ini_stage(self, controller=None):
563
- """
564
- | Initialisation procedure of the detector updating the status dictionnary.
565
- |
566
- | Init axes from image , here returns only None values (to tricky to di it with the server and not really 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_client)
575
-
576
- self.init_server()
577
-
578
- self.settings.child('units').hide()
579
- self.settings.child('epsilon').hide()
580
-
581
- self.status.info = 'TCP Server actuator'
582
- self.status.initialized = True
583
- self.status.controller = self.serversocket
584
- return self.status
585
-
586
- except Exception as e:
587
- self.status.info = getLineInfo() + str(e)
588
- self.status.initialized = False
589
- return self.status
590
-
591
- def close(self):
592
- """
593
- Should be used to uninitialize hardware.
594
-
595
- See Also
596
- --------
597
- utility_classes.DAQ_TCP_server.close_server
598
- """
599
- self.listening = False
600
- self.close_server()
601
-
602
- def move_Abs(self, position):
603
- """
604
-
605
- """
606
- position = self.check_bound(position)
607
- self.target_position = position
608
-
609
- position = self.set_position_with_scaling(position)
610
-
611
- sock = self.find_socket_within_connected_clients(self.client_type)
612
- if sock is not None: # if client self.client_type is connected then send it the command
613
- sock.send_string('move_abs')
614
- sock.send_scalar(position)
615
-
616
- def move_Rel(self, position):
617
- position = self.check_bound(self.current_position + position) - self.current_position
618
- self.target_position = position + self.current_position
619
-
620
- position = self.set_position_relative_with_scaling(position)
621
- sock = self.find_socket_within_connected_clients(self.client_type)
622
- if sock is not None: # if client self.client_type is connected then send it the command
623
- sock.send_string('move_rel')
624
- sock.send_scalar(position)
625
-
626
- def move_Home(self):
627
- """
628
- Make the absolute move to original position (0).
629
-
630
- See Also
631
- --------
632
- move_Abs
633
- """
634
- sock = self.find_socket_within_connected_clients(self.client_type)
635
- if sock is not None: # if client self.client_type is connected then send it the command
636
- sock.send_string('move_home')
637
-
638
- def get_actuator_value(self):
639
- """
640
- Get the current hardware position with scaling conversion given by get_position_with_scaling.
641
-
642
- See Also
643
- --------
644
- daq_move_base.get_position_with_scaling, daq_utils.ThreadCommand
645
- """
646
- sock = self.find_socket_within_connected_clients(self.client_type)
647
- if sock is not None: # if client self.client_type is connected then send it the command
648
- self.send_command(sock, 'get_actuator_value')
649
-
650
- return self.current_position
651
-
652
- def stop_motion(self):
653
- """
654
- See Also
655
- --------
656
- daq_move_base.move_done
657
- """
658
- sock = self.find_socket_within_connected_clients(self.client_type)
659
- if sock is not None: # if client self.client_type is connected then send it the command
660
- self.send_command(sock, 'stop_motion')
661
-
662
- def stop(self):
663
- """
664
- not implemented.
665
- """
666
- pass
667
- return ""
668
-
669
-
670
- if __name__ == '__main__':
671
- test = DAQ_Move_base()