pymodaq_scripting 5.3.7__py3-none-any.whl → 5.3.9__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.
@@ -15,78 +15,234 @@ if TYPE_CHECKING:
15
15
 
16
16
  class Actuator(Device[LECOActuatorWrapper]):
17
17
  """
18
- Public interface to control an Actuator
18
+ Public interface to control an Actuator of a running Dashboard
19
+
20
+ All the commands return at once with a :class:`concurrent.futures.Future`, filled when the Dashboard
21
+ answers: call ``result()`` on it to wait for the answer. A new command of the same kind replaces the
22
+ previous one, whose future then never completes (the four moves share the same future).
23
+
24
+ Parameters
25
+ ----------
26
+ device: str
27
+ Name of the actuator in the Dashboard (its title in the experiment)
28
+ **kwargs
29
+ Passed to the LECO ``Director`` (for example the ``host`` of the coordinator)
30
+
31
+ Examples
32
+ --------
33
+ >>> actuator = Actuator('Xaxis')
34
+ >>> actuator.move_abs('1.5 mm').result() # position reached, as a DataActuator
35
+ >>> actuator.get_actuator_value().result()
19
36
  """
20
37
  def __init__(self, device: str, **kwargs) -> None:
21
38
  super().__init__(LECOActuatorWrapper(device, **kwargs))
22
39
 
23
40
  def get_actuator_value(self) -> Future['DataActuator']:
41
+ """ Ask for the current position of the actuator
42
+
43
+ Returns
44
+ -------
45
+ Future: its result is the position, as a ``DataActuator``
46
+ """
24
47
  return self._wrapper.get_actuator_value()
25
48
 
26
49
  def move_home(self) -> Future['DataActuator']:
50
+ """ Move the actuator to its home position
51
+
52
+ Returns
53
+ -------
54
+ Future: its result is the position once the move is over
55
+ """
27
56
  return self._wrapper.move_home()
28
57
 
29
58
  def move_abs(self, value: Union['DataActuator', int, float, str]) -> Future['DataActuator']:
59
+ """ Move the actuator to an absolute position
60
+
61
+ Parameters
62
+ ----------
63
+ value: DataActuator, int, float or str
64
+ The target. A number is sent without units, a string is read with its units (``'1.5 mm'``,
65
+ see :func:`pymodaq_scripting.utils.value_to_data_actuator`).
66
+
67
+ Returns
68
+ -------
69
+ Future: its result is the position once the move is over
70
+ """
30
71
  return self._wrapper.move_abs(value)
31
72
 
32
73
  def move_rel(self, value: Union['DataActuator', int, float, str]) -> Future['DataActuator']:
74
+ """ Move the actuator by a displacement relative to its current position
75
+
76
+ Parameters
77
+ ----------
78
+ value: DataActuator, int, float or str
79
+ The displacement, same conversions as in :meth:`move_abs`
80
+
81
+ Returns
82
+ -------
83
+ Future: its result is the position once the move is over
84
+ """
33
85
  return self._wrapper.move_rel(value)
34
86
 
35
87
  def stop_move(self) -> Future['DataActuator']:
88
+ """ Stop the movement of the actuator
89
+
90
+ Returns
91
+ -------
92
+ Future: its result is the position once the actuator is stopped
93
+ """
36
94
  return self._wrapper.stop_move()
37
95
 
38
96
  def get_settings(self) -> Future[Element]:
97
+ """ Ask for the settings of the actuator
98
+
99
+ Returns
100
+ -------
101
+ Future: its result is the settings tree, as an XML ``Element``. It is also kept as the reference
102
+ against which :meth:`set_settings` detects what changed.
103
+ """
39
104
  return self._wrapper.get_settings()
40
105
 
41
106
  def set_settings(self, settings: Element) -> None:
107
+ """ Send the settings that differ from those obtained by the last :meth:`get_settings`
108
+
109
+ Only the parameters whose value or attributes changed are sent. Nothing is sent as long as the answer
110
+ to :meth:`get_settings` has not been received.
111
+
112
+ Parameters
113
+ ----------
114
+ settings: Element
115
+ The settings tree returned by :meth:`get_settings`, with some values modified
116
+ """
42
117
  self._wrapper.set_settings(settings)
43
118
 
119
+
44
120
  class Detector(Device[LECODetectorWrapper]):
45
121
  """
46
- Public interface to control a Detector
122
+ Public interface to control a Detector of a running Dashboard
123
+
124
+ Parameters
125
+ ----------
126
+ device: str
127
+ Name of the detector in the Dashboard (its title in the experiment)
128
+ **kwargs
129
+ Passed to the LECO ``Director`` (for example the ``host`` of the coordinator)
130
+
131
+ Examples
132
+ --------
133
+ >>> detector = Detector('Camera')
134
+ >>> data = detector.snap().result() # a DataToExport
47
135
  """
