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,1042 +0,0 @@
1
-
2
- from qtpy import QtGui, QtWidgets
3
- from qtpy.QtCore import QObject, Slot, QThread, Signal, QLocale, Qt
4
- import sys
5
- from pymodaq.daq_move.daq_move_gui import Ui_Form
6
-
7
- from pymodaq.daq_move.utility_classes import params as daq_move_params
8
- from pymodaq.daq_move.utility_classes import MoveCommand, DAQ_Move_base
9
- from pathlib import Path
10
-
11
- from pyqtgraph.parametertree import Parameter, ParameterTree
12
- from pymodaq.daq_utils.parameter import ioxml
13
- from pymodaq.daq_utils.parameter import utils as putils
14
-
15
- # must be imported to register proper custom parameter types
16
- from pymodaq.daq_utils.parameter import pymodaq_ptypes
17
-
18
- from pymodaq.daq_utils.daq_utils import ThreadCommand
19
- from easydict import EasyDict as edict
20
- from pymodaq.daq_utils.tcp_server_client import TCPClient
21
- from pymodaq.daq_utils import daq_utils as utils
22
- from pymodaq.daq_utils.exceptions import ActuatorError
23
- from pymodaq.daq_utils import config as config_mod
24
- local_path = config_mod.get_set_local_dir()
25
- sys.path.append(local_path)
26
-
27
- logger = utils.set_logger(utils.get_module_name(__file__))
28
- config = config_mod.Config()
29
- DAQ_Move_Stage_type = utils.get_plugins('daq_move')
30
-
31
-
32
- class DAQ_Move(Ui_Form, QObject):
33
- """
34
- | DAQ_Move object is a module used to control one motor from a specified list.
35
- |
36
- | Preset is an optional list of dicts used to managers programatically settings such as the name of the controller from the list of possible controllers, COM address...
37
- |
38
- | Init is a boolean to tell the programm to initialize the controller at the start of the programm given the managers options
39
-
40
- ========================= =================================================
41
- **Attributes** **Type**
42
- *command_stage* instance of Signal
43
- *move_done_signal* instance of Signal
44
- *update_settings_signal* instance of Signal
45
- *status_signal* instance of Signal
46
- *bounds_signal* instance of Signal
47
- *params* dictionnary list
48
- *ui* instance of UI_Form
49
- *parent* QObject
50
- *title* string
51
- *wait_time* int
52
- *initialized_state* boolean
53
- *Move_done* boolean
54
- *controller* instance of the specific controller object
55
- *stage* instance of the stage (axis or wathever) object
56
- *current_position* float
57
- *target_position* float
58
- *wait_position_flag* boolean
59
- *stage_types* string list
60
- ========================= =================================================
61
-
62
- See Also
63
- --------
64
- set_enabled_move_buttons, set_setting_tree, stage_changed, quit_fun, ini_stage_fun, move_Abs, move_Rel, move_Home, get_position, stop_Motion, show_settings, show_fine_tuning
65
-
66
- References
67
- ----------
68
- QLocale, QObject, Signal, QStatusBar, ParameterTree
69
- """
70
- init_signal = Signal(bool)
71
- command_stage = Signal(ThreadCommand)
72
- command_tcpip = Signal(ThreadCommand)
73
- move_done_signal = Signal(str, float)
74
- # to be used in external program to make sure the move has been done, export the current position. str refer
75
- # to the unique title given to the module
76
- move_moving_signal = Signal(str, float)
77
- # to be used in external program to make sure the move has been done, export the current position. str refer
78
- # to the unique title given to the module
79
- update_settings_signal = Signal(edict)
80
- status_signal = Signal(str)
81
- bounds_signal = Signal(bool)
82
- params = daq_move_params
83
-
84
- def __init__(self, parent, title="pymodaq Move", init=False):
85
- """DAQ_Move object is a module used to control one motor from a specified list.
86
- managers is an optional list of dicts used to managers programatically settings such as the name of the
87
- controller from the list of possible controllers, COM address...
88
- init is a boolean to tell the programm to initialize the controller at the start of the programm given the
89
- managers options
90
- To differenciate various instance of this class
91
- """
92
- self.logger = utils.set_logger(f'{logger.name}.{title}')
93
- self.logger.info(f'Initializing DAQ_Move: {title}')
94
-
95
- super().__init__()
96
-
97
- here = Path(__file__).parent
98
- splash = QtGui.QPixmap(str(here.parent.joinpath('splash.png')))
99
- self.splash_sc = QtWidgets.QSplashScreen(splash, Qt.WindowStaysOnTopHint)
100
-
101
- self.ui = Ui_Form()
102
- self.ui.setupUi(parent)
103
- self.ui.Moveto_pb_bis_2.setVisible(False)
104
- self.parent = parent
105
- self.ui.title_label.setText(title)
106
- self.title = title
107
- self.ui.statusbar = QtWidgets.QStatusBar(parent)
108
- self.ui.StatusBarLayout.addWidget(self.ui.statusbar)
109
- self.ui.statusbar.setMaximumHeight(20)
110
-
111
- self.send_to_tcpip = False
112
- self.tcpclient_thread = None
113
-
114
- self.wait_time = 1000
115
- self.ui.Ini_state_LED
116
-
117
- self.ui.Ini_state_LED.clickable = False
118
- self.ui.Ini_state_LED.set_as_false()
119
- self.ui.Move_Done_LED.clickable = False
120
- self.ui.Move_Done_LED.set_as_false()
121
- self.initialized_state = False
122
- self.ui.Current_position_sb.setReadOnly(False)
123
- self.move_done_bool = True
124
-
125
- # ###########IMPORTANT############################
126
- self.controller = None # the hardware controller/set after initialization and to be used by other modules
127
- # ################################################
128
-
129
- self.current_position = 0
130
- self.target_position = 0
131
- self.wait_position_flag = True
132
-
133
- self.ui.Current_position_sb.setValue(self.current_position)
134
- self.set_enabled_move_buttons(enable=False)
135
- self.ui.groupBox.hide()
136
- self.parent.resize(150, 200)
137
-
138
- # #Setting stages types
139
- self.stage_types = [mov['name'] for mov in DAQ_Move_Stage_type]
140
- self.ui.Stage_type_combo.clear()
141
- self.ui.Stage_type_combo.addItems(self.stage_types)
142
-
143
- # create main parameter tree
144
- self.ui.settings_tree = ParameterTree()
145
- self.ui.verticalLayout_2.addWidget(self.ui.settings_tree)
146
- self.ui.settings_tree.setMinimumWidth(300)
147
-
148
- self.settings = Parameter.create(name='Settings', type='group', children=self.params)
149
- self.ui.settings_tree.setParameters(self.settings, showTop=False)
150
-
151
- # connecting from tree
152
- self.settings.sigTreeStateChanged.connect(
153
- self.parameter_tree_changed) # any changes on the settings will update accordingly the detector
154
- self.ui.settings_tree.setVisible(False)
155
- self.set_setting_tree()
156
-
157
- QtWidgets.QApplication.processEvents()
158
- # #Connecting buttons:
159
- self.ui.Stage_type_combo.currentIndexChanged.connect(self.set_setting_tree)
160
- self.ui.Stage_type_combo.currentIndexChanged.connect(self.stage_changed)
161
-
162
- self.ui.Quit_pb.clicked.connect(self.quit_fun)
163
- self.ui.IniStage_pb.clicked.connect(self.ini_stage_fun)
164
-
165
- self.update_status("Ready", wait_time=self.wait_time)
166
- self.ui.Move_Abs_pb.clicked.connect(lambda: self.move_Abs(self.ui.Abs_position_sb.value()))
167
- self.ui.Move_Rel_plus_pb.clicked.connect(lambda: self.move_Rel(self.ui.Rel_position_sb.value()))
168
- self.ui.Move_Rel_minus_pb.clicked.connect(lambda: self.move_Rel(-self.ui.Rel_position_sb.value()))
169
- self.ui.Find_Home_pb.clicked.connect(self.move_Home)
170
- self.ui.Get_position_pb.clicked.connect(self.get_position)
171
- self.ui.Stop_pb.clicked.connect(self.stop_Motion)
172
-
173
- self.ui.parameters_pb.clicked.connect(self.show_settings)
174
- self.ui.fine_tuning_pb.clicked.connect(self.show_fine_tuning)
175
- self.ui.Abs_position_sb.valueChanged.connect(self.ui.Abs_position_sb_bis.setValue)
176
- self.ui.Abs_position_sb_bis.valueChanged.connect(self.ui.Abs_position_sb.setValue)
177
- self.ui.Moveto_pb_bis.clicked.connect(lambda: self.move_Abs(self.ui.Abs_position_sb_bis.value()))
178
-
179
- # initialize the controller if init=True
180
- if init:
181
- self.ui.IniStage_pb.click()
182
-
183
- @property
184
- def actuator(self):
185
- return self.ui.Stage_type_combo.currentText()
186
-
187
- @actuator.setter
188
- def actuator(self, actuator):
189
- self.ui.Stage_type_combo.setCurrentText(actuator)
190
- if self.actuator != actuator:
191
- raise ActuatorError(f'{actuator} is not a valid installed actuator: {self.stage_types}')
192
-
193
- def init(self):
194
- self.ui.IniStage_pb.click()
195
-
196
- def ini_stage_fun(self):
197
- """
198
- Init :
199
- * a DAQ_move_stage instance if not exists
200
- * a linked thread connected by signal to the DAQ_move_main instance
201
-
202
- See Also
203
- --------
204
- set_enabled_move_buttons, DAQ_utils.ThreadCommand, DAQ_Move_stage, DAQ_Move_stage.queue_command, thread_status, DAQ_Move_stage.update_settings, update_status
205
- """
206
- try:
207
- if not self.ui.IniStage_pb.isChecked():
208
- try:
209
- self.set_enabled_move_buttons(enable=False)
210
- self.ui.Stage_type_combo.setEnabled(True)
211
- self.ui.Ini_state_LED.set_as_false()
212
- self.command_stage.emit(ThreadCommand(command="close"))
213
- except Exception as e:
214
- self.logger.exception(str(e))
215
-
216
- else:
217
- self.stage_name = self.ui.Stage_type_combo.currentText()
218
- stage = DAQ_Move_stage(self.stage_name, self.current_position, self.title)
219
- self.stage_thread = QThread()
220
- stage.moveToThread(self.stage_thread)
221
-
222
- self.command_stage[ThreadCommand].connect(stage.queue_command)
223
- stage.status_sig[ThreadCommand].connect(self.thread_status)
224
- self.update_settings_signal[edict].connect(stage.update_settings)
225
-
226
- self.stage_thread.stage = stage
227
- self.stage_thread.start()
228
-
229
- self.ui.Stage_type_combo.setEnabled(False)
230
- self.command_stage.emit(ThreadCommand(command="ini_stage",
231
- attributes=[self.settings.child(('move_settings')).saveState(),
232
- self.controller]))
233
-
234
- except Exception as e:
235
- self.logger.exception(str(e))
236
- self.set_enabled_move_buttons(enable=False)
237
-
238
- def get_position(self):
239
- """
240
- Get the current position from the launched thread via the "check_position" Thread Command.
241
-
242
- See Also
243
- --------
244
- update_status, DAQ_utils.ThreadCommand
245
- """
246
- try:
247
- self.command_stage.emit(ThreadCommand(command="check_position"))
248
-
249
- except Exception as e:
250
- self.logger.exception(str(e))
251
-
252
- def move(self, move_command: MoveCommand):
253
- """Public method to trigger the correct action on the actuator. Should be used by external applications"""
254
- if move_command.move_type == 'abs':
255
- self.move_Abs(move_command.value)
256
- elif move_command.move_type == 'rel':
257
- self.move_Rel(move_command.value)
258
- elif move_command.move_type == 'home':
259
- self.move_Home(move_command.value)
260
-
261
- def move_Abs(self, position, send_to_tcpip=False):
262
- """
263
- | Make the move from an absolute position.
264
- |
265
- | The move is made if target is in bounds, sending the thread command "Reset_Stop_Motion" and "move_Abs".
266
-
267
- =============== ========== ===========================================
268
- **Parameters** **Type** **Description**
269
-
270
- *position* float The absolute target position of the move
271
- =============== ========== ===========================================
272
-
273
- See Also
274
- --------
275
- update_status, check_out_bounds, DAQ_utils.ThreadCommand
276
- """
277
- try:
278
- self.send_to_tcpip = send_to_tcpip
279
- if not (position == self.current_position and self.stage_name == "Thorlabs_Flipper"):
280
- self.ui.Move_Done_LED.set_as_false()
281
- self.move_done_bool = False
282
- self.target_position = position
283
- self.update_status("Moving", wait_time=self.wait_time)
284
- # self.check_out_bounds(position)
285
- self.command_stage.emit(ThreadCommand(command="Reset_Stop_Motion"))
286
- self.command_stage.emit(ThreadCommand(command="move_Abs", attributes=[position]))
287
-
288
- except Exception as e:
289
- self.logger.exception(str(e))
290
-
291
- def move_Home(self, send_to_tcpip=False):
292
- """
293
- Send the thread commands "Reset_Stop_Motion" and "move_Home" and update the status.
294
-
295
- See Also
296
- --------
297
- update_status, DAQ_utils.ThreadCommand
298
- """
299
- self.send_to_tcpip = send_to_tcpip
300
- try:
301
- self.ui.Move_Done_LED.set_as_false()
302
- self.move_done_bool = False
303
- self.update_status("Moving", wait_time=self.wait_time)
304
- self.command_stage.emit(ThreadCommand(command="Reset_Stop_Motion"))
305
- self.command_stage.emit(ThreadCommand(command="move_Home"))
306
-
307
- except Exception as e:
308
- self.logger.exception(str(e))
309
-
310
- def move_Rel_p(self):
311
- self.ui.Move_Rel_plus_pb.click()
312
-
313
- def move_Rel_m(self, send_to_tcpip=False):
314
- self.ui.Move_Rel_minus_pb.click()
315
-
316
- def move_Rel(self, rel_position, send_to_tcpip=False):
317
- """
318
- | Make a move from the given relative psition and the current one.
319
- |
320
- | The move is done if (current position + relative position) is in bounds sending Threads Commands "Reset_Stop_Motion" and "move_done"
321
-
322
- =============== ========== ===================================================
323
- **Parameters** **Type** **Description**
324
-
325
- *position* float The relative target position from the current one
326
- =============== ========== ===================================================
327
-
328
- See Also
329
- --------
330
- update_status, check_out_bounds, DAQ_utils.ThreadCommand
331
- """
332
- try:
333
- self.send_to_tcpip = send_to_tcpip
334
- self.ui.Move_Done_LED.set_as_false()
335
- self.move_done_bool = False
336
- self.target_position = self.current_position + rel_position
337
- self.update_status("Moving", wait_time=self.wait_time)
338
- # self.check_out_bounds(self.target_position)
339
- self.command_stage.emit(ThreadCommand(command="Reset_Stop_Motion"))
340
- self.command_stage.emit(ThreadCommand(command="move_Rel", attributes=[rel_position]))
341
-
342
- except Exception as e:
343
- self.logger.exception(str(e))
344
-
345
- def parameter_tree_changed(self, param, changes):
346
- """
347
- | Check eventual changes in the changes list parameter.
348
- |
349
- | In case of changed values, emit the signal containing the current path and parameter via update_settings_signal to the connected hardware.
350
-
351
- =============== ==================================== ==================================================
352
- **Parameters** **Type** **Description**
353
-
354
- *param* instance of pyqtgraph parameter The parameter to be checked
355
-
356
- *changes* (parameter,change,infos) tuple list The (parameter,change,infos) list to be treated
357
- =============== ==================================== ==================================================
358
- """
359
-
360
- for param, change, data in changes:
361
- path = self.settings.childPath(param)
362
- if path is not None:
363
- childName = '.'.join(path)
364
- else:
365
- childName = param.name()
366
- if change == 'childAdded':
367
- if 'main_settings' not in path:
368
- self.update_settings_signal.emit(edict(path=path, param=data[0].saveState(), change=change))
369
-
370
- elif change == 'value':
371
-
372
- if param.name() == 'connect_server':
373
- if param.value():
374
- self.connect_tcp_ip()
375
- else:
376
- self.command_tcpip.emit(ThreadCommand('quit'))
377
-
378
- elif param.name() == 'ip_address' or param.name == 'port':
379
- self.command_tcpip.emit(ThreadCommand('update_connection',
380
- dict(ipaddress=self.settings.child('main_settings', 'tcpip',
381
- 'ip_address').value(),
382
- port=self.settings.child('main_settings', 'tcpip',
383
- 'port').value())))
384
-
385
- if path is not None:
386
- if 'main_settings' not in path:
387
- self.update_settings_signal.emit(edict(path=path, param=param, change=change))
388
- if self.settings.child('main_settings', 'tcpip', 'tcp_connected').value():
389
- self.command_tcpip.emit(ThreadCommand('send_info', dict(path=path, param=param)))
390
-
391
- elif change == 'parent':
392
- if param.name() not in putils.iter_children(self.settings.child('main_settings'), []):
393
- self.update_settings_signal.emit(edict(path=['move_settings'], param=param, change=change))
394
-
395
- def connect_tcp_ip(self):
396
- if self.settings.child('main_settings', 'tcpip', 'connect_server').value():
397
- self.tcpclient_thread = QThread()
398
-
399
- tcpclient = TCPClient(self.settings.child('main_settings', 'tcpip', 'ip_address').value(),
400
- self.settings.child('main_settings', 'tcpip', 'port').value(),
401
- self.settings.child(('move_settings')), client_type="ACTUATOR")
402
- tcpclient.moveToThread(self.tcpclient_thread)
403
- self.tcpclient_thread.tcpclient = tcpclient
404
- tcpclient.cmd_signal.connect(self.process_tcpip_cmds)
405
-
406
- self.command_tcpip[ThreadCommand].connect(tcpclient.queue_command)
407
-
408
- self.tcpclient_thread.start()
409
- tcpclient.init_connection()
410
-
411
- @Slot(ThreadCommand)
412
- def process_tcpip_cmds(self, status):
413
- if 'move_abs' in status.command:
414
- self.move_Abs(status.attributes[0], send_to_tcpip=True)
415
-
416
- elif 'move_rel' in status.command:
417
- self.move_Rel(status.attributes[0], send_to_tcpip=True)
418
-
419
- elif 'move_home' in status.command:
420
- self.move_Home(send_to_tcpip=True)
421
-
422
- elif 'check_position' in status.command:
423
- self.send_to_tcpip = True
424
- self.command_stage.emit(ThreadCommand('check_position'))
425
-
426
- elif status.command == 'connected':
427
- self.settings.child('main_settings', 'tcpip', 'tcp_connected').setValue(True)
428
-
429
- elif status.command == 'disconnected':
430
- self.settings.child('main_settings', 'tcpip', 'tcp_connected').setValue(False)
431
-
432
- elif status.command == 'Update_Status':
433
- self.thread_status(status)
434
-
435
- elif status.command == 'set_info':
436
- param_dict = ioxml.XML_string_to_parameter(status.attributes[1])[0]
437
- param_tmp = Parameter.create(**param_dict)
438
- param = self.settings.child('move_settings', *status.attributes[0][1:])
439
-
440
- param.restoreState(param_tmp.saveState())
441
-
442
- def quit_fun(self):
443
- """
444
- Leave the current instance of DAQ_Move_Main closing the parent widget.
445
- """
446
- # insert anything that needs to be closed before leaving
447
- try:
448
- if self.initialized_state:
449
- self.ui.IniStage_pb.click()
450
-
451
- self.parent.close() # close the parent widget
452
- try:
453
- self.parent.parent().parent().close() # the dock parent (if any)
454
- except Exception as e:
455
- self.logger.info('No dock parent to close')
456
-
457
- except Exception as e:
458
- icon = QtGui.QIcon()
459
- icon.addPixmap(QtGui.QPixmap(":/Labview_icons/Icon_Library/close2.png"), QtGui.QIcon.Normal,
460
- QtGui.QIcon.Off)
461
- msgBox = QtWidgets.QMessageBox(parent=None)
462
- msgBox.addButton(QtWidgets.QMessageBox.Yes)
463
- msgBox.addButton(QtWidgets.QMessageBox.No)
464
- msgBox.setWindowTitle("Error")
465
- msgBox.setText(str(e) + " error happened when uninitializing the stage.\nDo you still want to quit?")
466
- msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
467
- ret = msgBox.exec()
468
- if ret == QtWidgets.QMessageBox.Yes:
469
- self.parent.close()
470
-
471
- @Slot()
472
- def raise_timeout(self):
473
- """
474
- Update status with "Timeout occured" statement.
475
-
476
- See Also
477
- --------
478
- update_status
479
- """
480
- self.update_status("Timeout occured", wait_time=self.wait_time)
481
- self.wait_position_flag = False
482
-
483
- def set_enabled_move_buttons(self, enable=False):
484
- """
485
- Set the move buttons enabled (or not) in User Interface from the gridLayout_buttons course.
486
-
487
- =============== ========== ================================================
488
- **Parameters** **Type** **Description**
489
-
490
- *enable* boolean The parameter making enable or not the buttons
491
- =============== ========== ================================================
492
-
493
- """
494
- Nchildren = self.ui.gridLayout_buttons.count()
495
- for ind in range(Nchildren):
496
- widget = self.ui.gridLayout_buttons.itemAt(ind).widget()
497
- if widget is not None:
498
- widget.setEnabled(enable)
499
- self.ui.Moveto_pb_bis.setEnabled(enable)
500
- self.ui.Abs_position_sb_bis.setEnabled(enable)
501
- self.ui.Current_position_sb.setEnabled(enable)
502
-
503
- @Slot(int)
504
- def set_setting_tree(self, index=0):
505
- """
506
- Set the move settings parameters tree, clearing the current tree and setting the 'move_settings' node.
507
-
508
- See Also
509
- --------
510
- update_status
511
- """
512
- self.stage_name = self.ui.Stage_type_combo.currentText()
513
- self.settings.child('main_settings', 'move_type').setValue(self.stage_name)
514
- try:
515
- for child in self.settings.child(('move_settings')).children():
516
- child.remove()
517
- parent_module = utils.find_dict_in_list_from_key_val(DAQ_Move_Stage_type, 'name', self.stage_name)
518
- class_ = getattr(getattr(parent_module['module'], 'daq_move_' + self.stage_name),
519
- 'DAQ_Move_' + self.stage_name)
520
- params = getattr(class_, 'params')
521
- move_params = Parameter.create(name='move_settings', type='group', children=params)
522
-
523
- self.settings.child(('move_settings')).addChildren(move_params.children())
524
-
525
- except Exception as e:
526
- self.logger.exception(str(e))
527
-
528
- def show_fine_tuning(self):
529
- """
530
- Make GroupBox visible if User Interface corresponding attribute is checked to show fine tuning in.
531
- """
532
- if self.ui.fine_tuning_pb.isChecked():
533
- self.ui.groupBox.show()
534
- else:
535
- self.ui.groupBox.hide()
536
-
537
- def show_settings(self):
538
- """
539
- Make settings tree visible if User Interface corresponding attribute is checked to show the settings tree in.
540
- """
541
- if self.ui.parameters_pb.isChecked():
542
-
543
- self.ui.settings_tree.setVisible(True)
544
- else:
545
- self.ui.settings_tree.setVisible(False)
546
-
547
- @Slot(int)
548
- def stage_changed(self, index=0):
549
-
550
- """
551
-
552
- See Also
553
- --------
554
- move_Abs
555
- """
556
- pass
557
-
558
- def stop_Motion(self):
559
- """
560
- stop any motion via the launched thread with the "stop_Motion" Thread Command.
561
-
562
- See Also
563
- --------
564
- update_status, DAQ_utils.ThreadCommand
565
- """
566
- try:
567
- self.command_stage.emit(ThreadCommand(command="stop_Motion"))
568
- except Exception as e:
569
- self.logger.exception(str(e))
570
-
571
- @Slot(ThreadCommand)
572
- def thread_status(self, status): # general function to get datas/infos from all threads back to the main
573
- """
574
- | General function to get datas/infos from all threads back to the main0
575
- |
576
-
577
- Interpret a command from the command given by the ThreadCommand status :
578
- * In case of **'Update_status'** command, call the update_status method with status attributes as parameters
579
- * In case of **'ini_stage'** command, initialise a Stage from status attributes
580
- * In case of **'close'** command, close the launched stage thread
581
- * In case of **'check_position'** command, set the Current_position value from status attributes
582
- * In case of **'move_done'** command, set the Current_position value, make profile of move_done and send the move done signal with status attributes
583
- * In case of **'Move_Not_Done'** command, set the current position value from the status attributes, make profile of Not_Move_Done and send the Thread Command "Move_abs"
584
- * In case of **'update_settings'** command, create child "Move Settings" from status attributes (if possible)
585
-
586
- ================ ================= ======================================================
587
- **Parameters** **Type** **Description**
588
-
589
- *status* ThreadCommand() instance of ThreadCommand containing two attributes :
590
-
591
- * *command* str
592
- * *attributes* list
593
-
594
- ================ ================= ======================================================
595
-
596
- See Also
597
- --------
598
- update_status, set_enabled_move_buttons, get_position, DAQ_utils.ThreadCommand, parameter_tree_changed, raise_timeout
599
- """
600
-
601
- if status.command == "Update_Status":
602
- if len(status.attributes) > 2:
603
- self.update_status(status.attributes[0], wait_time=self.wait_time, log_type=status.attributes[1])
604
- else:
605
- self.update_status(status.attributes[0], wait_time=self.wait_time)
606
-
607
- elif status.command == "ini_stage":
608
- # status.attributes[0]=edict(initialized=bool,info="", controller=)
609
- self.update_status("Stage initialized: {:} info: {:}".format(status.attributes[0]['initialized'],
610
- status.attributes[0]['info']),
611
- wait_time=self.wait_time)
612
- if status.attributes[0]['initialized']:
613
- self.controller = status.attributes[0]['controller']
614
- self.set_enabled_move_buttons(enable=True)
615
- self.ui.Ini_state_LED.set_as_true()
616
- self.initialized_state = True
617
- else:
618
- self.initialized_state = False
619
- if self.initialized_state:
620
- self.get_position()
621
- self.init_signal.emit(self.initialized_state)
622
-
623
- elif status.command == "close":
624
- try:
625
- self.update_status(status.attributes[0], wait_time=self.wait_time)
626
- self.stage_thread.exit()
627
- self.stage_thread.wait()
628
- finished = self.stage_thread.isFinished()
629
- if finished:
630
- pass
631
- delattr(self, 'stage_thread')
632
- else:
633
- self.update_status('thread is locked?!', self.wait_time, 'log')
634
- except Exception as e:
635
- self.logger.exception(str(e))
636
- self.initialized_state = False
637
- self.init_signal.emit(self.initialized_state)
638
-
639
- elif status.command == "check_position":
640
- self.ui.Current_position_sb.setValue(status.attributes[0])
641
- self.move_moving_signal.emit(self.title, status.attributes[0])
642
- self.current_position = status.attributes[0]
643
- if self.settings.child('main_settings', 'tcpip', 'tcp_connected').value() and self.send_to_tcpip:
644
- self.command_tcpip.emit(ThreadCommand('position_is', status.attributes))
645
-
646
- elif status.command == "move_done":
647
- self.ui.Current_position_sb.setValue(status.attributes[0])
648
- self.current_position = status.attributes[0]
649
- self.move_done_bool = True
650
- self.ui.Move_Done_LED.set_as_true()
651
- self.move_done_signal.emit(self.title, status.attributes[0])
652
- if self.settings.child('main_settings', 'tcpip', 'tcp_connected').value() and self.send_to_tcpip:
653
- self.command_tcpip.emit(ThreadCommand('move_done', status.attributes))
654
-
655
- elif status.command == "Move_Not_Done":
656
- self.ui.Current_position_sb.setValue(status.attributes[0])
657
- self.current_position = status.attributes[0]
658
- self.move_done_bool = False
659
- self.ui.Move_Done_LED.set_as_false()
660
- self.command_stage.emit(ThreadCommand(command="move_Abs", attributes=[self.target_position]))
661
-
662
- elif status.command == 'update_main_settings':
663
- # this is a way for the plugins to update main settings of the ui (solely values, limits and options)
664
- try:
665
- if status.attributes[2] == 'value':
666
- self.settings.child('main_settings', *status.attributes[0]).setValue(status.attributes[1])
667
- elif status.attributes[2] == 'limits':
668
- self.settings.child('main_settings', *status.attributes[0]).setLimits(status.attributes[1])
669
- elif status.attributes[2] == 'options':
670
- self.settings.child('main_settings', *status.attributes[0]).setOpts(**status.attributes[1])
671
- except Exception as e:
672
- self.logger.exception(str(e))
673
-
674
- elif status.command == 'update_settings':
675
- # ThreadCommand(command='update_settings',attributes=[path,data,change]))
676
- try:
677
- self.settings.sigTreeStateChanged.disconnect(
678
- self.parameter_tree_changed) # any changes on the settings will update accordingly the detector
679
- except Exception:
680
- pass
681
- try:
682
- if status.attributes[2] == 'value':
683
- self.settings.child('move_settings', *status.attributes[0]).setValue(status.attributes[1])
684
- elif status.attributes[2] == 'limits':
685
- self.settings.child('move_settings', *status.attributes[0]).setLimits(status.attributes[1])
686
- elif status.attributes[2] == 'options':
687
- self.settings.child('move_settings', *status.attributes[0]).setOpts(**status.attributes[1])
688
- elif status.attributes[2] == 'childAdded':
689
- child = Parameter.create(name='tmp')
690
- child.restoreState(status.attributes[1][0])
691
- self.settings.child('move_settings', *status.attributes[0]).addChild(status.attributes[1][0])
692
-
693
- except Exception as e:
694
- self.logger.exception(str(e))
695
- self.settings.sigTreeStateChanged.connect(
696
- self.parameter_tree_changed) # any changes on the settings will update accordingly the detector
697
-
698
- elif status.command == 'raise_timeout':
699
- self.raise_timeout()
700
-
701
- elif status.command == 'outofbounds':
702
- self.bounds_signal.emit(True)
703
-
704
- elif status.command == 'show_splash':
705
- self.ui.settings_tree.setEnabled(False)
706
- self.splash_sc.show()
707
- self.splash_sc.raise_()
708
- self.splash_sc.showMessage(status.attributes[0], color=Qt.white)
709
-
710
- elif status.command == 'close_splash':
711
- self.splash_sc.close()
712
- self.ui.settings_tree.setEnabled(True)
713
-
714
- elif status.command == 'set_allowed_values':
715
- if 'decimals' in status.attributes:
716
- self.ui.Current_position_sb.setDecimals(status.attributes['decimals'])
717
- self.ui.Abs_position_sb.setDecimals(status.attributes['decimals'])
718
- self.ui.Abs_position_sb_bis.setDecimals(status.attributes['decimals'])
719
- if 'minimum'in status.attributes:
720
- self.ui.Current_position_sb.setMinimum(status.attributes['minimum'])
721
- self.ui.Abs_position_sb.setMinimum(status.attributes['minimum'])
722
- self.ui.Abs_position_sb_bis.setMinimum(status.attributes['minimum'])
723
- if 'maximum'in status.attributes:
724
- self.ui.Current_position_sb.setMaximum(status.attributes['maximum'])
725
- self.ui.Abs_position_sb.setMaximum(status.attributes['maximum'])
726
- self.ui.Abs_position_sb_bis.setMaximum(status.attributes['maximum'])
727
- if 'step'in status.attributes:
728
- self.ui.Current_position_sb.setSingleStep(status.attributes['step'])
729
- self.ui.Abs_position_sb.setSingleStep(status.attributes['step'])
730
- self.ui.Abs_position_sb_bis.setSingleStep(status.attributes['step'])
731
-
732
- def update_status(self, txt, wait_time=0):
733
- """
734
- Show the given txt message in the status bar with a delay of wait_time ms if specified (0 by default).
735
-
736
- ================ ========== =================================
737
- **Parameters** **Type** **Description**
738
- *txt* string The message to show
739
- *wait_time* int The delay time of showing
740
- ================ ========== =================================
741
-
742
- """
743
-
744
- self.ui.statusbar.showMessage(txt, wait_time)
745
- self.status_signal.emit(txt)
746
- self.logger.info(txt)
747
-
748
-
749
- class DAQ_Move_stage(QObject):
750
- """
751
- ================== ========================
752
- **Attributes** **Type**
753
- *status_sig* instance of Signal
754
- *hardware* ???
755
- *stage_name* string
756
- *current_position* float
757
- *target_position* float
758
- *hardware_adress* string
759
- *axis_address* string
760
- *motion_stoped* boolean
761
- ================== ========================
762
- """
763
- status_sig = Signal(ThreadCommand)
764
-
765
- def __init__(self, stage_name, position, title='actuator'):
766
- super().__init__()
767
- self.logger = utils.set_logger(f'{logger.name}.{title}.actuator')
768
- self.title = title
769
- self.hardware: DAQ_Move_base = None
770
- self.stage_name = stage_name
771
- self.current_position = position
772
- self.target_position = 0
773
- self.hardware_adress = None
774
- self.axis_address = None
775
- self.motion_stoped = False
776
-
777
- def close(self):
778
- """
779
- Uninitialize the stage closing the hardware.
780
-
781
- """
782
- self.hardware.close()
783
-
784
- return "Stage uninitialized"
785
-
786
- def check_position(self):
787
- """
788
- Get the current position checking the harware position.
789
-
790
- """
791
- pos = self.hardware.get_actuator_value()
792
- self.status_sig.emit(ThreadCommand('check_position', [pos]))
793
-
794
- def ini_stage(self, params_state=None, controller=None):
795
- """
796
- Init a stage updating the hardware and sending an hardware move_done signal.
797
-
798
- =============== =================================== ==========================================================================================================================
799
- **Parameters** **Type** **Description**
800
-
801
- *params_state* ordered dictionnary list The parameter state of the hardware class composed by a list representing the tree to keep a temporary save of the tree
802
-
803
- *controller* one or many instance of DAQ_Move The controller id of the hardware
804
-
805
- *stage* instance of DAQ_Move Defining axes and motors
806
- =============== =================================== ==========================================================================================================================
807
-
808
- See Also
809
- --------
810
- DAQ_utils.ThreadCommand, DAQ_Move
811
- """
812
-
813
- status = edict(initialized=False, info="")
814
- try:
815
- parent_module = utils.find_dict_in_list_from_key_val(DAQ_Move_Stage_type, 'name', self.stage_name)
816
- class_ = getattr(getattr(parent_module['module'], 'daq_move_' + self.stage_name),
817
- 'DAQ_Move_' + self.stage_name)
818
- self.hardware = class_(self, params_state)
819
- try:
820
- infos = self.hardware.ini_stage(controller) # return edict(info="", controller=, stage=)
821
- except Exception as e:
822
- logger.exception('Hardware couldn\'t be initialized' + str(e))
823
- infos = str(e), False
824
-
825
- if isinstance(infos, edict):
826
- status.update(infos)
827
- else:
828
- status.info = infos[0]
829
- status.initialized = infos[1]
830
- status.controller = self.hardware.controller
831
- self.hardware.Move_Done_signal.connect(self.Move_Done)
832
-
833
- # status.initialized=True
834
- return status
835
- except Exception as e:
836
- self.logger.exception(str(e))
837
- return status
838
-
839
- def move_Abs(self, position, polling=True):
840
- """
841
- Make the hardware absolute move from the given position.
842
-
843
- =============== ========= =======================
844
- **Parameters** **Type** **Description**
845
-
846
- *position* float The absolute position
847
- =============== ========= =======================
848
-
849
- See Also
850
- --------
851
- move_Abs
852
- """
853
- position = float(position) # because it may be a numpy float and could cause issues
854
- # see https://github.com/pythonnet/pythonnet/issues/1833
855
- self.target_position = position
856
- self.hardware.move_is_done = False
857
- self.hardware.target_position = position
858
- self.hardware.ispolling = polling
859
- pos = self.hardware.move_abs(position)
860
- self.hardware.poll_moving()
861
-
862
- def move_Rel(self, rel_position, polling=True):
863
- """
864
- Make the hardware relative move from the given relative position added to the current one.
865
-
866
- ================ ========= ======================
867
- **Parameters** **Type** **Description**
868
-
869
- *position* float The relative position
870
- ================ ========= ======================
871
-
872
- See Also
873
- --------
874
- move_Rel
875
- """
876
- rel_position = float(rel_position) # because it may be a numpy float and could cause issues
877
- # see https://github.com/pythonnet/pythonnet/issues/1833
878
- self.hardware.move_is_done = False
879
- self.target_position = self.current_position + rel_position
880
- self.hardware.target_position = self.target_position
881
- self.hardware.ispolling = polling
882
- pos = self.hardware.move_rel(rel_position)
883
- self.hardware.poll_moving()
884
-
885
- @Slot(float)
886
- def Move_Stoped(self, pos):
887
- """
888
- Send a "move_done" Thread Command with the given position as an attribute.
889
-
890
- See Also
891
- --------
892
- DAQ_utils.ThreadCommand
893
- """
894
- self.status_sig.emit(ThreadCommand("move_done", [pos]))
895
-
896
- def move_Home(self):
897
- """
898
- Make the hardware move to the init position.
899
-
900
- """
901
- self.hardware.move_is_done = False
902
- self.target_position = 0
903
- self.hardware.move_home()
904
-
905
- @Slot(float)
906
- def Move_Done(self, pos):
907
- """
908
- | Send a "move_done" Thread Command with the given position as an attribute and update the current position attribute.
909
- |
910
- | Check if position reached within epsilon => not necessary this is done within the hardware code see polling for instance
911
-
912
- See Also
913
- --------
914
- DAQ_utils.ThreadCommand
915
- """
916
-
917
- # check if position reached within epsilon=> not necessary this is done within the hardware code see polling for instance
918
- self.current_position = pos
919
- self.status_sig.emit(ThreadCommand(command="move_done", attributes=[pos]))
920
- # if self.motion_stoped:
921
- # self.status_sig.emit(ThreadCommand(command="move_done",attributes=[pos]))
922
- # else:
923
- # if np.abs(self.target_position-pos)>self.hardware.settings.child(('epsilon')).value():
924
- # self.status_sig.emit(ThreadCommand("Move_Not_Done",[pos]))
925
- # else:
926
- # self.status_sig.emit(ThreadCommand("move_done",[pos]))
927
-
928
- @Slot(ThreadCommand)
929
- def queue_command(self, command=ThreadCommand()):
930
- """
931
- Interpret the given Thread Command.
932
- * In case of **'ini_stage'** command, init a stage from command attributes.
933
- * In case of **'close'** command, unitinalise the stage closing hardware and emitting the corresponding status signal
934
- * In case of **'move_Abs'** command, call the move_Abs method with position from command attributes
935
- * In case of **'move_Rel'** command, call the move_Rel method with the relative position from the command attributes.
936
- * In case of **'move_Home'** command, call the move_Home method
937
- * In case of **'check_position'** command, get the current position from the check_position method
938
- * In case of **'Stop_motion'** command, stop any motion via the stop_Motion method
939
- * In case of **'Reset_Stop_Motion'** command, set the motion_stopped attribute to false
940
-
941
- =============== =============== ================================
942
- **Parameters** **Type** **Description**
943
-
944
- *command* ThreadCommand() The command to be interpreted
945
- =============== =============== ================================
946
-
947
- See Also
948
- --------
949
- DAQ_utils.ThreadCommand, ini_stage, close, move_Abs, move_Rel, move_Home, check_position, stop_Motion
950
- """
951
- try:
952
- if command.command == "ini_stage":
953
- status = self.ini_stage(
954
- *command.attributes) # return edict(initialized=bool,info="", controller=, stage=)
955
- self.status_sig.emit(ThreadCommand(command=command.command, attributes=[status, 'log']))
956
-
957
- elif command.command == "close":
958
- status = self.close()
959
- self.status_sig.emit(ThreadCommand(command=command.command, attributes=[status]))
960
-
961
- elif command.command == "move_Abs":
962
- self.move_Abs(*command.attributes)
963
-
964
- elif command.command == "move_Rel":
965
- self.move_Rel(*command.attributes)
966
-
967
- elif command.command == "move_Home":
968
- self.move_Home()
969
-
970
- elif command.command == "check_position":
971
- self.check_position()
972
-
973
- elif command.command == "stop_Motion":
974
- self.stop_motion()
975
-
976
- elif command.command == "Reset_Stop_Motion":
977
- self.motion_stoped = False
978
-
979
- else: # custom commands for particular plugins (see spectrometer module 'get_spectro_wl' for instance)
980
- if hasattr(self.hardware, command.command):
981
- cmd = getattr(self.hardware, command.command)
982
- cmd(*command.attributes)
983
- except Exception as e:
984
- self.logger.exception(str(e))
985
-
986
- def stop_motion(self):
987
- """
988
- stop hardware motion with motion_stopped attribute updtaed to True and a status signal sended with an "update_status" Thread Command
989
-
990
- See Also
991
- --------
992
- DAQ_utils.ThreadCommand, stop_Motion
993
- """
994
- self.status_sig.emit(ThreadCommand(command="Update_Status", attributes=["Motion stoping", 'log']))
995
- self.motion_stoped = True
996
- self.hardware.stop_motion()
997
- self.hardware.poll_timer.stop()
998
- self.move_done()
999
-
1000
- @Slot(edict)
1001
- def update_settings(self, settings_parameter_dict):
1002
- """
1003
- Update settings of hardware with dictionnary parameters in case of "Move_Settings" path, else update attributes with dictionnary parameters.
1004
-
1005
- ========================= =========== ======================================================
1006
- **Parameters** **Type** **Description**
1007
-
1008
- *settings_parameter_dict* dictionnary Dictionnary containing the path and linked parameter
1009
- ========================= =========== ======================================================
1010
-
1011
- See Also
1012
- --------
1013
- update_settings
1014
- """
1015
- # settings_parameter_dict = edict(path=path,param=param)
1016
- path = settings_parameter_dict['path']
1017
- param = settings_parameter_dict['param']
1018
- if path[0] == 'main_settings':
1019
- if hasattr(self, path[-1]):
1020
- setattr(self, path[-1], param.value())
1021
-
1022
- elif path[0] == 'move_settings':
1023
- self.hardware.update_settings(settings_parameter_dict)
1024
-
1025
-
1026
- def main(init_qt=True):
1027
- if init_qt: # used for the test suite
1028
- app = QtWidgets.QApplication(sys.argv)
1029
- if config('style', 'darkstyle'):
1030
- import qdarkstyle
1031
- app.setStyleSheet(qdarkstyle.load_stylesheet(qdarkstyle.DarkPalette))
1032
-
1033
- form = QtWidgets.QWidget()
1034
- prog = DAQ_Move(form, title="test", init=False)
1035
- form.show()
1036
-
1037
- if init_qt:
1038
- sys.exit(app.exec_())
1039
- return prog, form
1040
-
1041
- if __name__ == '__main__':
1042
- main()