QInstrument 2.4.1__tar.gz → 3.0.0__tar.gz
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.
- {qinstrument-2.4.1 → qinstrument-3.0.0}/PKG-INFO +1 -1
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/PKG-INFO +1 -1
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/SOURCES.txt +5 -8
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/instrument.py +33 -9
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/instrument.py +5 -4
- qinstrument-3.0.0/instruments/StanfordResearch/SR830/__init__.py +10 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR830/instrument.py +25 -5
- qinstrument-3.0.0/instruments/StanfordResearch/SR844/__init__.py +10 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR844/instrument.py +25 -5
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/Configure.py +10 -5
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QAbstractInstrument.py +89 -149
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QFakeInstrument.py +13 -18
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QInstrumentTree.py +149 -60
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QInstrumentWidget.py +119 -79
- qinstrument-3.0.0/lib/QPollingMixin.py +97 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QReconcileDialog.py +4 -2
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QSerialInstrument.py +127 -59
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/QSerialInterface.py +26 -96
- {qinstrument-2.4.1 → qinstrument-3.0.0}/lib/__init__.py +1 -0
- qinstrument-3.0.0/lib/lazy.py +124 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/pyproject.toml +1 -1
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_Configure.py +16 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QAbstractInstrument.py +0 -43
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QFakeInstrument.py +0 -4
- qinstrument-3.0.0/tests/test_QInstrumentTree.py +347 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QInstrumentWidget.py +67 -2
- qinstrument-3.0.0/tests/test_QPollingMixin.py +132 -0
- qinstrument-3.0.0/tests/test_QReconcileDialog.py +85 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QSR830.py +39 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QSR844.py +39 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QSerialInstrument.py +35 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QSerialInterface.py +1 -83
- qinstrument-2.4.1/instruments/StanfordResearch/SR830/__init__.py +0 -6
- qinstrument-2.4.1/instruments/StanfordResearch/SR830/worker.py +0 -38
- qinstrument-2.4.1/instruments/StanfordResearch/SR844/__init__.py +0 -6
- qinstrument-2.4.1/instruments/StanfordResearch/SR844/worker.py +0 -38
- qinstrument-2.4.1/lib/QInstrumentWorker.py +0 -119
- qinstrument-2.4.1/lib/lazy.py +0 -52
- qinstrument-2.4.1/tests/test_QInstrumentWorker.py +0 -164
- qinstrument-2.4.1/tests/test_QSR830Worker.py +0 -107
- {qinstrument-2.4.1 → qinstrument-3.0.0}/LICENSE.md +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/dependency_links.txt +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/entry_points.txt +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/requires.txt +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrument.egg-info/top_level.txt +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/QInstrumentRack.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/README.md +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/__main__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/IPGLaserWidget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/IPGLaser/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/IPGPhotonics/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/OpusWidget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus1064/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus1064/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus1064/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus1064/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus1064/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus532/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus532/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus532/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus532/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus532/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus660/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus660/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus660/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus660/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/Opus660/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Novanta/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/PDUS210Widget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/PDUS210/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PiezoDrive/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/ProscanWidget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/Proscan/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/PriorScientific/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/DS345Widget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/DS345/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR830/SR830Widget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR830/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR830/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR830/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR844/SR844Widget.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR844/fake.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR844/tree.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/SR844/widget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/StanfordResearch/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Tektronix/TDS1000/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Tektronix/TDS1000/instrument.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/Tektronix/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/instruments/__init__.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/setup.cfg +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QDS345.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QIPGLaser.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QInstrumentRack.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QLedWidget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QOpus.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QPDUS210.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QProscan.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/tests/test_QRotaryEncoderSpinBox.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QJoystick.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QJoystickPad.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QLedWidget.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QRotaryEncoder.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QRotaryEncoderSpinBox.py +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/QRotaryEncoderSpinBox.ui +0 -0
- {qinstrument-2.4.1 → qinstrument-3.0.0}/widgets/__init__.py +0 -0
|
@@ -64,14 +64,12 @@ pyproject.toml
|
|
|
64
64
|
./instruments/StanfordResearch/SR830/instrument.py
|
|
65
65
|
./instruments/StanfordResearch/SR830/tree.py
|
|
66
66
|
./instruments/StanfordResearch/SR830/widget.py
|
|
67
|
-
./instruments/StanfordResearch/SR830/worker.py
|
|
68
67
|
./instruments/StanfordResearch/SR844/SR844Widget.ui
|
|
69
68
|
./instruments/StanfordResearch/SR844/__init__.py
|
|
70
69
|
./instruments/StanfordResearch/SR844/fake.py
|
|
71
70
|
./instruments/StanfordResearch/SR844/instrument.py
|
|
72
71
|
./instruments/StanfordResearch/SR844/tree.py
|
|
73
72
|
./instruments/StanfordResearch/SR844/widget.py
|
|
74
|
-
./instruments/StanfordResearch/SR844/worker.py
|
|
75
73
|
./instruments/Tektronix/__init__.py
|
|
76
74
|
./instruments/Tektronix/TDS1000/__init__.py
|
|
77
75
|
./instruments/Tektronix/TDS1000/instrument.py
|
|
@@ -80,7 +78,7 @@ pyproject.toml
|
|
|
80
78
|
./lib/QFakeInstrument.py
|
|
81
79
|
./lib/QInstrumentTree.py
|
|
82
80
|
./lib/QInstrumentWidget.py
|
|
83
|
-
./lib/
|
|
81
|
+
./lib/QPollingMixin.py
|
|
84
82
|
./lib/QReconcileDialog.py
|
|
85
83
|
./lib/QSerialInstrument.py
|
|
86
84
|
./lib/QSerialInterface.py
|
|
@@ -156,14 +154,12 @@ instruments/StanfordResearch/SR830/fake.py
|
|
|
156
154
|
instruments/StanfordResearch/SR830/instrument.py
|
|
157
155
|
instruments/StanfordResearch/SR830/tree.py
|
|
158
156
|
instruments/StanfordResearch/SR830/widget.py
|
|
159
|
-
instruments/StanfordResearch/SR830/worker.py
|
|
160
157
|
instruments/StanfordResearch/SR844/SR844Widget.ui
|
|
161
158
|
instruments/StanfordResearch/SR844/__init__.py
|
|
162
159
|
instruments/StanfordResearch/SR844/fake.py
|
|
163
160
|
instruments/StanfordResearch/SR844/instrument.py
|
|
164
161
|
instruments/StanfordResearch/SR844/tree.py
|
|
165
162
|
instruments/StanfordResearch/SR844/widget.py
|
|
166
|
-
instruments/StanfordResearch/SR844/worker.py
|
|
167
163
|
instruments/Tektronix/__init__.py
|
|
168
164
|
instruments/Tektronix/TDS1000/__init__.py
|
|
169
165
|
instruments/Tektronix/TDS1000/instrument.py
|
|
@@ -172,7 +168,7 @@ lib/QAbstractInstrument.py
|
|
|
172
168
|
lib/QFakeInstrument.py
|
|
173
169
|
lib/QInstrumentTree.py
|
|
174
170
|
lib/QInstrumentWidget.py
|
|
175
|
-
lib/
|
|
171
|
+
lib/QPollingMixin.py
|
|
176
172
|
lib/QReconcileDialog.py
|
|
177
173
|
lib/QSerialInstrument.py
|
|
178
174
|
lib/QSerialInterface.py
|
|
@@ -184,15 +180,16 @@ tests/test_QDS345.py
|
|
|
184
180
|
tests/test_QFakeInstrument.py
|
|
185
181
|
tests/test_QIPGLaser.py
|
|
186
182
|
tests/test_QInstrumentRack.py
|
|
183
|
+
tests/test_QInstrumentTree.py
|
|
187
184
|
tests/test_QInstrumentWidget.py
|
|
188
|
-
tests/test_QInstrumentWorker.py
|
|
189
185
|
tests/test_QLedWidget.py
|
|
190
186
|
tests/test_QOpus.py
|
|
191
187
|
tests/test_QPDUS210.py
|
|
188
|
+
tests/test_QPollingMixin.py
|
|
192
189
|
tests/test_QProscan.py
|
|
190
|
+
tests/test_QReconcileDialog.py
|
|
193
191
|
tests/test_QRotaryEncoderSpinBox.py
|
|
194
192
|
tests/test_QSR830.py
|
|
195
|
-
tests/test_QSR830Worker.py
|
|
196
193
|
tests/test_QSR844.py
|
|
197
194
|
tests/test_QSerialInstrument.py
|
|
198
195
|
tests/test_QSerialInterface.py
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
from qtpy import QtCore
|
|
5
|
+
from QInstrument.lib.QAbstractInstrument import QAbstractInstrument
|
|
5
6
|
from QInstrument.lib.QSerialInstrument import QSerialInstrument
|
|
6
7
|
|
|
7
8
|
|
|
@@ -210,6 +211,20 @@ class QProscan(QSerialInstrument):
|
|
|
210
211
|
|
|
211
212
|
positionChanged = QtCore.Signal(object)
|
|
212
213
|
|
|
214
|
+
_VOLATILE: frozenset[str] = frozenset({'speed', 'zspeed'})
|
|
215
|
+
'''Properties excluded from save/restore.
|
|
216
|
+
|
|
217
|
+
``speed`` and ``zspeed`` reflect the stage's live motion limits.
|
|
218
|
+
Silently writing a stale saved value on reconnect could cause
|
|
219
|
+
unexpected or unsafe stage behaviour, so they are excluded from
|
|
220
|
+
:attr:`settings`.
|
|
221
|
+
|
|
222
|
+
To exclude additional properties in a subclass, redefine
|
|
223
|
+
``_VOLATILE`` as a superset::
|
|
224
|
+
|
|
225
|
+
_VOLATILE = QProscan._VOLATILE | frozenset({'stepsize'})
|
|
226
|
+
'''
|
|
227
|
+
|
|
213
228
|
comm = dict(baudRate=QSerialInstrument.BaudRate.Baud9600,
|
|
214
229
|
dataBits=QSerialInstrument.DataBits.Data8,
|
|
215
230
|
stopBits=QSerialInstrument.StopBits.OneStop,
|
|
@@ -217,22 +232,31 @@ class QProscan(QSerialInstrument):
|
|
|
217
232
|
flowControl=QSerialInstrument.FlowControl.NoFlowControl,
|
|
218
233
|
eol='\r')
|
|
219
234
|
|
|
235
|
+
@property
|
|
236
|
+
def settings(self) -> QAbstractInstrument.Settings:
|
|
237
|
+
return {k: v for k, v in super().settings.items()
|
|
238
|
+
if k not in self._VOLATILE}
|
|
239
|
+
|
|
240
|
+
@settings.setter
|
|
241
|
+
def settings(self, s: QAbstractInstrument.Settings) -> None:
|
|
242
|
+
QAbstractInstrument.settings.fset(
|
|
243
|
+
self, {k: v for k, v in s.items()
|
|
244
|
+
if k not in self._VOLATILE})
|
|
245
|
+
|
|
220
246
|
def _registerProperties(self) -> None:
|
|
221
247
|
self._flip: bool = False
|
|
222
248
|
self._mirror: bool = False
|
|
223
|
-
for name, cmd
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
('zscurve', 'SCZ', True)):
|
|
249
|
+
for name, cmd in (('speed', 'SMS'),
|
|
250
|
+
('acceleration', 'SAS'),
|
|
251
|
+
('scurve', 'SCS'),
|
|
252
|
+
('zspeed', 'SMZ'),
|
|
253
|
+
('zacceleration', 'SAZ'),
|
|
254
|
+
('zscurve', 'SCZ')):
|
|
230
255
|
self.registerProperty(
|
|
231
256
|
name,
|
|
232
257
|
getter=lambda c=cmd: self.getValue(c, int),
|
|
233
258
|
setter=lambda v, c=cmd: self.expect(f'{c},{int(v)}', '0'),
|
|
234
|
-
ptype=int
|
|
235
|
-
persist=persist)
|
|
259
|
+
ptype=int)
|
|
236
260
|
self.registerProperty(
|
|
237
261
|
'stepsize',
|
|
238
262
|
getter=lambda: float(self.handshake('X').split(',')[0]),
|
|
@@ -108,8 +108,9 @@ class QDS345(QSerialInstrument):
|
|
|
108
108
|
def _registerProperties(self) -> None:
|
|
109
109
|
'''Register all instrument properties via ``registerProperty()``.
|
|
110
110
|
|
|
111
|
-
Called
|
|
112
|
-
set should call
|
|
111
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
112
|
+
that extend the property set should call
|
|
113
|
+
``super()._registerProperties()`` first.
|
|
113
114
|
'''
|
|
114
115
|
self._muted: bool = False
|
|
115
116
|
self._saved_amplitude: float
|
|
@@ -144,8 +145,8 @@ class QDS345(QSerialInstrument):
|
|
|
144
145
|
def _registerMethods(self) -> None:
|
|
145
146
|
'''Register all instrument methods via ``registerMethod()``.
|
|
146
147
|
|
|
147
|
-
Called
|
|
148
|
-
call ``super()._registerMethods()`` first.
|
|
148
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
149
|
+
that add methods should call ``super()._registerMethods()`` first.
|
|
149
150
|
'''
|
|
150
151
|
self.registerMethod('reset', self.reset)
|
|
151
152
|
self.registerMethod('trigger', self.trigger)
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from qtpy import QtCore
|
|
3
|
+
from QInstrument.lib.QPollingMixin import QPollingMixin
|
|
2
4
|
from QInstrument.lib.QSerialInstrument import QSerialInstrument
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
logger = logging.getLogger(__name__)
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
class QSR830(QSerialInstrument):
|
|
10
|
+
class QSR830(QPollingMixin, QSerialInstrument):
|
|
9
11
|
'''SRS SR830 Lock-in Amplifier
|
|
10
12
|
|
|
11
13
|
Properties
|
|
@@ -106,8 +108,9 @@ class QSR830(QSerialInstrument):
|
|
|
106
108
|
def _registerProperties(self) -> None:
|
|
107
109
|
'''Register all instrument properties via ``registerProperty()``.
|
|
108
110
|
|
|
109
|
-
Called
|
|
110
|
-
set should call
|
|
111
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
112
|
+
that extend the property set should call
|
|
113
|
+
``super()._registerProperties()`` first.
|
|
111
114
|
'''
|
|
112
115
|
# Reference and Phase
|
|
113
116
|
self._register('amplitude', 'SLVL', float)
|
|
@@ -140,8 +143,8 @@ class QSR830(QSerialInstrument):
|
|
|
140
143
|
def _registerMethods(self) -> None:
|
|
141
144
|
'''Register all instrument methods via ``registerMethod()``.
|
|
142
145
|
|
|
143
|
-
Called
|
|
144
|
-
call ``super()._registerMethods()`` first.
|
|
146
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
147
|
+
that add methods should call ``super()._registerMethods()`` first.
|
|
145
148
|
'''
|
|
146
149
|
self.registerMethod('reset', self.reset)
|
|
147
150
|
self.registerMethod('auto_gain', self.auto_gain)
|
|
@@ -184,6 +187,23 @@ class QSR830(QSerialInstrument):
|
|
|
184
187
|
'''
|
|
185
188
|
return 'SR830' in self.handshake('*IDN?')
|
|
186
189
|
|
|
190
|
+
def _poll(self) -> None:
|
|
191
|
+
'''Poll frequency, R, and theta simultaneously and emit results.
|
|
192
|
+
|
|
193
|
+
Overrides :meth:`QPollingMixin._poll` to use the ``SNAP?9,3,4``
|
|
194
|
+
batch command instead of three sequential queries, keeping the
|
|
195
|
+
captured values time-coherent.
|
|
196
|
+
'''
|
|
197
|
+
if not getattr(self, '_polling', False):
|
|
198
|
+
return
|
|
199
|
+
frequency, r, theta = self.report()
|
|
200
|
+
self.propertyValue.emit('frequency', frequency)
|
|
201
|
+
self.propertyValue.emit('r', r)
|
|
202
|
+
self.propertyValue.emit('theta', theta)
|
|
203
|
+
if getattr(self, '_polling', False):
|
|
204
|
+
QtCore.QTimer.singleShot(
|
|
205
|
+
self.POLL_INTERVAL, self._poll)
|
|
206
|
+
|
|
187
207
|
def report(self) -> list[float]:
|
|
188
208
|
'''Return the current frequency, magnitude, and phase.
|
|
189
209
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from qtpy import QtCore
|
|
3
|
+
from QInstrument.lib.QPollingMixin import QPollingMixin
|
|
2
4
|
from QInstrument.lib.QSerialInstrument import QSerialInstrument
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
logger = logging.getLogger(__name__)
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
class QSR844(QSerialInstrument):
|
|
10
|
+
class QSR844(QPollingMixin, QSerialInstrument):
|
|
9
11
|
'''SRS SR844 RF Lock-in Amplifier
|
|
10
12
|
|
|
11
13
|
Properties
|
|
@@ -93,8 +95,9 @@ class QSR844(QSerialInstrument):
|
|
|
93
95
|
def _registerProperties(self) -> None:
|
|
94
96
|
'''Register all instrument properties via ``registerProperty()``.
|
|
95
97
|
|
|
96
|
-
Called
|
|
97
|
-
set should call
|
|
98
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
99
|
+
that extend the property set should call
|
|
100
|
+
``super()._registerProperties()`` first.
|
|
98
101
|
'''
|
|
99
102
|
# Reference and Phase
|
|
100
103
|
self._register('frequency', 'FREQ', float)
|
|
@@ -128,8 +131,8 @@ class QSR844(QSerialInstrument):
|
|
|
128
131
|
def _registerMethods(self) -> None:
|
|
129
132
|
'''Register all instrument methods via ``registerMethod()``.
|
|
130
133
|
|
|
131
|
-
Called
|
|
132
|
-
call ``super()._registerMethods()`` first.
|
|
134
|
+
Called automatically by ``QAbstractInstrument.__init__``. Subclasses
|
|
135
|
+
that add methods should call ``super()._registerMethods()`` first.
|
|
133
136
|
'''
|
|
134
137
|
self.registerMethod('reset', self.reset)
|
|
135
138
|
self.registerMethod('auto_gain', self.auto_gain)
|
|
@@ -172,6 +175,23 @@ class QSR844(QSerialInstrument):
|
|
|
172
175
|
'''
|
|
173
176
|
return 'SR844' in self.handshake('*IDN?')
|
|
174
177
|
|
|
178
|
+
def _poll(self) -> None:
|
|
179
|
+
'''Poll frequency, R, and theta simultaneously and emit results.
|
|
180
|
+
|
|
181
|
+
Overrides :meth:`QPollingMixin._poll` to use the ``SNAP?9,3,4``
|
|
182
|
+
batch command instead of three sequential queries, keeping the
|
|
183
|
+
captured values time-coherent.
|
|
184
|
+
'''
|
|
185
|
+
if not getattr(self, '_polling', False):
|
|
186
|
+
return
|
|
187
|
+
frequency, r, theta = self.report()
|
|
188
|
+
self.propertyValue.emit('frequency', frequency)
|
|
189
|
+
self.propertyValue.emit('r', r)
|
|
190
|
+
self.propertyValue.emit('theta', theta)
|
|
191
|
+
if getattr(self, '_polling', False):
|
|
192
|
+
QtCore.QTimer.singleShot(
|
|
193
|
+
self.POLL_INTERVAL, self._poll)
|
|
194
|
+
|
|
175
195
|
def report(self) -> list[float]:
|
|
176
196
|
'''Return the current frequency, magnitude, and phase simultaneously.
|
|
177
197
|
|
|
@@ -98,19 +98,24 @@ class Configure(QtCore.QObject):
|
|
|
98
98
|
'''
|
|
99
99
|
return str(self.configdir / (obj.__class__.__name__ + '.json'))
|
|
100
100
|
|
|
101
|
-
def save(self, obj: object
|
|
101
|
+
def save(self, obj: object,
|
|
102
|
+
settings: dict | None = None) -> None:
|
|
102
103
|
'''Save *obj*'s settings to its JSON configuration file.
|
|
103
104
|
|
|
104
105
|
Reads ``obj.settings`` (a dict) and serializes it to
|
|
105
|
-
:meth:`configname`. Does nothing when
|
|
106
|
+
:meth:`configname`. Does nothing when the settings dict is empty.
|
|
107
|
+
An explicit *settings* dict may be supplied to avoid reading from
|
|
108
|
+
*obj* directly — useful when *obj* lives in a worker thread.
|
|
106
109
|
|
|
107
110
|
Parameters
|
|
108
111
|
----------
|
|
109
112
|
obj : object
|
|
110
|
-
Object
|
|
111
|
-
|
|
113
|
+
Object whose class name determines the configuration filename.
|
|
114
|
+
settings : dict or None, optional
|
|
115
|
+
Settings to save. When ``None`` (default), reads
|
|
116
|
+
``obj.settings``.
|
|
112
117
|
'''
|
|
113
|
-
settings = obj.settings
|
|
118
|
+
settings = obj.settings if settings is None else settings
|
|
114
119
|
if not settings:
|
|
115
120
|
return
|
|
116
121
|
filename = self.configname(obj)
|
|
@@ -9,18 +9,16 @@ _AUTO = object() # sentinel: auto-generate getter/setter from _name convention
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class QAbstractInstrument(QtCore.QObject):
|
|
12
|
-
'''Abstract base class
|
|
12
|
+
'''Abstract base class for scientific instruments.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
``transmit()`` and ``receive()`` methods.
|
|
14
|
+
Models instrument state as named properties registered via
|
|
15
|
+
:meth:`registerProperty` and accessed through the thread-safe
|
|
16
|
+
:meth:`get` and :meth:`set` slots. Methods are registered via
|
|
17
|
+
:meth:`registerMethod` and invoked by name via :meth:`execute`.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
:meth:`execute`. Both slots are thread-safe.
|
|
19
|
+
This class has no concept of hardware communication. A concrete
|
|
20
|
+
transport subclass (e.g. :class:`QSerialInstrument`) provides the
|
|
21
|
+
I/O layer and higher-level communication helpers.
|
|
24
22
|
|
|
25
23
|
Signals
|
|
26
24
|
-------
|
|
@@ -39,91 +37,31 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
39
37
|
self.mutex = QtCore.QMutex()
|
|
40
38
|
self._properties = {}
|
|
41
39
|
self._methods = {}
|
|
40
|
+
self._registerProperties()
|
|
41
|
+
self._registerMethods()
|
|
42
|
+
|
|
43
|
+
def __repr__(self) -> str:
|
|
44
|
+
return f'{self.__class__.__name__}()'
|
|
42
45
|
|
|
43
46
|
def _registerProperties(self) -> None:
|
|
44
47
|
'''Register instrument properties.
|
|
45
48
|
|
|
46
|
-
No-op base
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
Called automatically by :meth:`__init__`. No-op base
|
|
50
|
+
implementation; concrete instruments override this to call
|
|
51
|
+
:meth:`registerProperty` for each of their properties.
|
|
52
|
+
Subclasses that extend the property set of a parent instrument
|
|
53
|
+
should call ``super()._registerProperties()`` first.
|
|
50
54
|
'''
|
|
51
55
|
|
|
52
56
|
def _registerMethods(self) -> None:
|
|
53
57
|
'''Register instrument methods.
|
|
54
58
|
|
|
55
|
-
No-op base
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def __repr__(self) -> str:
|
|
62
|
-
return f'{self.__class__.__name__}()'
|
|
63
|
-
|
|
64
|
-
def handshake(self, data: str, **kwargs) -> str:
|
|
65
|
-
'''Transmit a command and return the instrument's response.
|
|
66
|
-
|
|
67
|
-
Delegates to ``transmit()`` and ``receive()``, which must be
|
|
68
|
-
provided by the concrete instrument class.
|
|
69
|
-
|
|
70
|
-
Parameters
|
|
71
|
-
----------
|
|
72
|
-
data : str
|
|
73
|
-
Command string to send to the instrument.
|
|
74
|
-
**kwargs :
|
|
75
|
-
Passed through to ``receive()``.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
str
|
|
80
|
-
Response string from the instrument.
|
|
81
|
-
'''
|
|
82
|
-
self.transmit(data)
|
|
83
|
-
return self.receive(**kwargs).strip()
|
|
84
|
-
|
|
85
|
-
def getValue(self, query: str, dtype: type = float) -> PropertyValue | None:
|
|
86
|
-
'''Query the instrument and return a typed value.
|
|
87
|
-
|
|
88
|
-
Parameters
|
|
89
|
-
----------
|
|
90
|
-
query : str
|
|
91
|
-
Command string that elicits a single-value response.
|
|
92
|
-
dtype : type, optional
|
|
93
|
-
Converts the response string to the desired type.
|
|
94
|
-
Default: ``float``.
|
|
95
|
-
|
|
96
|
-
Returns
|
|
97
|
-
-------
|
|
98
|
-
PropertyValue or None
|
|
99
|
-
Value converted by *dtype*, or ``None`` if conversion fails.
|
|
100
|
-
'''
|
|
101
|
-
response = self.handshake(query)
|
|
102
|
-
try:
|
|
103
|
-
value = dtype(response)
|
|
104
|
-
except ValueError:
|
|
105
|
-
value = None
|
|
106
|
-
return value
|
|
107
|
-
|
|
108
|
-
def expect(self, query: str, response: str, **kwargs) -> bool:
|
|
109
|
-
'''Return True if the instrument's response
|
|
110
|
-
contains the expected string.
|
|
111
|
-
|
|
112
|
-
Parameters
|
|
113
|
-
----------
|
|
114
|
-
query : str
|
|
115
|
-
Command string to send to the instrument.
|
|
116
|
-
response : str
|
|
117
|
-
Substring expected in the instrument's reply.
|
|
118
|
-
**kwargs :
|
|
119
|
-
Passed through to ``receive()``.
|
|
120
|
-
|
|
121
|
-
Returns
|
|
122
|
-
-------
|
|
123
|
-
bool
|
|
124
|
-
``True`` if *response* appears in the instrument's reply.
|
|
59
|
+
Called automatically by :meth:`__init__`. No-op base
|
|
60
|
+
implementation; concrete instruments override this to call
|
|
61
|
+
:meth:`registerMethod` for each of their methods.
|
|
62
|
+
Subclasses that extend the method set of a parent instrument
|
|
63
|
+
should call ``super()._registerMethods()`` first.
|
|
125
64
|
'''
|
|
126
|
-
return response in self.handshake(query, **kwargs)
|
|
127
65
|
|
|
128
66
|
def registerProperty(self,
|
|
129
67
|
name: str,
|
|
@@ -167,6 +105,22 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
167
105
|
self._properties[name] = dict(
|
|
168
106
|
getter=getter, setter=setter, ptype=ptype, **meta)
|
|
169
107
|
|
|
108
|
+
def registerMethod(self,
|
|
109
|
+
name: str,
|
|
110
|
+
method: Callable[[], None]) -> None:
|
|
111
|
+
'''Register a named zero-argument callable.
|
|
112
|
+
|
|
113
|
+
Registered methods can be invoked by name via :meth:`execute`.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
name : str
|
|
118
|
+
Method name used with :meth:`execute`.
|
|
119
|
+
method : callable
|
|
120
|
+
Zero-argument callable to invoke.
|
|
121
|
+
'''
|
|
122
|
+
self._methods[name] = method
|
|
123
|
+
|
|
170
124
|
@property
|
|
171
125
|
def properties(self) -> list[str]:
|
|
172
126
|
'''Names of all registered instrument properties.'''
|
|
@@ -174,23 +128,31 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
174
128
|
|
|
175
129
|
@property
|
|
176
130
|
def settings(self) -> Settings:
|
|
177
|
-
'''Current values of all writable
|
|
131
|
+
'''Current values of all writable registered properties.
|
|
178
132
|
|
|
179
133
|
Getting this property calls every qualifying getter, which may
|
|
180
134
|
issue instrument queries. A property qualifies when its setter
|
|
181
|
-
is not ``None`` (writable)
|
|
182
|
-
``True`` (default).
|
|
135
|
+
is not ``None`` (writable).
|
|
183
136
|
|
|
184
137
|
Setting it calls each registered setter for keys present in the
|
|
185
|
-
supplied dict, skipping unknown keys
|
|
186
|
-
|
|
138
|
+
supplied dict, skipping unknown keys and read-only properties.
|
|
139
|
+
Unlike :meth:`set`, the setter does not emit
|
|
140
|
+
:attr:`propertyValue` for each key; call
|
|
141
|
+
:meth:`_syncProperties` after a bulk restore if the UI must
|
|
142
|
+
reflect the new values.
|
|
143
|
+
|
|
144
|
+
Subclasses that need to exclude specific properties from
|
|
145
|
+
save/restore (e.g. motion-speed parameters that must not be
|
|
146
|
+
silently overwritten on reconnect) should override both the
|
|
147
|
+
getter and setter to filter those names. See
|
|
148
|
+
:class:`QProscan` for an example.
|
|
187
149
|
'''
|
|
188
150
|
with QtCore.QMutexLocker(self.mutex):
|
|
189
151
|
props = list(self._properties.items())
|
|
190
152
|
return {
|
|
191
153
|
name: info['getter']()
|
|
192
154
|
for name, info in props
|
|
193
|
-
if info['setter'] is not None
|
|
155
|
+
if info['setter'] is not None
|
|
194
156
|
}
|
|
195
157
|
|
|
196
158
|
@settings.setter
|
|
@@ -198,12 +160,45 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
198
160
|
with QtCore.QMutexLocker(self.mutex):
|
|
199
161
|
calls = [(self._properties[k]['setter'], v)
|
|
200
162
|
for k, v in settings.items()
|
|
201
|
-
if k in self._properties
|
|
202
|
-
and self._properties[k].get('persist', True)]
|
|
163
|
+
if k in self._properties]
|
|
203
164
|
for setter, value in calls:
|
|
204
165
|
if setter is not None:
|
|
205
166
|
setter(value)
|
|
206
167
|
|
|
168
|
+
@property
|
|
169
|
+
def methods(self) -> list[str]:
|
|
170
|
+
'''Names of all registered instrument methods.'''
|
|
171
|
+
return list(self._methods.keys())
|
|
172
|
+
|
|
173
|
+
@QtCore.Slot(str)
|
|
174
|
+
def get(self, key: str) -> PropertyValue | None:
|
|
175
|
+
'''Return the current value of a registered property.
|
|
176
|
+
|
|
177
|
+
Thread-safe Qt slot. The registry lock is released before
|
|
178
|
+
calling the getter, so the getter may safely call other
|
|
179
|
+
instrument methods without deadlocking. Emits
|
|
180
|
+
:attr:`propertyValue` with the name and value. Logs an error
|
|
181
|
+
and returns ``None`` if the key is not registered.
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
----------
|
|
185
|
+
key : str
|
|
186
|
+
Registered property name.
|
|
187
|
+
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
PropertyValue or None
|
|
191
|
+
Current value, or ``None`` if *key* is unknown.
|
|
192
|
+
'''
|
|
193
|
+
with QtCore.QMutexLocker(self.mutex):
|
|
194
|
+
if key not in self._properties:
|
|
195
|
+
logger.error(f'Unknown property: {key}')
|
|
196
|
+
return None
|
|
197
|
+
getter = self._properties[key]['getter']
|
|
198
|
+
value = getter()
|
|
199
|
+
self.propertyValue.emit(key, value)
|
|
200
|
+
return value
|
|
201
|
+
|
|
207
202
|
@QtCore.Slot(str, object)
|
|
208
203
|
def set(self, key: str, value: PropertyValue) -> None:
|
|
209
204
|
'''Set a registered property to the given value.
|
|
@@ -259,62 +254,6 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
259
254
|
info['readonly'] = info.pop('setter', None) is None
|
|
260
255
|
return info
|
|
261
256
|
|
|
262
|
-
@QtCore.Slot(str)
|
|
263
|
-
def get(self, key: str) -> PropertyValue | None:
|
|
264
|
-
'''Return the current value of a registered property.
|
|
265
|
-
|
|
266
|
-
Thread-safe Qt slot. The registry lock is released before
|
|
267
|
-
calling the getter, so the getter may safely call other
|
|
268
|
-
instrument methods without deadlocking. Emits
|
|
269
|
-
:attr:`propertyValue` with the name and value. Logs an error
|
|
270
|
-
and returns ``None`` if the key is not registered.
|
|
271
|
-
|
|
272
|
-
Parameters
|
|
273
|
-
----------
|
|
274
|
-
key : str
|
|
275
|
-
Registered property name.
|
|
276
|
-
|
|
277
|
-
Returns
|
|
278
|
-
-------
|
|
279
|
-
PropertyValue or None
|
|
280
|
-
Current value, or ``None`` if *key* is unknown.
|
|
281
|
-
'''
|
|
282
|
-
with QtCore.QMutexLocker(self.mutex):
|
|
283
|
-
if key not in self._properties:
|
|
284
|
-
logger.error(f'Unknown property: {key}')
|
|
285
|
-
return None
|
|
286
|
-
getter = self._properties[key]['getter']
|
|
287
|
-
value = getter()
|
|
288
|
-
self.propertyValue.emit(key, value)
|
|
289
|
-
return value
|
|
290
|
-
|
|
291
|
-
def busy(self) -> bool:
|
|
292
|
-
'''Return True if the instrument is busy.
|
|
293
|
-
|
|
294
|
-
Returns ``False`` by default. Subclasses should override this
|
|
295
|
-
if the instrument exposes a queryable busy/ready state.
|
|
296
|
-
'''
|
|
297
|
-
return False
|
|
298
|
-
|
|
299
|
-
def registerMethod(self, name: str, method: Callable[[], None]) -> None:
|
|
300
|
-
'''Register a named zero-argument callable.
|
|
301
|
-
|
|
302
|
-
Registered methods can be invoked by name via :meth:`execute`.
|
|
303
|
-
|
|
304
|
-
Parameters
|
|
305
|
-
----------
|
|
306
|
-
name : str
|
|
307
|
-
Method name used with :meth:`execute`.
|
|
308
|
-
method : callable
|
|
309
|
-
Zero-argument callable to invoke.
|
|
310
|
-
'''
|
|
311
|
-
self._methods[name] = method
|
|
312
|
-
|
|
313
|
-
@property
|
|
314
|
-
def methods(self) -> list[str]:
|
|
315
|
-
'''Names of all registered instrument methods.'''
|
|
316
|
-
return list(self._methods.keys())
|
|
317
|
-
|
|
318
257
|
@QtCore.Slot(str)
|
|
319
258
|
def execute(self, key: str) -> None:
|
|
320
259
|
'''Call a registered method by name.
|
|
@@ -334,4 +273,5 @@ class QAbstractInstrument(QtCore.QObject):
|
|
|
334
273
|
method = self._methods[key]
|
|
335
274
|
method()
|
|
336
275
|
|
|
276
|
+
|
|
337
277
|
__all__ = ['QAbstractInstrument']
|