48
136
  def __init__(self, device: str, **kwargs) -> None:
49
137
  super().__init__(LECODetectorWrapper(device, **kwargs))
50
138
 
51
139
  def snap(self) -> Optional[Future[DataToExport]]:
140
+ """ Acquire one data set
141
+
142
+ Returns
143
+ -------
144
+ Future or None: its result is the acquired ``DataToExport``. None, and nothing is asked, while a
145
+ continuous grab started by :meth:`grab` is running.
146
+ """
52
147
  return self._wrapper.snap()
53
148
 
54
- def grab(self, keep=False) -> Optional[list[DataToExport]]:
149
+ def grab(self, keep: bool = False) -> Optional[list[DataToExport]]:
150
+ """ Start a continuous acquisition, or stop it when one is running (each call toggles)
151
+
152
+ Parameters
153
+ ----------
154
+ keep: bool
155
+ If True, the data sets received while grabbing are appended to the returned list. Only used by
156
+ the call starting the grab.
157
+
158
+ Returns
159
+ -------
160
+ list or None: when starting with ``keep=True``, the list filling up with the acquired ``DataToExport``;
161
+ None otherwise (``keep=False``, or the call stopping the grab).
162
+ """
55
163
  return self._wrapper.grab(keep=keep)
56
164
 
57
165
  def stop_grab(self) -> None:
166
+ """ Stop the continuous acquisition """
58
167
  return self._wrapper.stop_grab()
59
168
 
60
169
  def get_settings(self) -> Future[Element]:
170
+ """ Ask for the settings of the detector
171
+
172
+ Returns
173
+ -------
174
+ Future: its result is the settings tree, as an XML ``Element``. It is also kept as the reference
175
+ against which :meth:`set_settings` detects what changed.
176
+ """
61
177
  return self._wrapper.get_settings()
62
178
 
63
179
  def set_settings(self, settings: Element) -> None:
180
+ """ Send the settings that differ from those obtained by the last :meth:`get_settings`
181
+
182
+ Only the parameters whose value or attributes changed are sent. Nothing is sent as long as the answer
183
+ to :meth:`get_settings` has not been received.
184
+
185
+ Parameters
186
+ ----------
187
+ settings: Element
188
+ The settings tree returned by :meth:`get_settings`, with some values modified
189
+ """
64
190
  self._wrapper.set_settings(settings)
65
191
 
66
192
 
67
193
  class Dashboard(Device[LECODashboardWrapper]):
68
194
  """
69
195
  Public interface to control a Dashboard
196
+
197
+ Parameters
198
+ ----------
199
+ **kwargs
200
+ Passed to the LECO ``Director`` (for example the ``host`` of the coordinator)
201
+
202
+ Examples
203
+ --------
204
+ >>> dashboard = Dashboard()
205
+ >>> dashboard.apply_experiment('my_experiment').result() # True once applied
206
+ >>> devices = dashboard.get_scripting_devices()
207
+ >>> devices['actuators']['Xaxis'].move_abs('1 mm').result()
70
208
  """
71
209
 
72
210
  def __init__(self, **kwargs) -> None:
73
211
  super().__init__(LECODashboardWrapper(**kwargs))
74
212
 
75
213
  @property
76
- def leco_name(self):
214
+ def leco_name(self) -> str:
215
+ """ Name under which this script is known on the LECO network"""
77
216
  return self._wrapper.leco_name
78
217
 
79
218
  @property
80
219
  def name(self) -> str:
220
+ """ Name of the Dashboard on the LECO network"""
81
221
  return self._wrapper.name
82
222
 
83
223
  def sign_out(self) -> None:
224
+ """ Sign this script out of the LECO coordinator (done automatically when Python exits)"""
84
225
  self._wrapper.sign_out()
85
226
 
86
227
  def get_devices(self) -> Future[dict[str, list[str]]]:
228
+ """ Ask for the names of the instruments of the applied experiment
229
+
230
+ Returns
231
+ -------
232
+ Future: its result is a dict with the keys ``'actuators'`` and ``'detectors'``, each holding the list
233
+ of the names
234
+ """
87
235
  return self._wrapper.get_devices()
88
236
 
89
237
  def get_scripting_devices(self) -> dict[str, dict[str, Actuator | Detector]]:
238
+ """ Get an :class:`Actuator` or :class:`Detector` object for each instrument of the experiment
239
+
240
+ Waits for the answer of the Dashboard (see :meth:`get_devices`).
241
+
242
+ Returns
243
+ -------
244
+ dict: ``{'actuators': {name: Actuator}, 'detectors': {name: Detector}}``
245
+ """
90
246
  devices = self._wrapper.get_devices().result()
91
247
 
92
248
  return {
@@ -95,13 +251,47 @@ class Dashboard(Device[LECODashboardWrapper]):
95
251
  }
96
252
 
