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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List, Union, TYPE_CHECKING
|
|
1
|
+
from typing import List, Union, TYPE_CHECKING, Optional, Sequence
|
|
2
2
|
|
|
3
3
|
from collections import OrderedDict
|
|
4
4
|
from qtpy.QtCore import QObject, Signal, Slot, QThread
|
|
@@ -15,14 +15,16 @@ from pymodaq_gui.managers.parameter_manager import ParameterManager
|
|
|
15
15
|
from pymodaq_gui.utils import Dock
|
|
16
16
|
|
|
17
17
|
from pymodaq.utils.data import DataActuator
|
|
18
|
-
|
|
18
|
+
from pymodaq.utils.config import Config as ControlModulesConfig
|
|
19
19
|
|
|
20
20
|
if TYPE_CHECKING:
|
|
21
21
|
from pymodaq.control_modules.daq_viewer import DAQ_Viewer
|
|
22
22
|
from pymodaq.control_modules.daq_move import DAQ_Move
|
|
23
23
|
|
|
24
24
|
logger = set_logger(get_module_name(__file__))
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
config_utils = Config()
|
|
27
|
+
config = ControlModulesConfig()
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
class ModulesManager(QObject, ParameterManager):
|
|
@@ -68,9 +70,26 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
68
70
|
]},
|
|
69
71
|
]
|
|
70
72
|
|
|
71
|
-
def __init__(self,
|
|
73
|
+
def __init__(self,
|
|
74
|
+
detectors: Optional[Sequence['DAQ_Viewer']] = None,
|
|
75
|
+
actuators: Optional[Sequence['DAQ_Move']] = None,
|
|
76
|
+
selected_detectors: Optional[Sequence['DAQ_Viewer']] = None,
|
|
77
|
+
selected_actuators: Optional[Sequence['DAQ_Move']] = None,
|
|
78
|
+
parent_name='',
|
|
79
|
+
**kwargs):
|
|
80
|
+
|
|
72
81
|
QObject.__init__(self)
|
|
73
82
|
ParameterManager.__init__(self)
|
|
83
|
+
if detectors is None:
|
|
84
|
+
detectors = []
|
|
85
|
+
if actuators is None:
|
|
86
|
+
actuators = []
|
|
87
|
+
if selected_detectors is None:
|
|
88
|
+
selected_detectors = []
|
|
89
|
+
if selected_actuators is None:
|
|
90
|
+
selected_actuators = []
|
|
91
|
+
|
|
92
|
+
self.parent_name = parent_name
|
|
74
93
|
|
|
75
94
|
for mod in selected_actuators:
|
|
76
95
|
assert mod in actuators
|
|
@@ -100,6 +119,9 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
100
119
|
self.set_actuators(actuators, selected_actuators)
|
|
101
120
|
self.set_detectors(detectors, selected_detectors)
|
|
102
121
|
|
|
122
|
+
def __repr__(self):
|
|
123
|
+
return f'ModulesManager of "{self.parent_name}" with control modules: {self.get_names(self.modules_all)}'
|
|
124
|
+
|
|
103
125
|
def show_only_control_modules(self, show: True):
|
|
104
126
|
self.settings.child('move_done').show(not show)
|
|
105
127
|
self.settings.child('det_done').show(not show)
|
|
@@ -197,7 +219,7 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
197
219
|
|
|
198
220
|
@property
|
|
199
221
|
def modules(self):
|
|
200
|
-
"""Get the list of
|
|
222
|
+
"""Get the list of detectors and actuators"""
|
|
201
223
|
return self.detectors + self.actuators
|
|
202
224
|
|
|
203
225
|
@property
|
|
@@ -257,25 +279,28 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
257
279
|
def get_det_data_list(self) -> DataToExport:
|
|
258
280
|
"""Do a snap of selected detectors, to get the list of all the data and processed data"""
|
|
259
281
|
|
|
260
|
-
self.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
282
|
+
if len(self.detectors) == 0:
|
|
283
|
+
return DataToExport(name=__class__.__name__, control_module='DAQ_Viewer')
|
|
284
|
+
else:
|
|
285
|
+
self.connect_detectors()
|
|
286
|
+
datas: DataToExport = self.grab_data()
|
|
287
|
+
|
|
288
|
+
data_list0D = datas.get_full_names('data0D')
|
|
289
|
+
data_list1D = datas.get_full_names('data1D')
|
|
290
|
+
data_list2D = datas.get_full_names('data2D')
|
|
291
|
+
data_listND = datas.get_full_names('dataND')
|
|
292
|
+
|
|
293
|
+
self.settings.child('data_dimensions', 'det_data_list0D').setValue(
|
|
294
|
+
dict(all_items=data_list0D, selected=[]))
|
|
295
|
+
self.settings.child('data_dimensions', 'det_data_list1D').setValue(
|
|
296
|
+
dict(all_items=data_list1D, selected=[]))
|
|
297
|
+
self.settings.child('data_dimensions', 'det_data_list2D').setValue(
|
|
298
|
+
dict(all_items=data_list2D, selected=[]))
|
|
299
|
+
self.settings.child('data_dimensions', 'det_data_listND').setValue(
|
|
300
|
+
dict(all_items=data_listND, selected=[]))
|
|
301
|
+
|
|
302
|
+
self.connect_detectors(False)
|
|
303
|
+
return datas
|
|
279
304
|
|
|
280
305
|
def get_selected_probed_data(self, dim='0D'):
|
|
281
306
|
"""Get the name of selected data names of a given dimensionality
|
|
@@ -287,26 +312,42 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
287
312
|
"""
|
|
288
313
|
return self.settings.child('data_dimensions', f'det_data_list{dim.upper()}').value()['selected']
|
|
289
314
|
|
|
290
|
-
def grab_data(self, **kwargs):
|
|
291
|
-
"""Do a single grab of connected and selected detectors
|
|
315
|
+
def grab_data(self, check_do_override=True, **kwargs):
|
|
316
|
+
"""Do a single grab of connected and selected detectors
|
|
317
|
+
|
|
318
|
+
Parameter
|
|
319
|
+
---------
|
|
320
|
+
check_do_override: bool
|
|
321
|
+
If this is True the signal emission to the DAQ_Viewers will be conditionned to the status of their internal
|
|
322
|
+
override_grab_from_extension attribute
|
|
323
|
+
"""
|
|
292
324
|
self.det_done_datas = DataToExport(name=__class__.__name__, control_module='DAQ_Viewer')
|
|
293
325
|
self._received_data = 0
|
|
294
326
|
self.det_done_flag = False
|
|
295
327
|
self.settings.child('det_done').setValue(self.det_done_flag)
|
|
296
328
|
tzero = time.perf_counter()
|
|
329
|
+
|
|
330
|
+
if 'DataMixer' in self.selected_detectors_name:
|
|
331
|
+
overridden_detectors = self.get_mod_from_name(
|
|
332
|
+
'DataMixer', 'det').settings.child(
|
|
333
|
+
'detector_settings', 'overridden_detectors').opts['limits']
|
|
334
|
+
else:
|
|
335
|
+
overridden_detectors = []
|
|
297
336
|
|
|
298
337
|
for mod in self.detectors:
|
|
299
|
-
|
|
300
|
-
mod.
|
|
338
|
+
#if not (check_do_override and mod.override_grab_from_extension):
|
|
339
|
+
if mod.title not in overridden_detectors:
|
|
340
|
+
kwargs.update(dict(Naverage=mod.Naverage))
|
|
341
|
+
mod.command_hardware.emit(utils.ThreadCommand("single", kwargs))
|
|
301
342
|
|
|
302
343
|
while not self.det_done_flag:
|
|
303
344
|
# wait for grab done signals to end
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if time.perf_counter() - tzero > self.detector_timeout:
|
|
345
|
+
QtWidgets.QApplication.processEvents() # mandatory for the det_done_flag boolean to be modified in the corresponding method
|
|
346
|
+
if time.perf_counter() - tzero > self.detector_timeout / 1000:
|
|
307
347
|
self.timeout_signal.emit(True)
|
|
308
348
|
logger.error('Timeout Fired during waiting for data to be acquired')
|
|
309
349
|
break
|
|
350
|
+
QThread.msleep(10)
|
|
310
351
|
|
|
311
352
|
self.det_done_signal.emit(self.det_done_datas)
|
|
312
353
|
return self.det_done_datas
|
|
@@ -453,12 +494,12 @@ class ModulesManager(QObject, ParameterManager):
|
|
|
453
494
|
if polling:
|
|
454
495
|
while not self.move_done_flag: # polling move done
|
|
455
496
|
|
|
456
|
-
QtWidgets.QApplication.processEvents()
|
|
497
|
+
QtWidgets.QApplication.processEvents() # mandatory for the det_done_flag boolean to be modified in the corresponding method
|
|
457
498
|
if time.perf_counter() - tzero > self.actuator_timeout / 1000: # timeout in seconds
|
|
458
499
|
self.timeout_signal.emit(True)
|
|
459
500
|
logger.error('Timeout Fired during waiting for actuators to be moved')
|
|
460
501
|
break
|
|
461
|
-
QThread.msleep(
|
|
502
|
+
QThread.msleep(10)
|
|
462
503
|
|
|
463
504
|
self.move_done_signal.emit(self.move_done_positions)
|
|
464
505
|
return self.move_done_positions
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from qtpy import QtWidgets
|
|
2
|
+
from qtpy.QtWidgets import QMessageBox, QDialogButtonBox, QDialog
|
|
2
3
|
import sys
|
|
3
4
|
import os
|
|
4
5
|
|
|
@@ -121,13 +122,13 @@ class OvershootManager:
|
|
|
121
122
|
self._activated = False
|
|
122
123
|
|
|
123
124
|
if msgbox:
|
|
124
|
-
msgBox =
|
|
125
|
+
msgBox = QMessageBox()
|
|
125
126
|
msgBox.setText("Overshoot Manager?")
|
|
126
127
|
msgBox.setInformativeText("What do you want to do?")
|
|
127
|
-
cancel_button = msgBox.addButton(
|
|
128
|
-
new_button = msgBox.addButton("New",
|
|
129
|
-
modify_button = msgBox.addButton(
|
|
130
|
-
msgBox.setDefaultButton(
|
|
128
|
+
cancel_button = msgBox.addButton(QMessageBox.StandardButton.Cancel)
|
|
129
|
+
new_button = msgBox.addButton("New", QMessageBox.ButtonRole.ActionRole)
|
|
130
|
+
modify_button = msgBox.addButton("Modify", QMessageBox.ButtonRole.AcceptRole)
|
|
131
|
+
msgBox.setDefaultButton(QMessageBox.StandardButton.Cancel)
|
|
131
132
|
ret = msgBox.exec()
|
|
132
133
|
|
|
133
134
|
if msgBox.clickedButton() == new_button:
|
|
@@ -173,7 +174,7 @@ class OvershootManager:
|
|
|
173
174
|
"""
|
|
174
175
|
|
|
175
176
|
"""
|
|
176
|
-
dialog =
|
|
177
|
+
dialog = QDialog()
|
|
177
178
|
vlayout = QtWidgets.QVBoxLayout()
|
|
178
179
|
tree = ParameterTree()
|
|
179
180
|
tree.setMinimumWidth(400)
|
|
@@ -182,18 +183,18 @@ class OvershootManager:
|
|
|
182
183
|
|
|
183
184
|
vlayout.addWidget(tree)
|
|
184
185
|
dialog.setLayout(vlayout)
|
|
185
|
-
buttonBox =
|
|
186
|
+
buttonBox = QDialogButtonBox(parent=dialog)
|
|
186
187
|
|
|
187
|
-
buttonBox.addButton(
|
|
188
|
+
buttonBox.addButton("Save", QDialogButtonBox.ButtonRole.AcceptRole)
|
|
188
189
|
buttonBox.accepted.connect(dialog.accept)
|
|
189
|
-
buttonBox.addButton(
|
|
190
|
+
buttonBox.addButton("Cancel", QDialogButtonBox.ButtonRole.RejectRole)
|
|
190
191
|
buttonBox.rejected.connect(dialog.reject)
|
|
191
192
|
|
|
192
193
|
vlayout.addWidget(buttonBox)
|
|
193
194
|
dialog.setWindowTitle('Fill in information about this managers')
|
|
194
195
|
res = dialog.exec()
|
|
195
196
|
|
|
196
|
-
if res ==
|
|
197
|
+
if res == QDialog.DialogCode.Accepted:
|
|
197
198
|
# save managers parameters in a xml file
|
|
198
199
|
# start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
|
|
199
200
|
# start = os.path.join("..",'daq_scan')
|
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
import sys
|
|
4
4
|
|
|
5
5
|
from qtpy import QtWidgets
|
|
6
|
+
from qtpy.QtWidgets import QMessageBox, QDialogButtonBox, QDialog
|
|
6
7
|
|
|
7
8
|
import pymodaq_utils.config as config_mod
|
|
8
9
|
from pymodaq_utils.logger import set_logger, get_module_name
|
|
@@ -26,7 +27,6 @@ layout_path = config_mod_pymodaq.get_set_layout_path()
|
|
|
26
27
|
|
|
27
28
|
class PresetManager:
|
|
28
29
|
def __init__(self, msgbox=False, path=None, extra_params=[], param_options=[]):
|
|
29
|
-
|
|
30
30
|
if path is None:
|
|
31
31
|
path = preset_path
|
|
32
32
|
else:
|
|
@@ -38,21 +38,25 @@ class PresetManager:
|
|
|
38
38
|
self.preset_params: Parameter = None
|
|
39
39
|
|
|
40
40
|
if msgbox:
|
|
41
|
-
msgBox =
|
|
41
|
+
msgBox = QMessageBox()
|
|
42
42
|
msgBox.setText("Preset Manager?")
|
|
43
43
|
msgBox.setInformativeText("What do you want to do?")
|
|
44
|
-
cancel_button = msgBox.addButton(
|
|
45
|
-
new_button = msgBox.addButton(
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
cancel_button = msgBox.addButton(QMessageBox.StandardButton.Cancel)
|
|
45
|
+
new_button = msgBox.addButton(
|
|
46
|
+
"New", QMessageBox.ButtonRole.ActionRole
|
|
47
|
+
)
|
|
48
|
+
modify_button = msgBox.addButton(
|
|
49
|
+
"Modify", QMessageBox.ButtonRole.AcceptRole
|
|
50
|
+
)
|
|
51
|
+
msgBox.setDefaultButton(QMessageBox.StandardButton.Cancel)
|
|
48
52
|
ret = msgBox.exec()
|
|
49
53
|
|
|
50
54
|
if msgBox.clickedButton() == new_button:
|
|
51
55
|
self.set_new_preset()
|
|
52
56
|
|
|
53
57
|
elif msgBox.clickedButton() == modify_button:
|
|
54
|
-
path = select_file(start_path=self.preset_path, save=False, ext=
|
|
55
|
-
if path !=
|
|
58
|
+
path = select_file(start_path=self.preset_path, save=False, ext="xml")
|
|
59
|
+
if path != "":
|
|
56
60
|
self.set_file_preset(str(path))
|
|
57
61
|
else: # cancel
|
|
58
62
|
pass
|
|
@@ -60,37 +64,55 @@ class PresetManager:
|
|
|
60
64
|
@property
|
|
61
65
|
def filename(self) -> str:
|
|
62
66
|
try:
|
|
63
|
-
return self.preset_params[
|
|
67
|
+
return self.preset_params["filename"]
|
|
64
68
|
except:
|
|
65
69
|
return None
|
|
66
70
|
|
|
67
71
|
def set_file_preset(self, filename, show=True):
|
|
68
|
-
"""
|
|
69
|
-
|
|
70
|
-
"""
|
|
72
|
+
""" """
|
|
71
73
|
status = False
|
|
72
74
|
children = ioxml.XML_file_to_parameter(filename)
|
|
73
|
-
self.preset_params = Parameter.create(
|
|
75
|
+
self.preset_params = Parameter.create(
|
|
76
|
+
title="Preset", name="Preset", type="group", children=children
|
|
77
|
+
)
|
|
74
78
|
if show:
|
|
75
79
|
status = self.show_preset()
|
|
76
80
|
return status
|
|
77
81
|
|
|
78
|
-
|
|
79
82
|
def set_new_preset(self):
|
|
80
83
|
param = [
|
|
81
|
-
{
|
|
82
|
-
|
|
84
|
+
{
|
|
85
|
+
"title": "Filename:",
|
|
86
|
+
"name": "filename",
|
|
87
|
+
"type": "str",
|
|
88
|
+
"value": "preset_default",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"title": "Model Settings:",
|
|
92
|
+
"name": "model_settings",
|
|
93
|
+
"type": "group",
|
|
94
|
+
"visible": False,
|
|
95
|
+
"children": [],
|
|
96
|
+
},
|
|
83
97
|
]
|
|
84
98
|
params_move = [
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
{"title": "Moves:", "name": "Moves", "type": "groupmove"}
|
|
100
|
+
] # PresetScalableGroupMove(name="Moves")]
|
|
101
|
+
params_det = [
|
|
102
|
+
{"title": "Detectors:", "name": "Detectors", "type": "groupdet"}
|
|
103
|
+
] # [PresetScalableGroupDet(name="Detectors")]
|
|
104
|
+
self.preset_params = Parameter.create(
|
|
105
|
+
title="Preset",
|
|
106
|
+
name="Preset",
|
|
107
|
+
type="group",
|
|
108
|
+
children=param + self.extra_params + params_move + params_det,
|
|
109
|
+
)
|
|
90
110
|
try:
|
|
91
111
|
for option in self.param_options:
|
|
92
|
-
if
|
|
93
|
-
self.preset_params.child(option[
|
|
112
|
+
if "path" in option and "options_dict" in option:
|
|
113
|
+
self.preset_params.child(option["path"]).setOpts(
|
|
114
|
+
**option["options_dict"]
|
|
115
|
+
)
|
|
94
116
|
except Exception as e:
|
|
95
117
|
logger.exception(str(e))
|
|
96
118
|
|
|
@@ -101,91 +123,105 @@ class PresetManager:
|
|
|
101
123
|
|
|
102
124
|
def parameter_tree_changed(self, param, changes):
|
|
103
125
|
"""
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
Check for changes in the given (parameter,change,information) tuple list.
|
|
127
|
+
In case of value changed, update the DAQscan_settings tree consequently.
|
|
128
|
+
|
|
129
|
+
=============== ============================================ ==============================
|
|
130
|
+
**Parameters** **Type** **Description**
|
|
131
|
+
*param* instance of pyqtgraph parameter the parameter to be checked
|
|
132
|
+
*changes* (parameter,change,information) tuple list the current changes state
|
|
133
|
+
=============== ============================================ ==============================
|
|
112
134
|
"""
|
|
113
135
|
for param, change, data in changes:
|
|
114
136
|
path = self.preset_params.childPath(param)
|
|
115
|
-
if change ==
|
|
137
|
+
if change == "childAdded":
|
|
116
138
|
if len(data) > 1:
|
|
117
|
-
if
|
|
118
|
-
data[0].child(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
if "params" in data[0].children():
|
|
140
|
+
data[0].child(
|
|
141
|
+
"params", "main_settings", "module_name"
|
|
142
|
+
).setValue(data[0].child("name").value())
|
|
143
|
+
|
|
144
|
+
elif change == "value":
|
|
145
|
+
if param.name() == "name":
|
|
146
|
+
param.parent().child(
|
|
147
|
+
"params", "main_settings", "module_name"
|
|
148
|
+
).setValue(param.value())
|
|
149
|
+
|
|
150
|
+
elif change == "parent":
|
|
125
151
|
pass
|
|
126
152
|
|
|
127
153
|
def show_preset(self):
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
"""
|
|
131
|
-
dialog = QtWidgets.QDialog()
|
|
154
|
+
""" """
|
|
155
|
+
dialog = QDialog()
|
|
132
156
|
vlayout = QtWidgets.QVBoxLayout()
|
|
133
157
|
tree = ParameterTree()
|
|
134
158
|
# tree.setMinimumWidth(400)
|
|
135
159
|
# tree.setMinimumHeight(500)
|
|
136
160
|
tree.setParameters(self.preset_params, showTop=False)
|
|
161
|
+
tree.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
|
137
162
|
|
|
138
163
|
vlayout.addWidget(tree)
|
|
139
164
|
dialog.setLayout(vlayout)
|
|
140
|
-
buttonBox =
|
|
165
|
+
buttonBox = QDialogButtonBox(parent=dialog)
|
|
141
166
|
|
|
142
|
-
buttonBox.addButton(
|
|
167
|
+
buttonBox.addButton("Save", QDialogButtonBox.ButtonRole.AcceptRole)
|
|
143
168
|
buttonBox.accepted.connect(dialog.accept)
|
|
144
|
-
buttonBox.addButton(
|
|
169
|
+
buttonBox.addButton("Cancel", QDialogButtonBox.ButtonRole.RejectRole)
|
|
145
170
|
buttonBox.rejected.connect(dialog.reject)
|
|
146
171
|
|
|
147
172
|
vlayout.addWidget(buttonBox)
|
|
148
|
-
dialog.setWindowTitle(
|
|
173
|
+
dialog.setWindowTitle("Fill in information about this manager")
|
|
149
174
|
res = dialog.exec()
|
|
150
175
|
|
|
151
176
|
path = self.preset_path
|
|
152
|
-
file= None
|
|
177
|
+
file = None
|
|
153
178
|
|
|
154
|
-
if res ==
|
|
179
|
+
if res == QDialog.DialogCode.Accepted:
|
|
155
180
|
# save managers parameters in a xml file
|
|
156
181
|
# start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
|
|
157
182
|
# start = os.path.join("..",'daq_scan')
|
|
158
183
|
filename_without_extension = self.filename
|
|
159
184
|
|
|
160
185
|
try:
|
|
161
|
-
ioxml.parameter_to_xml_file(
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
ioxml.parameter_to_xml_file(
|
|
187
|
+
self.preset_params,
|
|
188
|
+
path.joinpath(filename_without_extension),
|
|
189
|
+
overwrite=False,
|
|
190
|
+
)
|
|
164
191
|
except FileExistsError as currenterror:
|
|
165
192
|
# logger.warning(str(currenterror)+"File " + filename_without_extension + ".xml exists")
|
|
166
|
-
logger.warning(
|
|
167
|
-
|
|
168
|
-
|
|
193
|
+
logger.warning(
|
|
194
|
+
f"{currenterror} File {filename_without_extension}.xml exists"
|
|
195
|
+
)
|
|
196
|
+
user_agreed = dialogbox(
|
|
197
|
+
title="Overwrite confirmation",
|
|
198
|
+
message="File exist do you want to overwrite it ?",
|
|
199
|
+
)
|
|
169
200
|
if user_agreed:
|
|
170
|
-
ioxml.parameter_to_xml_file(
|
|
171
|
-
|
|
172
|
-
|
|
201
|
+
ioxml.parameter_to_xml_file(
|
|
202
|
+
self.preset_params, path.joinpath(filename_without_extension)
|
|
203
|
+
)
|
|
204
|
+
logger.warning(
|
|
205
|
+
f"File {filename_without_extension}.xml overwriten at user request"
|
|
206
|
+
)
|
|
173
207
|
else:
|
|
174
|
-
logger.warning(
|
|
208
|
+
logger.warning(
|
|
209
|
+
f"File {filename_without_extension}.xml wasn't saved at user request"
|
|
210
|
+
)
|
|
175
211
|
# emit status signal to dashboard to write : did not save ?
|
|
176
212
|
pass
|
|
177
213
|
|
|
178
214
|
# check if overshoot configuration and layout configuration with same name exists => delete them if yes
|
|
179
|
-
over_shoot_file = overshoot_path.joinpath(self.filename +
|
|
215
|
+
over_shoot_file = overshoot_path.joinpath(self.filename + ".xml")
|
|
180
216
|
over_shoot_file.unlink(missing_ok=True)
|
|
181
217
|
|
|
182
|
-
layout_file = layout_path.joinpath(self.filename +
|
|
218
|
+
layout_file = layout_path.joinpath(self.filename + ".dock")
|
|
183
219
|
layout_file.unlink(missing_ok=True)
|
|
184
220
|
|
|
185
|
-
return res ==
|
|
221
|
+
return res == QDialog.DialogCode.Accepted
|
|
186
222
|
|
|
187
223
|
|
|
188
|
-
if __name__ ==
|
|
224
|
+
if __name__ == "__main__":
|
|
189
225
|
app = QtWidgets.QApplication(sys.argv)
|
|
190
226
|
# prog = PresetManager(True)
|
|
191
227
|
prog = PresetManager(True)
|