pymodaq 5.0.17__py3-none-any.whl → 5.1.0__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/__init__.py +23 -11
- pymodaq/control_modules/__init__.py +1 -0
- pymodaq/control_modules/daq_move.py +458 -246
- pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/factory.py +48 -0
- pymodaq/control_modules/{daq_move_ui.py → daq_move_ui/ui_base.py} +168 -210
- pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
- pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
- pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
- pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
- pymodaq/control_modules/daq_viewer.py +113 -101
- pymodaq/control_modules/daq_viewer_ui.py +41 -31
- pymodaq/control_modules/mocks.py +2 -2
- pymodaq/control_modules/move_utility_classes.py +113 -41
- pymodaq/control_modules/thread_commands.py +137 -0
- pymodaq/control_modules/ui_utils.py +72 -0
- pymodaq/control_modules/utils.py +107 -63
- pymodaq/control_modules/viewer_utility_classes.py +13 -17
- pymodaq/dashboard.py +1294 -625
- pymodaq/examples/qt_less_standalone_module.py +48 -11
- pymodaq/extensions/__init__.py +8 -3
- pymodaq/extensions/adaptive/__init__.py +2 -0
- pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
- pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
- pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
- pymodaq/extensions/adaptive/utils.py +123 -0
- pymodaq/extensions/bayesian/__init__.py +1 -1
- pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
- pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
- pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
- pymodaq/extensions/bayesian/utils.py +71 -297
- pymodaq/extensions/daq_logger/daq_logger.py +7 -12
- pymodaq/extensions/daq_logger/h5logging.py +1 -1
- pymodaq/extensions/daq_scan.py +30 -55
- pymodaq/extensions/data_mixer/__init__.py +0 -0
- pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
- pymodaq/extensions/data_mixer/data_mixer.py +262 -0
- pymodaq/extensions/data_mixer/model.py +108 -0
- pymodaq/extensions/data_mixer/models/__init__.py +0 -0
- pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
- pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
- pymodaq/extensions/data_mixer/parser.py +53 -0
- pymodaq/extensions/data_mixer/utils.py +23 -0
- pymodaq/extensions/h5browser.py +3 -34
- pymodaq/extensions/optimizers_base/__init__.py +0 -0
- pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
- pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
- pymodaq/extensions/optimizers_base/utils.py +427 -0
- pymodaq/extensions/pid/actuator_controller.py +3 -2
- pymodaq/extensions/pid/daq_move_PID.py +107 -30
- pymodaq/extensions/pid/pid_controller.py +613 -287
- pymodaq/extensions/pid/utils.py +8 -5
- pymodaq/extensions/utils.py +17 -2
- pymodaq/resources/config_template.toml +57 -0
- pymodaq/resources/preset_default.xml +1 -1
- pymodaq/utils/config.py +13 -4
- pymodaq/utils/daq_utils.py +14 -0
- pymodaq/utils/data.py +1 -0
- pymodaq/utils/gui_utils/loader_utils.py +25 -15
- pymodaq/utils/h5modules/module_saving.py +134 -22
- pymodaq/utils/leco/daq_move_LECODirector.py +123 -84
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +84 -97
- pymodaq/utils/leco/director_utils.py +32 -16
- pymodaq/utils/leco/leco_director.py +104 -27
- pymodaq/utils/leco/pymodaq_listener.py +186 -97
- pymodaq/utils/leco/rpc_method_definitions.py +43 -0
- pymodaq/utils/leco/utils.py +25 -25
- pymodaq/utils/managers/batchscan_manager.py +12 -11
- pymodaq/utils/managers/modules_manager.py +74 -33
- pymodaq/utils/managers/overshoot_manager.py +11 -10
- pymodaq/utils/managers/preset_manager.py +100 -64
- pymodaq/utils/managers/preset_manager_utils.py +163 -107
- pymodaq/utils/managers/remote_manager.py +21 -16
- pymodaq/utils/scanner/scan_factory.py +18 -4
- pymodaq/utils/scanner/scan_selector.py +1 -3
- pymodaq/utils/scanner/scanner.py +35 -6
- pymodaq/utils/scanner/scanners/_1d_scanners.py +15 -46
- pymodaq/utils/scanner/scanners/_2d_scanners.py +21 -68
- pymodaq/utils/scanner/scanners/sequential.py +50 -31
- pymodaq/utils/scanner/scanners/tabular.py +45 -28
- {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/METADATA +7 -6
- pymodaq-5.1.0.dist-info/RECORD +154 -0
- {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/entry_points.txt +0 -2
- pymodaq/extensions/bayesian/bayesian_optimisation.py +0 -685
- pymodaq/utils/leco/desktop.ini +0 -2
- pymodaq-5.0.17.dist-info/RECORD +0 -121
- {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/WHEEL +0 -0
- {pymodaq-5.0.17.dist-info → pymodaq-5.1.0.dist-info}/licenses/LICENSE +0 -0
pymodaq/control_modules/utils.py
CHANGED
|
@@ -5,28 +5,30 @@ Created the 03/10/2022
|
|
|
5
5
|
@author: Sebastien Weber
|
|
6
6
|
"""
|
|
7
7
|
from random import randint
|
|
8
|
-
from typing import Optional, Type
|
|
9
|
-
|
|
8
|
+
from typing import Optional, Type, Union
|
|
10
9
|
from easydict import EasyDict as edict
|
|
11
10
|
|
|
12
|
-
from qtpy import QtCore
|
|
13
11
|
from qtpy.QtCore import Signal, QObject, Qt, Slot, QThread
|
|
14
12
|
|
|
13
|
+
from pymodaq.control_modules.thread_commands import ThreadStatus
|
|
15
14
|
from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val
|
|
16
15
|
from pymodaq_utils.config import Config
|
|
17
|
-
from pymodaq_utils.enums import BaseEnum
|
|
16
|
+
from pymodaq_utils.enums import BaseEnum
|
|
18
17
|
from pymodaq_utils.logger import get_base_logger, set_logger, get_module_name
|
|
19
18
|
|
|
20
|
-
from pymodaq_gui.utils.custom_app import CustomApp
|
|
21
19
|
from pymodaq_gui.parameter import Parameter, ioxml
|
|
20
|
+
from pymodaq_gui.parameter.utils import ParameterWithPath
|
|
22
21
|
from pymodaq_gui.managers.parameter_manager import ParameterManager
|
|
23
22
|
from pymodaq_gui.plotting.data_viewers import ViewersEnum
|
|
23
|
+
from pymodaq_gui.h5modules.saving import H5Saver
|
|
24
24
|
|
|
25
25
|
from pymodaq.utils.tcp_ip.tcp_server_client import TCPClient
|
|
26
26
|
from pymodaq.utils.exceptions import DetectorError
|
|
27
27
|
from pymodaq.utils.leco.pymodaq_listener import ActorListener, LECOClientCommands, LECOCommands
|
|
28
28
|
|
|
29
29
|
from pymodaq.utils.daq_utils import get_plugins
|
|
30
|
+
from pymodaq.utils.h5modules.module_saving import DetectorSaver, ActuatorSaver
|
|
31
|
+
from pymodaq.utils.config import Config as ControlModulesConfig
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
class DAQTypesEnum(BaseEnum):
|
|
@@ -77,7 +79,8 @@ if len(DET_TYPES['DAQ0D']) == 0:
|
|
|
77
79
|
raise DetectorError('No installed Detector')
|
|
78
80
|
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
config_utils = Config()
|
|
83
|
+
config = ControlModulesConfig()
|
|
81
84
|
logger = set_logger(get_module_name(__file__))
|
|
82
85
|
|
|
83
86
|
|
|
@@ -130,12 +133,51 @@ class ControlModule(QObject):
|
|
|
130
133
|
self._send_to_tcpip = False
|
|
131
134
|
self._tcpclient_thread = None
|
|
132
135
|
self._hardware_thread = None
|
|
133
|
-
|
|
136
|
+
|
|
134
137
|
self.plugin_config: Optional[Config] = None
|
|
135
138
|
|
|
139
|
+
self._h5saver: Optional[H5Saver] = None
|
|
140
|
+
self._module_and_data_saver = None
|
|
141
|
+
|
|
136
142
|
def __repr__(self):
|
|
137
143
|
return f'{self.__class__.__name__}: {self.title}'
|
|
138
144
|
|
|
145
|
+
def create_new_file(self, new_file: bool):
|
|
146
|
+
if new_file:
|
|
147
|
+
self.close_file()
|
|
148
|
+
|
|
149
|
+
self.module_and_data_saver.h5saver = self.h5saver
|
|
150
|
+
return True
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def h5saver(self):
|
|
154
|
+
if self._h5saver is None:
|
|
155
|
+
self._h5saver = H5Saver(backend=config_utils('general', 'hdf5_backend'))
|
|
156
|
+
if self._h5saver.h5_file is None:
|
|
157
|
+
self._h5saver.init_file(update_h5=True)
|
|
158
|
+
if not self._h5saver.isopen():
|
|
159
|
+
self._h5saver.init_file(addhoc_file_path=self._h5saver.settings['current_h5_file'])
|
|
160
|
+
return self._h5saver
|
|
161
|
+
|
|
162
|
+
@h5saver.setter
|
|
163
|
+
def h5saver(self, h5saver_temp: H5Saver):
|
|
164
|
+
self._h5saver = h5saver_temp
|
|
165
|
+
|
|
166
|
+
def close_file(self):
|
|
167
|
+
self.h5saver.close_file()
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def module_and_data_saver(self):
|
|
171
|
+
if not self._module_and_data_saver.h5saver.isopen():
|
|
172
|
+
self._module_and_data_saver.h5saver = self.h5saver
|
|
173
|
+
return self._module_and_data_saver
|
|
174
|
+
|
|
175
|
+
@module_and_data_saver.setter
|
|
176
|
+
def module_and_data_saver(self, mod: Union[DetectorSaver, ActuatorSaver]):
|
|
177
|
+
self._module_and_data_saver = mod
|
|
178
|
+
self._module_and_data_saver.h5saver = self.h5saver
|
|
179
|
+
|
|
180
|
+
|
|
139
181
|
def custom_command(self, command: str, **kwargs):
|
|
140
182
|
self.command_hardware.emit(ThreadCommand(command, kwargs))
|
|
141
183
|
|
|
@@ -161,25 +203,23 @@ class ControlModule(QObject):
|
|
|
161
203
|
"""
|
|
162
204
|
|
|
163
205
|
if status.command == "Update_Status":
|
|
206
|
+
# legacy
|
|
164
207
|
if len(status.attribute) > 1:
|
|
165
208
|
self.update_status(status.attribute[0], log=status.attribute[1])
|
|
166
209
|
else:
|
|
167
210
|
self.update_status(status.attribute[0])
|
|
168
211
|
|
|
169
|
-
elif status.command ==
|
|
212
|
+
elif status.command == ThreadStatus.UPDATE_STATUS:
|
|
170
213
|
self.update_status(status.attribute)
|
|
171
214
|
|
|
172
|
-
elif status.command ==
|
|
215
|
+
elif status.command == ThreadStatus.CLOSE:
|
|
173
216
|
try:
|
|
174
217
|
self.update_status(status.attribute[0])
|
|
175
218
|
self._hardware_thread.quit()
|
|
176
|
-
self._hardware_thread.wait()
|
|
177
|
-
|
|
178
|
-
if finished:
|
|
179
|
-
pass
|
|
180
|
-
else:
|
|
181
|
-
print('Thread still running')
|
|
219
|
+
terminated = self._hardware_thread.wait(5000)
|
|
220
|
+
if not terminated:
|
|
182
221
|
self._hardware_thread.terminate()
|
|
222
|
+
self._hardware_thread.wait()
|
|
183
223
|
self.update_status('thread is locked?!', 'log')
|
|
184
224
|
except Exception as e:
|
|
185
225
|
logger.exception(f'Wrong call to the "close" command: \n{str(e)}')
|
|
@@ -187,7 +227,7 @@ class ControlModule(QObject):
|
|
|
187
227
|
self._initialized_state = False
|
|
188
228
|
self.init_signal.emit(self._initialized_state)
|
|
189
229
|
|
|
190
|
-
elif status.command ==
|
|
230
|
+
elif status.command == ThreadStatus.UPDATE_MAIN_SETTINGS:
|
|
191
231
|
# this is a way for the plugins to update main settings of the ui (solely values, limits and options)
|
|
192
232
|
try:
|
|
193
233
|
if status.attribute[2] == 'value':
|
|
@@ -199,7 +239,7 @@ class ControlModule(QObject):
|
|
|
199
239
|
except Exception as e:
|
|
200
240
|
logger.exception(f'Wrong call to the "update_main_settings" command: \n{str(e)}')
|
|
201
241
|
|
|
202
|
-
elif status.command ==
|
|
242
|
+
elif status.command == ThreadStatus.UPDATE_SETTINGS:
|
|
203
243
|
# using this the settings shown in the UI for the plugin reflects the real plugin settings
|
|
204
244
|
try:
|
|
205
245
|
self.settings.sigTreeStateChanged.disconnect(
|
|
@@ -227,7 +267,7 @@ class ControlModule(QObject):
|
|
|
227
267
|
logger.exception(f'Wrong call to the "update_settings" command: \n{str(e)}')
|
|
228
268
|
self.settings.sigTreeStateChanged.connect(self.parameter_tree_changed)
|
|
229
269
|
|
|
230
|
-
elif status.command ==
|
|
270
|
+
elif status.command == ThreadStatus.UPDATE_UI:
|
|
231
271
|
try:
|
|
232
272
|
if self.ui is not None:
|
|
233
273
|
if hasattr(self.ui, status.attribute):
|
|
@@ -236,16 +276,16 @@ class ControlModule(QObject):
|
|
|
236
276
|
except Exception as e:
|
|
237
277
|
logger.info(f'Wrong call to the "update_ui" command: \n{str(e)}')
|
|
238
278
|
|
|
239
|
-
elif status.command ==
|
|
279
|
+
elif status.command == ThreadStatus.RAISE_TIMEOUT:
|
|
240
280
|
self.raise_timeout()
|
|
241
281
|
|
|
242
|
-
elif status.command ==
|
|
282
|
+
elif status.command == ThreadStatus.SHOW_SPLASH:
|
|
243
283
|
self.settings_tree.setEnabled(False)
|
|
244
284
|
self.splash_sc.show()
|
|
245
285
|
self.splash_sc.raise_()
|
|
246
286
|
self.splash_sc.showMessage(status.attribute, color=Qt.white)
|
|
247
287
|
|
|
248
|
-
elif status.command ==
|
|
288
|
+
elif status.command == ThreadStatus.CLOSE_SPLASH:
|
|
249
289
|
self.splash_sc.close()
|
|
250
290
|
self.settings_tree.setEnabled(True)
|
|
251
291
|
|
|
@@ -328,9 +368,9 @@ class ControlModule(QObject):
|
|
|
328
368
|
config_tree = TreeFromToml(config)
|
|
329
369
|
config_tree.show_dialog()
|
|
330
370
|
|
|
331
|
-
return
|
|
371
|
+
return ControlModulesConfig()
|
|
332
372
|
|
|
333
|
-
def update_status(self, txt, log=True):
|
|
373
|
+
def update_status(self, txt: str, log=True):
|
|
334
374
|
"""Display a message in the ui status bar and eventually log the message
|
|
335
375
|
|
|
336
376
|
Parameters
|
|
@@ -431,7 +471,9 @@ class ParameterControlModule(ParameterManager, ControlModule):
|
|
|
431
471
|
if self.settings.child('main_settings', 'tcpip', 'tcp_connected').value():
|
|
432
472
|
self._command_tcpip.emit(ThreadCommand('send_info', dict(path=path, param=param)))
|
|
433
473
|
if self.settings.child('main_settings', 'leco', 'leco_connected').value():
|
|
434
|
-
self._command_tcpip.emit(
|
|
474
|
+
self._command_tcpip.emit(
|
|
475
|
+
ThreadCommand(LECOCommands.SEND_INFO,
|
|
476
|
+
ParameterWithPath(param, path)))
|
|
435
477
|
|
|
436
478
|
def connect_tcp_ip(self, params_state=None, client_type: str = "GRABBER") -> None:
|
|
437
479
|
"""Init a TCPClient in a separated thread to communicate with a distant TCp/IP Server
|
|
@@ -469,17 +511,29 @@ class ParameterControlModule(ParameterManager, ControlModule):
|
|
|
469
511
|
name = self.settings.child("main_settings", "leco", "leco_name").setValue(name)
|
|
470
512
|
return name
|
|
471
513
|
|
|
514
|
+
def get_leco_host_port(self) -> tuple:
|
|
515
|
+
host = self.settings["main_settings", "leco", "host"]
|
|
516
|
+
port = self.settings["main_settings", "leco", "port"]
|
|
517
|
+
if host == '':
|
|
518
|
+
# take the localhost as default
|
|
519
|
+
host = 'localhost'
|
|
520
|
+
if port == '':
|
|
521
|
+
# take the default port as 12300
|
|
522
|
+
port = 12300
|
|
523
|
+
return (host, port)
|
|
524
|
+
|
|
472
525
|
def connect_leco(self, connect: bool) -> None:
|
|
473
526
|
if connect:
|
|
474
527
|
name = self.get_leco_name()
|
|
528
|
+
host, port = self.get_leco_host_port()
|
|
475
529
|
try:
|
|
476
530
|
self._leco_client.name = name
|
|
477
531
|
except AttributeError:
|
|
478
|
-
self._leco_client = self.listener_class(name=name)
|
|
532
|
+
self._leco_client = self.listener_class(name=name, host=host, port=port)
|
|
479
533
|
self._leco_client.cmd_signal.connect(self.process_tcpip_cmds)
|
|
480
534
|
self._command_tcpip[ThreadCommand].connect(self._leco_client.queue_command)
|
|
481
535
|
self._leco_client.start_listen()
|
|
482
|
-
# self._leco_client.cmd_signal.emit(ThreadCommand(
|
|
536
|
+
# self._leco_client.cmd_signal.emit(ThreadCommand(LECOCommands.SET_INFO, attribute=["detector_settings", ""]))
|
|
483
537
|
else:
|
|
484
538
|
self._command_tcpip.emit(ThreadCommand(LECOCommands.QUIT, ))
|
|
485
539
|
try:
|
|
@@ -504,45 +558,35 @@ class ParameterControlModule(ParameterManager, ControlModule):
|
|
|
504
558
|
elif status.command == 'Update_Status':
|
|
505
559
|
self.thread_status(status)
|
|
506
560
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
See specific implementation
|
|
561
|
+
elif status.command == 'set_info':
|
|
562
|
+
""" The Director sent a parameter to be updated"""
|
|
563
|
+
path_in_settings = status.attribute.path
|
|
564
|
+
if 'move' in self.__class__.__name__.lower():
|
|
565
|
+
common_param = 'move_settings'
|
|
566
|
+
else:
|
|
567
|
+
common_param = 'detector_settings'
|
|
568
|
+
if common_param in path_in_settings:
|
|
569
|
+
param = self.settings.child(*path_in_settings)
|
|
570
|
+
elif 'settings_client' in path_in_settings:
|
|
571
|
+
param = self.settings.child(common_param, *path_in_settings[1:])
|
|
572
|
+
else:
|
|
573
|
+
param = self.settings.child(common_param, *path_in_settings)
|
|
521
574
|
|
|
522
|
-
|
|
523
|
-
--------
|
|
524
|
-
:class:`daq_move_ui.DAQ_Move_UI`, :class:`daq_viewer_ui.DAQ_Viewer_UI`
|
|
525
|
-
"""
|
|
526
|
-
command_sig = QtCore.Signal(ThreadCommand)
|
|
575
|
+
param.setValue(status.attribute.parameter.value())
|
|
527
576
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
577
|
+
elif status.command == LECOCommands.GET_SETTINGS:
|
|
578
|
+
""" The Director requested the content of the actuator settings"""
|
|
579
|
+
if 'move' in self.__class__.__name__.lower():
|
|
580
|
+
common_param = 'move_settings'
|
|
581
|
+
else:
|
|
582
|
+
common_param = 'detector_settings'
|
|
583
|
+
self._command_tcpip.emit(
|
|
584
|
+
ThreadCommand(LECOCommands.SET_DIRECTOR_SETTINGS,
|
|
585
|
+
ioxml.parameter_to_xml_string(
|
|
586
|
+
self.settings.child(common_param))))
|
|
531
587
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
588
|
+
else:
|
|
589
|
+
# not handled
|
|
590
|
+
return status
|
|
535
591
|
|
|
536
|
-
def do_init(self, do_init=True):
|
|
537
|
-
"""Programmatically press the Init button
|
|
538
|
-
API entry
|
|
539
|
-
Parameters
|
|
540
|
-
----------
|
|
541
|
-
do_init: bool
|
|
542
|
-
will fire the Init button depending on the argument value and the button check state
|
|
543
|
-
"""
|
|
544
|
-
raise NotImplementedError
|
|
545
592
|
|
|
546
|
-
def send_init(self, checked: bool):
|
|
547
|
-
"""Should be implemented to send to the main app the fact that someone (un)checked init."""
|
|
548
|
-
raise NotImplementedError
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
1
2
|
from typing import Union, Iterable
|
|
2
3
|
from qtpy import QtWidgets
|
|
3
4
|
from qtpy.QtCore import QObject, Slot, Signal
|
|
@@ -18,7 +19,7 @@ from pymodaq_utils.warnings import deprecation_msg
|
|
|
18
19
|
from pymodaq_utils.serialize.mysocket import Socket
|
|
19
20
|
from pymodaq_utils.serialize.serializer_legacy import DeSerializer, Serializer
|
|
20
21
|
from pymodaq_gui.plotting.utils.plot_utils import RoiInfo
|
|
21
|
-
|
|
22
|
+
from pymodaq.control_modules.thread_commands import ThreadStatus, ThreadStatusViewer
|
|
22
23
|
from pymodaq_gui.utils.utils import mkQApp
|
|
23
24
|
|
|
24
25
|
comon_parameters = [{'title': 'Controller Status:', 'name': 'controller_status', 'type': 'list',
|
|
@@ -267,6 +268,7 @@ class DAQ_Viewer_base(QObject):
|
|
|
267
268
|
self.controller = controller
|
|
268
269
|
return controller
|
|
269
270
|
|
|
271
|
+
@abstractmethod
|
|
270
272
|
def ini_detector(self, controller=None):
|
|
271
273
|
"""
|
|
272
274
|
Mandatory
|
|
@@ -274,6 +276,7 @@ class DAQ_Viewer_base(QObject):
|
|
|
274
276
|
"""
|
|
275
277
|
raise NotImplementedError
|
|
276
278
|
|
|
279
|
+
@abstractmethod
|
|
277
280
|
def close(self):
|
|
278
281
|
"""
|
|
279
282
|
Mandatory
|
|
@@ -281,6 +284,7 @@ class DAQ_Viewer_base(QObject):
|
|
|
281
284
|
"""
|
|
282
285
|
raise NotImplementedError
|
|
283
286
|
|
|
287
|
+
@abstractmethod
|
|
284
288
|
def grab_data(self, Naverage=1, **kwargs):
|
|
285
289
|
"""
|
|
286
290
|
Mandatory
|
|
@@ -288,6 +292,7 @@ class DAQ_Viewer_base(QObject):
|
|
|
288
292
|
"""
|
|
289
293
|
raise NotImplementedError
|
|
290
294
|
|
|
295
|
+
@abstractmethod
|
|
291
296
|
def stop(self):
|
|
292
297
|
"""
|
|
293
298
|
Mandatory
|
|
@@ -328,15 +333,6 @@ class DAQ_Viewer_base(QObject):
|
|
|
328
333
|
"""
|
|
329
334
|
pass
|
|
330
335
|
|
|
331
|
-
def get_axis(self):
|
|
332
|
-
"""deprecated"""
|
|
333
|
-
raise DeprecationWarning('get_axis is deprecated add the axes within the DataWithAxes, '
|
|
334
|
-
'DataFromPlugins')
|
|
335
|
-
if self.plugin_type == '1D' or self.plugin_type == '2D':
|
|
336
|
-
self.emit_x_axis()
|
|
337
|
-
|
|
338
|
-
if self.plugin_type == '2D':
|
|
339
|
-
self.emit_y_axis()
|
|
340
336
|
|
|
341
337
|
def emit_status(self, status: ThreadCommand):
|
|
342
338
|
"""
|
|
@@ -400,8 +396,7 @@ class DAQ_Viewer_base(QObject):
|
|
|
400
396
|
|
|
401
397
|
self.commit_settings(param)
|
|
402
398
|
except Exception as e:
|
|
403
|
-
self.emit_status(ThreadCommand(
|
|
404
|
-
|
|
399
|
+
self.emit_status(ThreadCommand(ThreadStatus.UPDATE_STATUS, str(e)))
|
|
405
400
|
|
|
406
401
|
|
|
407
402
|
def send_param_status(self, param, changes):
|
|
@@ -423,13 +418,14 @@ class DAQ_Viewer_base(QObject):
|
|
|
423
418
|
path = self.settings.childPath(param)
|
|
424
419
|
if change == 'childAdded':
|
|
425
420
|
# first create a "copy" of the actual parameter and send this "copy", to be restored in the main UI
|
|
426
|
-
self.emit_status(ThreadCommand(
|
|
421
|
+
self.emit_status(ThreadCommand(ThreadStatus.UPDATE_SETTINGS,
|
|
427
422
|
[self.parent_parameters_path + path, [data[0].saveState(), data[1]],
|
|
428
423
|
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
|
|
429
424
|
|
|
430
425
|
elif change == 'value' or change == 'limits' or change == 'options':
|
|
431
|
-
self.emit_status(ThreadCommand(
|
|
432
|
-
|
|
426
|
+
self.emit_status(ThreadCommand(ThreadStatus.UPDATE_SETTINGS,
|
|
427
|
+
[self.parent_parameters_path + path, data,
|
|
428
|
+
change])) # send parameters values/limits back to the GUI
|
|
433
429
|
elif change == 'parent':
|
|
434
430
|
pass
|
|
435
431
|
|
|
@@ -544,7 +540,7 @@ class DAQ_Viewer_TCP_server(DAQ_Viewer_base, TCPServer):
|
|
|
544
540
|
self.send_data(command_sock, data) # to be send to a client
|
|
545
541
|
|
|
546
542
|
except Exception as e:
|
|
547
|
-
self.emit_status(ThreadCommand(
|
|
543
|
+
self.emit_status(ThreadCommand(ThreadStatus.UPDATE_STATUS, str(e)))
|
|
548
544
|
|
|
549
545
|
def commit_settings(self, param):
|
|
550
546
|
|
|
@@ -640,7 +636,7 @@ class DAQ_Viewer_TCP_server(DAQ_Viewer_base, TCPServer):
|
|
|
640
636
|
# self.command_server.emit(["process_cmds","Send Data 2D"])
|
|
641
637
|
|
|
642
638
|
except Exception as e:
|
|
643
|
-
self.emit_status(ThreadCommand(
|
|
639
|
+
self.emit_status(ThreadCommand(ThreadStatus.UPDATE_STATUS, str(e)))
|
|
644
640
|
|
|
645
641
|
def stop(self):
|
|
646
642
|
"""
|