97
253
  def get_states(self) -> Future[list[str]]:
254
+ """ Ask for the names of the available states
255
+
256
+ Returns
257
+ -------
258
+ Future: its result is the list of names
259
+ """
98
260
  return self._wrapper.get_states()
99
261
 
100
262
  def apply_state(self, state: str) -> Future[bool]:
263
+ """ Apply a state (instrument settings and actuator values)
264
+
265
+ Parameters
266
+ ----------
267
+ state: str
268
+ Name of the state, as returned by :meth:`get_states`
269
+
270
+ Returns
271
+ -------
272
+ Future: its result is the success of the operation, set when the state has been applied
273
+ """
101
274
  return self._wrapper.apply_state(state)
102
275
 
103
276
  def get_experiments(self) -> Future[list[str]]:
277
+ """ Ask for the names of the available experiments
278
+
279
+ Returns
280
+ -------
281
+ Future: its result is the list of names
282
+ """
104
283
  return self._wrapper.get_experiments()
105
284
 
106
285
  def apply_experiment(self, experiment: str) -> Future[bool]:
286
+ """ Load an experiment (the list of instruments the Dashboard manages)
287
+
288
+ Parameters
289
+ ----------
290
+ experiment: str
291
+ Name of the experiment, as returned by :meth:`get_experiments`
292
+
293
+ Returns
294
+ -------
295
+ Future: its result is the success of the operation, set when the experiment has been applied
296
+ """
107
297
  return self._wrapper.apply_experiment(experiment)
File without changes
@@ -212,7 +212,7 @@ class LECOActuatorWrapper(LECODeviceWrapper):
212
212
 
213
213
  return future
214
214
 
215
- def move_rel(self, value: 'DataActuator') -> Future['DataActuator']:
215
+ def move_rel(self, value: Union['DataActuator', int, float, str]) -> Future['DataActuator']:
216
216
  future = Future()
217
217
  self._move_done_future = future
218
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pymodaq_scripting
3
- Version: 5.3.7
3
+ Version: 5.3.9
4
4
  Summary: Objects and utilities to use PyMoDAQ from a script
5
5
  Project-URL: Homepage, http://pymodaq.cnrs.fr
6
6
  Project-URL: Source, https://github.com/PyMoDAQ/pymodaq_scripting
@@ -0,0 +1,11 @@
1
+ pymodaq_scripting/__init__.py,sha256=bOKxPgKOT-TqS42lx8O8JY3d7cSfpskAUDADA1iYThM,50
2
+ pymodaq_scripting/devices.py,sha256=EUY-IE_axMOayvKNqNqgWX0dEf6Cxgp1MO-SCWiZrok,10103
3
+ pymodaq_scripting/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pymodaq_scripting/utils.py,sha256=Vn8I946pKqrDdKKvEuaZiX31ji2mu0yTwvo8ivuStWM,14140
5
+ pymodaq_scripting/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pymodaq_scripting/examples/dashboard_script.py,sha256=lYz5iIau1fGEjFU7m92vDGCuAWhRDd7GSUgM54r_TcE,1006
7
+ pymodaq_scripting/examples/simple_script.py,sha256=dTaVprhgG9lPh1ECo0xlbby9Yq7Gm4EJYDbcqNEOssQ,1320
8
+ pymodaq_scripting-5.3.9.dist-info/METADATA,sha256=X5IUs7CqyMP8zY4OA72C-6LEqcg4YiTKjFLQ4VaS7Do,6557
9
+ pymodaq_scripting-5.3.9.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
10
+ pymodaq_scripting-5.3.9.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
11
+ pymodaq_scripting-5.3.9.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- pymodaq_scripting/__init__.py,sha256=bOKxPgKOT-TqS42lx8O8JY3d7cSfpskAUDADA1iYThM,50
2
- pymodaq_scripting/devices.py,sha256=K7iPIubX84LBV8xosvtKBYTx15W18YEmoD-LpyeCbtA,3343
3
- pymodaq_scripting/utils.py,sha256=yRdymXJq1e48YmHaPUDjBk300dvQzm27HzZo9CMByHQ,14116
4
- pymodaq_scripting/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- pymodaq_scripting/examples/dashboard_script.py,sha256=lYz5iIau1fGEjFU7m92vDGCuAWhRDd7GSUgM54r_TcE,1006
6
- pymodaq_scripting/examples/simple_script.py,sha256=dTaVprhgG9lPh1ECo0xlbby9Yq7Gm4EJYDbcqNEOssQ,1320
7
- pymodaq_scripting-5.3.7.dist-info/METADATA,sha256=aeSllKKyc83PDLcC7wLgvBgiAYldh9_dNV1fjC-hbzI,6557
8
- pymodaq_scripting-5.3.7.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
9
- pymodaq_scripting-5.3.7.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
10
- pymodaq_scripting-5.3.7.dist-info/RECORD,,