pymodaq 5.0.5__py3-none-any.whl → 5.1.0a0__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.
- pymodaq/control_modules/daq_move.py +77 -64
- pymodaq/control_modules/daq_move_ui.py +16 -15
- pymodaq/control_modules/daq_viewer.py +95 -87
- pymodaq/control_modules/daq_viewer_ui.py +22 -23
- pymodaq/control_modules/mocks.py +2 -2
- pymodaq/control_modules/move_utility_classes.py +28 -19
- pymodaq/control_modules/thread_commands.py +138 -0
- pymodaq/control_modules/utils.py +88 -20
- pymodaq/control_modules/viewer_utility_classes.py +8 -17
- pymodaq/dashboard.py +90 -27
- pymodaq/examples/qt_less_standalone_module.py +48 -11
- pymodaq/extensions/__init__.py +7 -3
- pymodaq/extensions/adaptive/__init__.py +2 -0
- pymodaq/extensions/adaptive/adaptive_optimization.py +159 -0
- pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +86 -0
- pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
- pymodaq/extensions/adaptive/loss_function/loss_factory.py +106 -0
- pymodaq/extensions/adaptive/utils.py +97 -0
- pymodaq/extensions/bayesian/__init__.py +1 -1
- pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +71 -0
- pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +86 -0
- pymodaq/extensions/bayesian/bayesian_optimization.py +121 -0
- pymodaq/extensions/bayesian/utils.py +27 -286
- pymodaq/extensions/daq_logger/daq_logger.py +7 -12
- pymodaq/extensions/daq_logger/h5logging.py +1 -1
- pymodaq/extensions/daq_scan.py +18 -47
- pymodaq/extensions/h5browser.py +3 -34
- pymodaq/extensions/optimizers_base/__init__.py +0 -0
- pymodaq/extensions/{bayesian/bayesian_optimisation.py → optimizers_base/optimizer.py} +441 -334
- pymodaq/extensions/optimizers_base/thread_commands.py +20 -0
- pymodaq/extensions/optimizers_base/utils.py +378 -0
- pymodaq/extensions/pid/pid_controller.py +6 -10
- pymodaq/extensions/utils.py +12 -0
- pymodaq/utils/data.py +1 -0
- pymodaq/utils/gui_utils/loader_utils.py +2 -0
- pymodaq/utils/h5modules/module_saving.py +134 -22
- pymodaq/utils/leco/daq_move_LECODirector.py +73 -73
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +36 -84
- pymodaq/utils/leco/director_utils.py +25 -10
- pymodaq/utils/leco/leco_director.py +65 -26
- pymodaq/utils/leco/pymodaq_listener.py +118 -68
- pymodaq/utils/leco/utils.py +24 -24
- pymodaq/utils/managers/modules_manager.py +37 -8
- pymodaq/utils/scanner/scanners/_1d_scanners.py +0 -38
- pymodaq/utils/scanner/scanners/_2d_scanners.py +0 -58
- {pymodaq-5.0.5.dist-info → pymodaq-5.1.0a0.dist-info}/METADATA +4 -3
- {pymodaq-5.0.5.dist-info → pymodaq-5.1.0a0.dist-info}/RECORD +52 -38
- {pymodaq-5.0.5.dist-info → pymodaq-5.1.0a0.dist-info}/entry_points.txt +0 -2
- pymodaq/utils/leco/desktop.ini +0 -2
- {pymodaq-5.0.5.dist-info → pymodaq-5.1.0a0.dist-info}/WHEEL +0 -0
- {pymodaq-5.0.5.dist-info → pymodaq-5.1.0a0.dist-info}/licenses/LICENSE +0 -0
|
@@ -36,6 +36,8 @@ from pymodaq_gui.utils.utils import mkQApp
|
|
|
36
36
|
|
|
37
37
|
from pymodaq.utils.h5modules import module_saving
|
|
38
38
|
from pymodaq.control_modules.utils import ParameterControlModule
|
|
39
|
+
from pymodaq.control_modules.thread_commands import (ThreadStatus, ThreadStatusMove, ControlToHardwareMove,
|
|
40
|
+
UiToMainMove)
|
|
39
41
|
from pymodaq.control_modules.daq_move_ui import DAQ_Move_UI, ThreadCommand
|
|
40
42
|
from pymodaq.control_modules.move_utility_classes import (MoveCommand, DAQ_Move_base,
|
|
41
43
|
DataActuatorType, check_units,
|
|
@@ -43,7 +45,7 @@ from pymodaq.control_modules.move_utility_classes import (MoveCommand, DAQ_Move_
|
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
from pymodaq.control_modules.move_utility_classes import params as daq_move_params
|
|
46
|
-
from pymodaq.utils.leco.pymodaq_listener import MoveActorListener, LECOMoveCommands
|
|
48
|
+
from pymodaq.utils.leco.pymodaq_listener import MoveActorListener, LECOMoveCommands, LECOCommands
|
|
47
49
|
|
|
48
50
|
from pymodaq.utils.daq_utils import get_plugins
|
|
49
51
|
from pymodaq import Q_, Unit
|
|
@@ -126,7 +128,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
126
128
|
if len(ACTUATOR_TYPES) > 0: # will be 0 if no valid plugins are installed
|
|
127
129
|
self.actuator = kwargs.get('actuator', ACTUATOR_TYPES[0])
|
|
128
130
|
|
|
129
|
-
self.module_and_data_saver = module_saving.
|
|
131
|
+
self.module_and_data_saver = module_saving.ActuatorTimeSaver(self)
|
|
130
132
|
|
|
131
133
|
self._move_done_bool = True
|
|
132
134
|
|
|
@@ -157,36 +159,36 @@ class DAQ_Move(ParameterControlModule):
|
|
|
157
159
|
* rel_value
|
|
158
160
|
* show_config
|
|
159
161
|
"""
|
|
160
|
-
if cmd.command ==
|
|
162
|
+
if cmd.command == UiToMainMove.INIT:
|
|
161
163
|
self.init_hardware(cmd.attribute[0])
|
|
162
|
-
elif cmd.command ==
|
|
164
|
+
elif cmd.command == UiToMainMove.QUIT:
|
|
163
165
|
self.quit_fun()
|
|
164
|
-
elif cmd.command ==
|
|
166
|
+
elif cmd.command == UiToMainMove.GET_VALUE:
|
|
165
167
|
self.get_actuator_value()
|
|
166
|
-
elif cmd.command ==
|
|
168
|
+
elif cmd.command == UiToMainMove.LOOP_GET_VALUE:
|
|
167
169
|
self.get_continuous_actuator_value(cmd.attribute)
|
|
168
|
-
elif cmd.command ==
|
|
170
|
+
elif cmd.command == UiToMainMove.FIND_HOME:
|
|
169
171
|
self.move_home()
|
|
170
|
-
elif cmd.command ==
|
|
172
|
+
elif cmd.command == UiToMainMove.STOP:
|
|
171
173
|
self.stop_motion()
|
|
172
|
-
elif cmd.command ==
|
|
174
|
+
elif cmd.command == UiToMainMove.MOVE_ABS:
|
|
173
175
|
data_act: DataActuator = cmd.attribute
|
|
174
176
|
if not Unit(data_act.units).is_compatible_with(self.units) and data_act.units != '':
|
|
175
177
|
data_act.force_units(self.units)
|
|
176
178
|
self.move_abs(data_act)
|
|
177
|
-
elif cmd.command ==
|
|
179
|
+
elif cmd.command == UiToMainMove.MOVE_REL:
|
|
178
180
|
data_act: DataActuator = cmd.attribute
|
|
179
181
|
if not Unit(data_act.units).is_compatible_with(self.units) and data_act.units != '':
|
|
180
182
|
data_act.force_units(self.units)
|
|
181
183
|
self.move_rel(data_act)
|
|
182
|
-
elif cmd.command ==
|
|
184
|
+
elif cmd.command == UiToMainMove.SHOW_LOG:
|
|
183
185
|
self.show_log()
|
|
184
|
-
elif cmd.command ==
|
|
186
|
+
elif cmd.command == UiToMainMove.SHOW_CONFIG:
|
|
185
187
|
self.config = self.show_config(self.config)
|
|
186
188
|
self.ui.config = self.config
|
|
187
|
-
elif cmd.command ==
|
|
189
|
+
elif cmd.command == UiToMainMove.ACTUATOR_CHANGED:
|
|
188
190
|
self.actuator = cmd.attribute
|
|
189
|
-
elif cmd.command ==
|
|
191
|
+
elif cmd.command == UiToMainMove.REL_VALUE:
|
|
190
192
|
self._relative_value = cmd.attribute
|
|
191
193
|
|
|
192
194
|
@property
|
|
@@ -203,12 +205,13 @@ class DAQ_Move(ParameterControlModule):
|
|
|
203
205
|
self.settings.child('move_settings', 'multiaxes', 'multi_status').setValue(
|
|
204
206
|
'Master' if is_master else 'Slave')
|
|
205
207
|
|
|
206
|
-
def append_data(self, dte: Optional[DataToExport] = None,
|
|
208
|
+
def append_data(self, dte: Optional[DataToExport] = None,
|
|
209
|
+
where: Union[Node, str, None] = None):
|
|
207
210
|
"""Appends current DataToExport to an ActuatorEnlargeableSaver
|
|
208
211
|
|
|
209
212
|
Parameters
|
|
210
213
|
----------
|
|
211
|
-
|
|
214
|
+
dte: DataToExport, optional
|
|
212
215
|
where: Node or str
|
|
213
216
|
See Also
|
|
214
217
|
--------
|
|
@@ -245,7 +248,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
245
248
|
"""Stop any motion
|
|
246
249
|
"""
|
|
247
250
|
try:
|
|
248
|
-
self.command_hardware.emit(ThreadCommand(
|
|
251
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.STOP_MOTION))
|
|
249
252
|
except Exception as e:
|
|
250
253
|
self.logger.exception(str(e))
|
|
251
254
|
|
|
@@ -294,8 +297,9 @@ class DAQ_Move(ParameterControlModule):
|
|
|
294
297
|
self._move_done_bool = False
|
|
295
298
|
self._target_value = value
|
|
296
299
|
self.update_status("Moving")
|
|
297
|
-
self.command_hardware.emit(ThreadCommand(
|
|
298
|
-
self.command_hardware.emit(ThreadCommand(
|
|
300
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.RESET_STOP_MOTION))
|
|
301
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.MOVE_ABS,
|
|
302
|
+
attribute=[value]))
|
|
299
303
|
|
|
300
304
|
except Exception as e:
|
|
301
305
|
self.logger.exception(str(e))
|
|
@@ -314,8 +318,8 @@ class DAQ_Move(ParameterControlModule):
|
|
|
314
318
|
self.ui.move_done = False
|
|
315
319
|
self._move_done_bool = False
|
|
316
320
|
self.update_status("Moving")
|
|
317
|
-
self.command_hardware.emit(ThreadCommand(
|
|
318
|
-
self.command_hardware.emit(ThreadCommand(
|
|
321
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.RESET_STOP_MOTION))
|
|
322
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.MOVE_HOME))
|
|
319
323
|
|
|
320
324
|
except Exception as e:
|
|
321
325
|
self.logger.exception(str(e))
|
|
@@ -342,8 +346,9 @@ class DAQ_Move(ParameterControlModule):
|
|
|
342
346
|
self._move_done_bool = False
|
|
343
347
|
self._target_value = self._current_value + rel_value
|
|
344
348
|
self.update_status("Moving")
|
|
345
|
-
self.command_hardware.emit(ThreadCommand(
|
|
346
|
-
self.command_hardware.emit(ThreadCommand(
|
|
349
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.RESET_STOP_MOTION))
|
|
350
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.MOVE_REL,
|
|
351
|
+
attribute=[rel_value]))
|
|
347
352
|
|
|
348
353
|
except Exception as e:
|
|
349
354
|
self.logger.exception(str(e))
|
|
@@ -372,7 +377,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
372
377
|
""" Init or desinit the selected instrument plugin class """
|
|
373
378
|
if not do_init:
|
|
374
379
|
try:
|
|
375
|
-
self.command_hardware.emit(ThreadCommand(
|
|
380
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.CLOSE))
|
|
376
381
|
if self.ui is not None:
|
|
377
382
|
self.ui.actuator_init = False
|
|
378
383
|
except Exception as e:
|
|
@@ -390,9 +395,10 @@ class DAQ_Move(ParameterControlModule):
|
|
|
390
395
|
self._hardware_thread.hardware = hardware
|
|
391
396
|
self._hardware_thread.start()
|
|
392
397
|
self.command_hardware.emit(
|
|
393
|
-
ThreadCommand(
|
|
394
|
-
|
|
395
|
-
|
|
398
|
+
ThreadCommand(ControlToHardwareMove.INI_STAGE,
|
|
399
|
+
attribute=[
|
|
400
|
+
self.settings.child('move_settings').saveState(),
|
|
401
|
+
self.controller]))
|
|
396
402
|
except Exception as e:
|
|
397
403
|
self.logger.exception(str(e))
|
|
398
404
|
|
|
@@ -432,6 +438,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
432
438
|
self.update_status("Timeout occurred")
|
|
433
439
|
self.wait_position_flag = False
|
|
434
440
|
|
|
441
|
+
|
|
435
442
|
@Slot(ThreadCommand)
|
|
436
443
|
def thread_status(self, status: ThreadCommand): # general function to get datas/infos from all threads back to the main
|
|
437
444
|
"""Get back info (using the ThreadCommand object) from the hardware
|
|
@@ -457,7 +464,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
457
464
|
|
|
458
465
|
super().thread_status(status, 'move')
|
|
459
466
|
|
|
460
|
-
if status.command ==
|
|
467
|
+
if status.command == ThreadStatusMove.INI_STAGE:
|
|
461
468
|
self.update_status(f"Stage initialized: {status.attribute['initialized']} "
|
|
462
469
|
f"info: {status.attribute['info']}")
|
|
463
470
|
if status.attribute['initialized']:
|
|
@@ -471,7 +478,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
471
478
|
self.get_actuator_value()
|
|
472
479
|
self.init_signal.emit(self._initialized_state)
|
|
473
480
|
|
|
474
|
-
elif status.command ==
|
|
481
|
+
elif status.command == ThreadStatusMove.GET_ACTUATOR_VALUE or status.command == 'check_position':
|
|
475
482
|
data_act = self._check_data_type(status.attribute)
|
|
476
483
|
if self.ui is not None:
|
|
477
484
|
self.ui.display_value(data_act)
|
|
@@ -485,7 +492,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
485
492
|
if self.settings['main_settings', 'leco', 'leco_connected'] and self._send_to_tcpip:
|
|
486
493
|
self._command_tcpip.emit(ThreadCommand(LECOMoveCommands.POSITION, data_act))
|
|
487
494
|
|
|
488
|
-
elif status.command ==
|
|
495
|
+
elif status.command == ThreadStatusMove.MOVE_DONE:
|
|
489
496
|
data_act = self._check_data_type(status.attribute)
|
|
490
497
|
if self.ui is not None:
|
|
491
498
|
self.ui.display_value(data_act)
|
|
@@ -498,17 +505,17 @@ class DAQ_Move(ParameterControlModule):
|
|
|
498
505
|
if self.settings.child('main_settings', 'leco', 'leco_connected').value() and self._send_to_tcpip:
|
|
499
506
|
self._command_tcpip.emit(ThreadCommand(LECOMoveCommands.MOVE_DONE, data_act))
|
|
500
507
|
|
|
501
|
-
elif status.command ==
|
|
508
|
+
elif status.command == ThreadStatusMove.OUT_OF_BOUNDS:
|
|
502
509
|
self.bounds_signal.emit(True)
|
|
503
510
|
|
|
504
|
-
elif status.command ==
|
|
511
|
+
elif status.command == ThreadStatusMove.SET_ALLOWED_VALUES:
|
|
505
512
|
if self.ui is not None:
|
|
506
513
|
self.ui.set_abs_spinbox_properties(**status.attribute)
|
|
507
514
|
|
|
508
|
-
elif status.command ==
|
|
515
|
+
elif status.command == ThreadStatusMove.STOP:
|
|
509
516
|
self.stop_motion()
|
|
510
517
|
|
|
511
|
-
elif status.command ==
|
|
518
|
+
elif status.command == ThreadStatusMove.UNITS:
|
|
512
519
|
self.units = status.attribute
|
|
513
520
|
|
|
514
521
|
def _check_data_type(self, data_act: Union[list[np.ndarray], float, DataActuator]) -> DataActuator:
|
|
@@ -533,7 +540,7 @@ class DAQ_Move(ParameterControlModule):
|
|
|
533
540
|
Returns nothing but the `move_done_signal` will be send once the action is done
|
|
534
541
|
"""
|
|
535
542
|
try:
|
|
536
|
-
self.command_hardware.emit(ThreadCommand(
|
|
543
|
+
self.command_hardware.emit(ThreadCommand(ControlToHardwareMove.GET_ACTUATOR_VALUE))
|
|
537
544
|
|
|
538
545
|
except Exception as e:
|
|
539
546
|
self.logger.exception(str(e))
|
|
@@ -663,35 +670,36 @@ class DAQ_Move(ParameterControlModule):
|
|
|
663
670
|
super().connect_tcp_ip(params_state=self.settings.child('move_settings'),
|
|
664
671
|
client_type="ACTUATOR")
|
|
665
672
|
|
|
673
|
+
def connect_leco(self, connect: bool) -> None:
|
|
674
|
+
super().connect_leco(connect)
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
666
678
|
@Slot(ThreadCommand)
|
|
667
679
|
def process_tcpip_cmds(self, status: ThreadCommand) -> None:
|
|
668
680
|
if super().process_tcpip_cmds(status=status) is None:
|
|
669
681
|
return
|
|
670
|
-
if
|
|
671
|
-
self.move_abs(status.attribute
|
|
682
|
+
if LECOMoveCommands.MOVE_ABS == status.command:
|
|
683
|
+
self.move_abs(status.attribute, send_to_tcpip=True)
|
|
672
684
|
|
|
673
|
-
elif
|
|
674
|
-
self.move_rel(status.attribute
|
|
685
|
+
elif LECOMoveCommands.MOVE_REL == status.command:
|
|
686
|
+
self.move_rel(status.attribute, send_to_tcpip=True)
|
|
675
687
|
|
|
676
|
-
elif
|
|
688
|
+
elif LECOMoveCommands.MOVE_HOME == status.command:
|
|
677
689
|
self.move_home(send_to_tcpip=True)
|
|
678
690
|
|
|
679
691
|
elif 'check_position' in status.command:
|
|
680
692
|
deprecation_msg('check_position is deprecated, you should use get_actuator_value')
|
|
681
693
|
self._send_to_tcpip = True
|
|
682
|
-
self.
|
|
694
|
+
self.get_actuator_value()
|
|
683
695
|
|
|
684
|
-
elif
|
|
696
|
+
elif LECOMoveCommands.GET_ACTUATOR_VALUE in status.command:
|
|
685
697
|
self._send_to_tcpip = True
|
|
686
|
-
self.
|
|
698
|
+
self.get_actuator_value()
|
|
699
|
+
|
|
700
|
+
elif status.command == LECOMoveCommands.STOP:
|
|
701
|
+
self.stop_motion()
|
|
687
702
|
|
|
688
|
-
elif status.command == 'set_info':
|
|
689
|
-
path_in_settings = status.attribute[0]
|
|
690
|
-
param_as_xml = status.attribute[1]
|
|
691
|
-
param_dict = ioxml.XML_string_to_parameter(param_as_xml)[0]
|
|
692
|
-
param_tmp = Parameter.create(**param_dict)
|
|
693
|
-
param = self.settings.child('move_settings', *path_in_settings[1:])
|
|
694
|
-
param.restoreState(param_tmp.saveState())
|
|
695
703
|
|
|
696
704
|
|
|
697
705
|
class DAQ_Move_Hardware(QObject):
|
|
@@ -791,7 +799,8 @@ class DAQ_Move_Hardware(QObject):
|
|
|
791
799
|
status.controller = self.hardware.controller
|
|
792
800
|
self.hardware.move_done_signal.connect(self.move_done)
|
|
793
801
|
if status.initialized:
|
|
794
|
-
self.status_sig.emit(ThreadCommand(
|
|
802
|
+
self.status_sig.emit(ThreadCommand(ThreadStatusMove.GET_ACTUATOR_VALUE,
|
|
803
|
+
self.get_actuator_value()))
|
|
795
804
|
|
|
796
805
|
return status
|
|
797
806
|
except Exception as e:
|
|
@@ -837,7 +846,7 @@ class DAQ_Move_Hardware(QObject):
|
|
|
837
846
|
--------
|
|
838
847
|
DAQ_utils.ThreadCommand
|
|
839
848
|
"""
|
|
840
|
-
self.status_sig.emit(ThreadCommand(
|
|
849
|
+
self.status_sig.emit(ThreadCommand(ThreadStatusMove.MOVE_DONE, pos))
|
|
841
850
|
|
|
842
851
|
def move_home(self):
|
|
843
852
|
"""
|
|
@@ -852,7 +861,8 @@ class DAQ_Move_Hardware(QObject):
|
|
|
852
861
|
"""Send the move_done signal back to the main class
|
|
853
862
|
"""
|
|
854
863
|
self._current_value = pos
|
|
855
|
-
self.status_sig.emit(ThreadCommand(command=
|
|
864
|
+
self.status_sig.emit(ThreadCommand(command=ThreadStatusMove.MOVE_DONE,
|
|
865
|
+
attribute=pos))
|
|
856
866
|
|
|
857
867
|
@Slot(ThreadCommand)
|
|
858
868
|
def queue_command(self, command: ThreadCommand):
|
|
@@ -881,31 +891,34 @@ class DAQ_Move_Hardware(QObject):
|
|
|
881
891
|
"""
|
|
882
892
|
try:
|
|
883
893
|
logger.debug(f'Threadcommand {command.command} sent to {self.title}')
|
|
884
|
-
if command.command ==
|
|
894
|
+
if command.command == ControlToHardwareMove.INI_STAGE:
|
|
885
895
|
status: edict = self.ini_stage(*command.attribute)
|
|
886
|
-
self.status_sig.emit(ThreadCommand(command=
|
|
896
|
+
self.status_sig.emit(ThreadCommand(command=ThreadStatusMove.INI_STAGE,
|
|
897
|
+
attribute=status))
|
|
887
898
|
|
|
888
|
-
elif command.command ==
|
|
899
|
+
elif command.command == ControlToHardwareMove.CLOSE:
|
|
889
900
|
status = self.close()
|
|
890
|
-
self.status_sig.emit(ThreadCommand(command=
|
|
901
|
+
self.status_sig.emit(ThreadCommand(command=ThreadStatus.CLOSE,
|
|
902
|
+
attribute=[status]))
|
|
891
903
|
|
|
892
|
-
elif command.command ==
|
|
904
|
+
elif command.command == ControlToHardwareMove.MOVE_ABS:
|
|
893
905
|
self.move_abs(*command.attribute)
|
|
894
906
|
|
|
895
|
-
elif command.command ==
|
|
907
|
+
elif command.command == ControlToHardwareMove.MOVE_REL:
|
|
896
908
|
self.move_rel(*command.attribute)
|
|
897
909
|
|
|
898
|
-
elif command.command ==
|
|
910
|
+
elif command.command == ControlToHardwareMove.MOVE_HOME:
|
|
899
911
|
self.move_home()
|
|
900
912
|
|
|
901
|
-
elif command.command ==
|
|
913
|
+
elif command.command == ControlToHardwareMove.GET_ACTUATOR_VALUE:
|
|
902
914
|
pos = self.get_actuator_value()
|
|
903
|
-
self.status_sig.emit(ThreadCommand(
|
|
915
|
+
self.status_sig.emit(ThreadCommand(ThreadStatusMove.GET_ACTUATOR_VALUE,
|
|
916
|
+
pos))
|
|
904
917
|
|
|
905
|
-
elif command.command ==
|
|
918
|
+
elif command.command == ControlToHardwareMove.STOP_MOTION:
|
|
906
919
|
self.stop_motion()
|
|
907
920
|
|
|
908
|
-
elif command.command ==
|
|
921
|
+
elif command.command == ControlToHardwareMove.RESET_STOP_MOTION:
|
|
909
922
|
self.motion_stoped = False
|
|
910
923
|
|
|
911
924
|
else: # custom commands for particular plugins (see spectrometer module 'get_spectro_wl' for instance)
|
|
@@ -24,7 +24,7 @@ from pymodaq_gui.plotting.data_viewers.viewer import ViewerDispatcher
|
|
|
24
24
|
|
|
25
25
|
from pymodaq.control_modules.utils import ControlModuleUI
|
|
26
26
|
from pymodaq.utils.data import DataToExport, DataActuator
|
|
27
|
-
|
|
27
|
+
from pymodaq.control_modules.thread_commands import UiToMainMove
|
|
28
28
|
|
|
29
29
|
config = Config()
|
|
30
30
|
|
|
@@ -308,14 +308,15 @@ class DAQ_Move_UI(ControlModuleUI):
|
|
|
308
308
|
self.connect_action('show_settings', lambda show: self.settings_ui.setVisible(show))
|
|
309
309
|
self.connect_action('show_graph', lambda show: self.graph_ui.setVisible(show))
|
|
310
310
|
|
|
311
|
-
self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand(
|
|
311
|
+
self.connect_action('quit', lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.QUIT, )))
|
|
312
312
|
self.connect_action('refresh_value',
|
|
313
|
-
lambda do_refresh: self.command_sig.emit(ThreadCommand(
|
|
313
|
+
lambda do_refresh: self.command_sig.emit(ThreadCommand(UiToMainMove.LOOP_GET_VALUE,
|
|
314
|
+
do_refresh)))
|
|
314
315
|
self.connect_action('move_abs', lambda: self.emit_move_abs(self.abs_value_sb))
|
|
315
316
|
self.connect_action('move_abs_2', lambda: self.emit_move_abs(self.abs_value_sb_2))
|
|
316
|
-
self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand(
|
|
317
|
-
self.connect_action('stop', lambda: self.command_sig.emit(ThreadCommand(
|
|
318
|
-
self.connect_action('show_config', lambda: self.command_sig.emit(ThreadCommand(
|
|
317
|
+
self.connect_action('log', lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.SHOW_LOG, )))
|
|
318
|
+
self.connect_action('stop', lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.STOP, )))
|
|
319
|
+
self.connect_action('show_config', lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.SHOW_CONFIG, )))
|
|
319
320
|
|
|
320
321
|
self.move_abs_pb.clicked.connect(lambda: self.emit_move_abs(self.abs_value_sb_bis))
|
|
321
322
|
self.abs_value_sb.shortcut["Ctrl+E"].activated.connect(lambda: self.emit_move_abs(self.abs_value_sb))
|
|
@@ -324,20 +325,20 @@ class DAQ_Move_UI(ControlModuleUI):
|
|
|
324
325
|
|
|
325
326
|
|
|
326
327
|
self.rel_value_sb.valueChanged.connect(lambda: self.command_sig.emit(
|
|
327
|
-
ThreadCommand(
|
|
328
|
+
ThreadCommand(UiToMainMove.REL_VALUE, self.rel_value_sb.value())))
|
|
328
329
|
self.move_rel_plus_pb.clicked.connect(lambda: self.emit_move_rel('+'))
|
|
329
330
|
self.move_rel_minus_pb.clicked.connect(lambda: self.emit_move_rel('-'))
|
|
330
331
|
self.rel_value_sb.shortcut["Ctrl+E"].activated.connect(lambda: self.emit_move_rel('+'))
|
|
331
332
|
self.rel_value_sb.shortcut["Ctrl+Shift+E"].activated.connect(lambda: self.emit_move_rel('-'))
|
|
332
333
|
|
|
333
|
-
self.find_home_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(
|
|
334
|
-
self.stop_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(
|
|
335
|
-
self.get_value_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(
|
|
334
|
+
self.find_home_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.FIND_HOME, )))
|
|
335
|
+
self.stop_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.STOP, )))
|
|
336
|
+
self.get_value_pb.clicked.connect(lambda: self.command_sig.emit(ThreadCommand(UiToMainMove.GET_VALUE, )))
|
|
336
337
|
|
|
337
338
|
self.ini_actuator_pb.clicked.connect(self.send_init)
|
|
338
339
|
|
|
339
340
|
self.actuators_combo.currentTextChanged.connect(
|
|
340
|
-
lambda act: self.command_sig.emit(ThreadCommand(
|
|
341
|
+
lambda act: self.command_sig.emit(ThreadCommand(UiToMainMove.ACTUATOR_CHANGED, act)))
|
|
341
342
|
|
|
342
343
|
def do_init(self, do_init=True):
|
|
343
344
|
"""Programmatically press the Init button
|
|
@@ -352,17 +353,17 @@ class DAQ_Move_UI(ControlModuleUI):
|
|
|
352
353
|
|
|
353
354
|
def send_init(self, checked):
|
|
354
355
|
self.actuators_combo.setEnabled(not checked)
|
|
355
|
-
self.command_sig.emit(ThreadCommand(
|
|
356
|
+
self.command_sig.emit(ThreadCommand(UiToMainMove.INIT, [self.ini_actuator_pb.isChecked(),
|
|
356
357
|
self.actuators_combo.currentText()]))
|
|
357
358
|
|
|
358
359
|
def emit_move_abs(self, spinbox):
|
|
359
360
|
spinbox.editingFinished.emit()
|
|
360
|
-
self.command_sig.emit(ThreadCommand(
|
|
361
|
+
self.command_sig.emit(ThreadCommand(UiToMainMove.MOVE_ABS, DataActuator(data=spinbox.value(),
|
|
361
362
|
units=self._unit)))
|
|
362
363
|
|
|
363
364
|
def emit_move_rel(self, sign):
|
|
364
365
|
self.command_sig.emit(ThreadCommand(
|
|
365
|
-
|
|
366
|
+
UiToMainMove.MOVE_REL,
|
|
366
367
|
DataActuator(data=self.rel_value_sb.value() * (1 if sign == '+' else -1),
|
|
367
368
|
units=self._unit)))
|
|
368
369
|
|
|
@@ -384,7 +385,7 @@ def main(init_qt=True):
|
|
|
384
385
|
|
|
385
386
|
def print_command_sig(cmd_sig):
|
|
386
387
|
print(cmd_sig)
|
|
387
|
-
if cmd_sig.command ==
|
|
388
|
+
if cmd_sig.command == UiToMainMove.INIT:
|
|
388
389
|
prog.enable_move_buttons(True)
|
|
389
390
|
|
|
390
391
|
prog.command_sig.connect(print_command_sig)
|