pymodaq 4.4.0__py3-none-any.whl → 4.4.3__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.

@@ -1,3 +1,5 @@
1
+ import numbers
2
+
1
3
  from time import perf_counter
2
4
  from typing import Union, List, Dict, TYPE_CHECKING, Optional
3
5
  from numbers import Number
@@ -61,9 +63,15 @@ class DataActuatorType(BaseEnum):
61
63
  DataActuator = 1
62
64
 
63
65
 
64
- def comon_parameters(epsilon=config('actuator', 'epsilon_default')):
66
+ def comon_parameters(epsilon=config('actuator', 'epsilon_default'),
67
+ epsilons=None):
68
+ if epsilons is not None:
69
+ epsilon=epsilons
65
70
  if isinstance(epsilon, list):
66
71
  epsilon=epsilon[0]
72
+ elif isinstance(epsilon, dict):
73
+ epsilon=epsilon[list[epsilon.keys()][0]]
74
+
67
75
  return [{'title': 'Units:', 'name': 'units', 'type': 'str', 'value': '', 'readonly': True},
68
76
  {'title': 'Epsilon:', 'name': 'epsilon', 'type': 'float',
69
77
  'value': epsilon,
@@ -106,32 +114,49 @@ class MoveCommand:
106
114
  self.value = value
107
115
 
108
116
 
109
- def comon_parameters_fun(is_multiaxes = False,
110
- axes_names: Union[List[str], Dict[str, int]] = [],
117
+ def comon_parameters_fun(is_multiaxes=False, axes_names=None,
111
118
  axis_names: Union[List, Dict] = [],
112
119
  master=True,
113
- epsilon=config('actuator', 'epsilon_default')):
120
+ epsilon: float = config('actuator', 'epsilon_default')):
121
+
114
122
  """Function returning the common and mandatory parameters that should be on the actuator plugin level
115
123
 
116
124
  Parameters
117
125
  ----------
118
- is_multiaxes: bool
126
+ is_multiaxes: bool # deprecated not need anymore
119
127
  If True, display the particular settings to define which axis the controller is driving
120
- axis_names: list of str
128
+ axes_names: deprecated, use axis_names
129
+ axis_names: list of str or dictionnary of string as key and integer as value
121
130
  The string identifier of every axis the controller can drive
122
131
  master: bool
123
132
  If True consider this plugin has to init the controller, otherwise use an already initialized instance
133
+ epsilon: float
134
+ deprecated (< 5.0.0) no more used here
135
+
124
136
  """
125
- if axis_names == [] and len(axes_names) != 0:
137
+ if axes_names is not None and len(axis_names) == 0:
138
+ if len(axes_names) == 0:
139
+ axes_names = ['']
126
140
  axis_names = axes_names
127
141
 
142
+ is_multiaxes = len(axis_names) > 1
143
+ if isinstance(axis_names, list):
144
+ if len(axis_names) > 0:
145
+ axis_name = axis_names[0]
146
+ else:
147
+ axis_names = ['']
148
+ axis_name = ''
149
+ elif isinstance(axis_names, dict):
150
+ axis_name = axis_names[list(axis_names.keys())[0]]
128
151
  params = [
129
- {'title': 'MultiAxes:', 'name': 'multiaxes', 'type': 'group', 'visible': is_multiaxes, 'children': [
130
- {'title': 'is Multiaxes:', 'name': 'ismultiaxes', 'type': 'bool', 'value': is_multiaxes,
131
- 'default': False},
152
+ {'title': 'MultiAxes:', 'name': 'multiaxes', 'type': 'group',
153
+ 'visible': is_multiaxes, 'children': [
154
+ {'title': 'is Multiaxes:', 'name': 'ismultiaxes', 'type': 'bool',
155
+ 'value': is_multiaxes, 'default': False},
132
156
  {'title': 'Status:', 'name': 'multi_status', 'type': 'list',
133
157
  'value': 'Master' if master else 'Slave', 'limits': ['Master', 'Slave']},
134
- {'title': 'Axis:', 'name': 'axis', 'type': 'list', 'limits': axis_names},
158
+ {'title': 'Axis:', 'name': 'axis', 'type': 'list', 'limits': axis_names,
159
+ 'value': axis_name},
135
160
  ]},
136
161
  ] + comon_parameters(epsilon)
137
162
  return params
@@ -231,10 +256,16 @@ class DAQ_Move_base(QObject):
231
256
 
232
257
  move_done_signal = Signal(DataActuator)
233
258
  is_multiaxes = False
234
- stage_names = []
259
+ stage_names = [] # deprecated
260
+
261
+ _axis_names: Union[list, Dict[str, int]] = None
262
+ _controller_units: Union[str, List[str], Dict[str, int]] = ''
263
+ _epsilons: Union[float, List[float], Dict[str, float]] = None
264
+ _epsilon = 1.0 # deprecated
265
+
266
+
235
267
  params = []
236
- _controller_units: Union[str, List[str]] = ''
237
- _epsilon = 1.0
268
+
238
269
  data_actuator_type = DataActuatorType.float
239
270
  data_shape = (1, ) # expected shape of the underlying actuator's value (in general a float so shape = (1, ))
240
271
 
@@ -264,11 +295,11 @@ class DAQ_Move_base(QObject):
264
295
  else:
265
296
  self._title = "myactuator"
266
297
 
267
- self._axis_units: List[str] = []
298
+ self._axis_units: Union[Dict[str, str], List[str]] = None
268
299
  self.axis_units = self._controller_units
269
- self._epsilons: List[float] = [] # self._epsilon if isinstance(self._epsilon, list) else\
270
- # [self._epsilon for _ in range(len(self.axis_name))]
271
- self.epsilons = self._epsilon
300
+ if self._epsilons is None:
301
+ self._epsilons = self._epsilon
302
+ self.epsilons = self._epsilons
272
303
  self.axis_name = self.axis_name # to trigger some actions on units and epsilons
273
304
 
274
305
  self._current_value = DataActuator(self._title,
@@ -293,16 +324,16 @@ class DAQ_Move_base(QObject):
293
324
 
294
325
  New in 4.4.0
295
326
  """
296
- return self.axis_units[self.axis_value]
327
+ return self.axis_units[self.axis_index_key]
297
328
 
298
329
  @axis_unit.setter
299
330
  def axis_unit(self, unit: str):
300
- self.axis_units[self.axis_value] = unit
331
+ self.axis_units[self.axis_index_key] = unit
301
332
  self.settings.child('units').setValue(unit)
302
333
  self.emit_status(ThreadCommand('units', unit))
303
334
 
304
335
  @property
305
- def axis_units(self) -> List[str]:
336
+ def axis_units(self) -> Union[List[str], Dict[str, str]]:
306
337
  """ Get/Set the units for each axis of the controller
307
338
 
308
339
  New in 4.4.0
@@ -310,10 +341,23 @@ class DAQ_Move_base(QObject):
310
341
  return self._axis_units
311
342
 
312
343
  @axis_units.setter
313
- def axis_units(self, units: Union[str, List[str]]):
344
+ def axis_units(self, units: Union[str, List[str], Dict[str, str]]):
314
345
  if isinstance(units, str):
315
- units = [units for _ in range(len(self.axis_names))]
316
- self._axis_units = units
346
+ if isinstance(self.axis_names, list):
347
+ units_tmp = [units for _ in range(len(self.axis_names))]
348
+ else:
349
+ units_tmp = {}
350
+ for key in self.axis_names:
351
+ units_tmp[key] = units
352
+ else:
353
+ if not isinstance(units, type(self.axis_names)):
354
+ raise TypeError('units should be defined just like axis_names: a str, list of string or'
355
+ 'dict of string')
356
+ if len(units) != len(self.axis_names):
357
+ raise ValueError('Units should be defined either as a single str or a list/dict with'
358
+ 'a str defined for each axis')
359
+ units_tmp = units
360
+ self._axis_units = units_tmp
317
361
 
318
362
  @property
319
363
  def epsilon(self) -> float:
@@ -321,14 +365,14 @@ class DAQ_Move_base(QObject):
321
365
 
322
366
  New in 4.4.0
323
367
  """
324
- return self.epsilons[self.axis_value]
368
+ return self.epsilons[self.axis_index_key]
325
369
 
326
370
  @epsilon.setter
327
371
  def epsilon(self, eps: float):
328
- self.epsilons[self.axis_value] = eps
372
+ self.epsilons[self.axis_index_key] = eps
329
373
 
330
374
  @property
331
- def epsilons(self) -> List[float]:
375
+ def epsilons(self) -> Union[List[float], Dict[str, float]]:
332
376
  """ Get/Set the epsilon for each axis of the controller
333
377
 
334
378
  New in 4.4.0
@@ -336,10 +380,24 @@ class DAQ_Move_base(QObject):
336
380
  return self._epsilons
337
381
 
338
382
  @epsilons.setter
339
- def epsilons(self, epsilons: Union[float, List[float]]):
340
- if not isinstance(epsilons, Iterable) and isinstance(epsilons, float):
341
- epsilons = [epsilons for _ in range(len(self.axis_names))]
342
- self._epsilons = epsilons
383
+ def epsilons(self, epsilons: Union[float, List[float], Dict[str, float]]):
384
+ if isinstance(epsilons, numbers.Number):
385
+ if isinstance(self.axis_names, list):
386
+ epsilons_tmp = [epsilons for _ in range(len(self.axis_names))]
387
+ else:
388
+ epsilons_tmp = {}
389
+ for key in self.axis_names:
390
+ epsilons_tmp[key] = epsilons
391
+ else:
392
+ if not isinstance(epsilons, type(self.axis_names)):
393
+ raise TypeError('units should be defined just like axis_names: a float, list of '
394
+ 'float or dict of float')
395
+ if len(epsilons) != len(self.axis_names):
396
+ raise ValueError('epsilons should be defined either as a single float or a '
397
+ 'list/dict with'
398
+ 'a float defined for each axis')
399
+ epsilons_tmp = epsilons
400
+ self._epsilons = epsilons_tmp
343
401
 
344
402
  @property
345
403
  def controller_units(self):
@@ -357,7 +415,7 @@ class DAQ_Move_base(QObject):
357
415
  def controller_units(self, units: str = ''):
358
416
  deprecation_msg('The property controller_units is deprecated please use the'
359
417
  'axis_unit property.')
360
- self._axis_units[self.axis_value] = units
418
+ self._axis_units[self.axis_index_key] = units
361
419
 
362
420
  @property
363
421
  def axis_name(self) -> Union[str]:
@@ -398,12 +456,29 @@ class DAQ_Move_base(QObject):
398
456
 
399
457
  @property
400
458
  def axis_value(self) -> int:
401
- """Get the current value selected from the current axis"""
459
+ """Get the current value selected from the current axis
460
+
461
+ In case axis_names is a list, return the element of the list: self.axis_name
462
+ In case axis_names is a dict, return the value of the dict self.axis_names[self.axis_name]
463
+ """
402
464
  if isinstance(self.axis_names, list):
403
- return self.axis_names.index(self.axis_name)
465
+ return self.axis_name
404
466
  else:
405
467
  return self.axis_names[self.axis_name]
406
468
 
469
+ @property
470
+ def axis_index_key(self) -> Union[int, str]:
471
+ """ Get the current index or key correspondingto the current axis
472
+
473
+ In case axis_names is a list, return the index wihtin the list
474
+ In case axis_names is a dict, return the key of the dict self.axis_name
475
+
476
+ """
477
+ if isinstance(self.axis_names, list):
478
+ return self.axis_names.index(self.axis_name)
479
+ else:
480
+ return self.axis_name
481
+
407
482
  def ini_attributes(self):
408
483
  """ To be subclassed, in order to init specific attributes needed by the real implementation"""
409
484
  self.controller = None
@@ -442,14 +517,14 @@ class DAQ_Move_base(QObject):
442
517
 
443
518
  @property
444
519
  def current_value(self):
445
- if self.data_actuator_type.name == 'float':
520
+ if self.data_actuator_type == self.data_actuator_type.float:
446
521
  return self._current_value.value()
447
522
  else:
448
523
  return self._current_value
449
524
 
450
525
  @current_value.setter
451
526
  def current_value(self, value: Union[float, DataActuator]):
452
- if not isinstance(value, DataActuator):
527
+ if isinstance(value, numbers.Number):
453
528
  self._current_value = DataActuator(self._title, data=value,
454
529
  units=self.axis_unit)
455
530
  else:
@@ -461,14 +536,14 @@ class DAQ_Move_base(QObject):
461
536
 
462
537
  @property
463
538
  def target_value(self):
464
- if self.data_actuator_type.name == 'float':
539
+ if self.data_actuator_type.name == self.data_actuator_type.float:
465
540
  return self._target_value.value()
466
541
  else:
467
542
  return self._target_value
468
543
 
469
544
  @target_value.setter
470
- def target_value(self, value: Union[float, DataActuator]):
471
- if not isinstance(value, DataActuator):
545
+ def target_value(self, value: Union[numbers.Number, DataActuator]):
546
+ if isinstance(value, numbers.Number):
472
547
  self._target_value = DataActuator(self._title, data=value,
473
548
  units=self.axis_unit)
474
549
  else:
@@ -796,7 +871,7 @@ class DAQ_Move_TCP_server(DAQ_Move_base, TCPServer):
796
871
  message_list = ["Quit", "Status", "Done", "Server Closed", "Info", "Infos", "Info_xml", "move_abs",
797
872
  'move_home', 'move_rel', 'get_actuator_value', 'stop_motion', 'position_is', 'move_done']
798
873
  socket_types = ["ACTUATOR"]
799
- params = comon_parameters() + tcp_parameters
874
+ params = comon_parameters_fun() + tcp_parameters
800
875
 
801
876
  def __init__(self, parent=None, params_state=None):
802
877
  """
@@ -868,6 +943,12 @@ class DAQ_Move_TCP_server(DAQ_Move_base, TCPServer):
868
943
  initialized = True
869
944
  return info, initialized
870
945
 
946
+ def read_infos(self, sock: Socket = None, infos=''):
947
+ """Reimplemented to get the units"""
948
+ super().read_infos(sock, infos)
949
+
950
+ self.axis_unit = self.settings['settings_client', 'units']
951
+
871
952
  def close(self):
872
953
  """
873
954
  Should be used to uninitialize hardware.
pymodaq/resources/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- version = '4.4.0'
1
+ version = '4.4.3'
2
2
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymodaq
3
- Version: 4.4.0
3
+ Version: 4.4.3
4
4
  Summary: Modular Data Acquisition with Python
5
5
  Project-URL: Homepage, http://pymodaq.cnrs.fr
6
6
  Project-URL: Source, https://github.com/PyMoDAQ/PyMoDAQ
@@ -8,7 +8,7 @@ pymodaq/control_modules/daq_move_ui.py,sha256=IbqNAErwXGjKUbYEptvZUz3J8MapNBFIbQ
8
8
  pymodaq/control_modules/daq_viewer.py,sha256=5CYmdWHGE7sQApeMfdWNV3zbPyoxxYtzFlQ1PaEw4fI,57883
9
9
  pymodaq/control_modules/daq_viewer_ui.py,sha256=FWP3jdIOR9vTgYqNaaodteGZ3dwgQ1GdWKrOpOAuSrs,15693
10
10
  pymodaq/control_modules/mocks.py,sha256=hh_xSWp9g1UV3NAQVD9Ft9tNWfTsSvKU0OU0trgzP2w,1956
11
- pymodaq/control_modules/move_utility_classes.py,sha256=LUO7kGb-1iQOP_6Wvp46xnx5Z9wNxUhRzOfz9cfXH-s,39664
11
+ pymodaq/control_modules/move_utility_classes.py,sha256=rtCTwYxb1gc7RSCNqT-MKm3LnAwOkN0Z3H7jTS1LRo8,42921
12
12
  pymodaq/control_modules/utils.py,sha256=5YdSwq_lFJm7IalYWe_Hn1U4LUoUmo1gedvV9UguU0Y,20016
13
13
  pymodaq/control_modules/viewer_utility_classes.py,sha256=OHxwue1t3z2AXyeqNjnwPT2pMc8yXhnqyiWc9IdCI2c,26841
14
14
  pymodaq/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -58,7 +58,7 @@ pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.py,sha256=1u7hWDaiwsZ
58
58
  pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.ui,sha256=PyzbCWPMkh5oIYYteZczXyWMeHKW9EJmM1QlzXhnyTk,7037
59
59
  pymodaq/post_treatment/daq_measurement/daq_measurement_main.py,sha256=CAKwcWMOD86aXB8mbdxOK7e8nZRos5d59FzDtqK1QoY,17093
60
60
  pymodaq/post_treatment/daq_measurement/process_from_QtDesigner_DAQ_Measurement_GUI.bat,sha256=e1tu2A67MS9fk3jhriF6saQgRxWIucIvNW92iWXFP6E,164
61
- pymodaq/resources/VERSION,sha256=x4JbXmXiNnoebdA-11hkfcpy5BKE5mBMlysMVDo9SRw,19
61
+ pymodaq/resources/VERSION,sha256=5fs1bL_Go-jyl-eCjdUaNpWrQ094john5_mxE61Kw2g,19
62
62
  pymodaq/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  pymodaq/resources/config_template.toml,sha256=d3pofgIK5FxaRMELAI1qEsRcMD3GlYd87zZjDj9G9m0,3210
64
64
  pymodaq/resources/preset_default.xml,sha256=Dt8iWLwPPOPtcG00JCVP-mh-G7KC6B0YN8hd8RQdnNI,27256
@@ -438,8 +438,8 @@ pymodaq/utils/tcp_ip/__init__.py,sha256=1e_EK0AgvdoLAD_CSGGEaITZdy6OWCO7ih9IAIp7
438
438
  pymodaq/utils/tcp_ip/mysocket.py,sha256=StAWj8dzHeMnbLj68Sel81uWFy-YkKVNRnVf7gXrESI,3452
439
439
  pymodaq/utils/tcp_ip/serializer.py,sha256=htVQCE4saRBMeIcseEyxTt5G58A341m6OGkaJUA34Wk,27766
440
440
  pymodaq/utils/tcp_ip/tcp_server_client.py,sha256=xIMTNgVW_rKK0yTi4FDNFLf85-Akb27Jz2LdrvOrP68,30660
441
- pymodaq-4.4.0.dist-info/METADATA,sha256=PGjrsAiJMph8il3hZKb9aJDvUShYG5CUrEYgTPsY8is,7623
442
- pymodaq-4.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
443
- pymodaq-4.4.0.dist-info/entry_points.txt,sha256=RAzdYNjvUT28I2eiCKki_g2NzXq0woWxhev6lwzwRv8,348
444
- pymodaq-4.4.0.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
445
- pymodaq-4.4.0.dist-info/RECORD,,
441
+ pymodaq-4.4.3.dist-info/METADATA,sha256=W7g44E0hOVUfN-tO5bgilLk9UZRg7uZZiSvlzMIqhtM,7623
442
+ pymodaq-4.4.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
443
+ pymodaq-4.4.3.dist-info/entry_points.txt,sha256=RAzdYNjvUT28I2eiCKki_g2NzXq0woWxhev6lwzwRv8,348
444
+ pymodaq-4.4.3.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
445
+ pymodaq-4.4.3.dist-info/RECORD,,