QInstrument 2.4.1__tar.gz → 3.0.1__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.
Files changed (126) hide show
  1. {qinstrument-2.4.1 → qinstrument-3.0.1}/PKG-INFO +1 -1
  2. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/PKG-INFO +1 -1
  3. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/SOURCES.txt +5 -8
  4. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/fake.py +1 -0
  5. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/instrument.py +62 -10
  6. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/widget.py +23 -18
  7. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/instrument.py +5 -4
  8. qinstrument-3.0.1/instruments/StanfordResearch/SR830/__init__.py +10 -0
  9. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR830/fake.py +2 -7
  10. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR830/instrument.py +5 -23
  11. qinstrument-3.0.1/instruments/StanfordResearch/SR844/__init__.py +10 -0
  12. qinstrument-3.0.1/instruments/StanfordResearch/SR844/fake.py +27 -0
  13. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR844/instrument.py +5 -32
  14. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/Configure.py +10 -5
  15. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QAbstractInstrument.py +89 -149
  16. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QFakeInstrument.py +13 -18
  17. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QInstrumentTree.py +143 -60
  18. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QInstrumentWidget.py +114 -79
  19. qinstrument-3.0.1/lib/QPollingMixin.py +97 -0
  20. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QReconcileDialog.py +4 -2
  21. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QSerialInstrument.py +127 -59
  22. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/QSerialInterface.py +26 -96
  23. {qinstrument-2.4.1 → qinstrument-3.0.1}/lib/__init__.py +1 -0
  24. qinstrument-3.0.1/lib/lazy.py +124 -0
  25. {qinstrument-2.4.1 → qinstrument-3.0.1}/pyproject.toml +1 -1
  26. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_Configure.py +16 -0
  27. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QAbstractInstrument.py +0 -43
  28. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QFakeInstrument.py +0 -4
  29. qinstrument-3.0.1/tests/test_QInstrumentTree.py +347 -0
  30. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QInstrumentWidget.py +53 -2
  31. qinstrument-3.0.1/tests/test_QPollingMixin.py +132 -0
  32. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QProscan.py +59 -0
  33. qinstrument-3.0.1/tests/test_QReconcileDialog.py +85 -0
  34. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QSR830.py +2 -2
  35. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QSR844.py +2 -3
  36. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QSerialInstrument.py +35 -0
  37. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QSerialInterface.py +1 -83
  38. qinstrument-2.4.1/instruments/StanfordResearch/SR830/__init__.py +0 -6
  39. qinstrument-2.4.1/instruments/StanfordResearch/SR830/worker.py +0 -38
  40. qinstrument-2.4.1/instruments/StanfordResearch/SR844/__init__.py +0 -6
  41. qinstrument-2.4.1/instruments/StanfordResearch/SR844/fake.py +0 -36
  42. qinstrument-2.4.1/instruments/StanfordResearch/SR844/worker.py +0 -38
  43. qinstrument-2.4.1/lib/QInstrumentWorker.py +0 -119
  44. qinstrument-2.4.1/lib/lazy.py +0 -52
  45. qinstrument-2.4.1/tests/test_QInstrumentWorker.py +0 -164
  46. qinstrument-2.4.1/tests/test_QSR830Worker.py +0 -107
  47. {qinstrument-2.4.1 → qinstrument-3.0.1}/LICENSE.md +0 -0
  48. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/dependency_links.txt +0 -0
  49. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/entry_points.txt +0 -0
  50. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/requires.txt +0 -0
  51. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrument.egg-info/top_level.txt +0 -0
  52. {qinstrument-2.4.1 → qinstrument-3.0.1}/QInstrumentRack.py +0 -0
  53. {qinstrument-2.4.1 → qinstrument-3.0.1}/README.md +0 -0
  54. {qinstrument-2.4.1 → qinstrument-3.0.1}/__init__.py +0 -0
  55. {qinstrument-2.4.1 → qinstrument-3.0.1}/__main__.py +0 -0
  56. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/IPGLaserWidget.ui +0 -0
  57. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/__init__.py +0 -0
  58. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/fake.py +0 -0
  59. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/instrument.py +0 -0
  60. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/tree.py +0 -0
  61. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/IPGLaser/widget.py +0 -0
  62. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/IPGPhotonics/__init__.py +0 -0
  63. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/OpusWidget.ui +0 -0
  64. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/__init__.py +0 -0
  65. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/fake.py +0 -0
  66. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/instrument.py +0 -0
  67. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/tree.py +0 -0
  68. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus/widget.py +0 -0
  69. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus1064/__init__.py +0 -0
  70. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus1064/fake.py +0 -0
  71. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus1064/instrument.py +0 -0
  72. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus1064/tree.py +0 -0
  73. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus1064/widget.py +0 -0
  74. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus532/__init__.py +0 -0
  75. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus532/fake.py +0 -0
  76. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus532/instrument.py +0 -0
  77. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus532/tree.py +0 -0
  78. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus532/widget.py +0 -0
  79. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus660/__init__.py +0 -0
  80. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus660/fake.py +0 -0
  81. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus660/instrument.py +0 -0
  82. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus660/tree.py +0 -0
  83. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/Opus660/widget.py +0 -0
  84. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Novanta/__init__.py +0 -0
  85. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/PDUS210Widget.ui +0 -0
  86. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/__init__.py +0 -0
  87. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/fake.py +0 -0
  88. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/instrument.py +0 -0
  89. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/tree.py +0 -0
  90. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/PDUS210/widget.py +0 -0
  91. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PiezoDrive/__init__.py +0 -0
  92. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/ProscanWidget.ui +0 -0
  93. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/__init__.py +0 -0
  94. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/Proscan/tree.py +0 -0
  95. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/PriorScientific/__init__.py +0 -0
  96. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/DS345Widget.ui +0 -0
  97. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/__init__.py +0 -0
  98. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/fake.py +0 -0
  99. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/tree.py +0 -0
  100. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/DS345/widget.py +0 -0
  101. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR830/SR830Widget.ui +0 -0
  102. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR830/tree.py +0 -0
  103. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR830/widget.py +0 -0
  104. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR844/SR844Widget.ui +0 -0
  105. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR844/tree.py +0 -0
  106. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/SR844/widget.py +0 -0
  107. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/StanfordResearch/__init__.py +0 -0
  108. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Tektronix/TDS1000/__init__.py +0 -0
  109. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Tektronix/TDS1000/instrument.py +0 -0
  110. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/Tektronix/__init__.py +0 -0
  111. {qinstrument-2.4.1 → qinstrument-3.0.1}/instruments/__init__.py +0 -0
  112. {qinstrument-2.4.1 → qinstrument-3.0.1}/setup.cfg +0 -0
  113. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QDS345.py +0 -0
  114. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QIPGLaser.py +0 -0
  115. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QInstrumentRack.py +0 -0
  116. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QLedWidget.py +0 -0
  117. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QOpus.py +0 -0
  118. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QPDUS210.py +0 -0
  119. {qinstrument-2.4.1 → qinstrument-3.0.1}/tests/test_QRotaryEncoderSpinBox.py +0 -0
  120. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QJoystick.py +0 -0
  121. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QJoystickPad.py +0 -0
  122. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QLedWidget.py +0 -0
  123. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QRotaryEncoder.py +0 -0
  124. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QRotaryEncoderSpinBox.py +0 -0
  125. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/QRotaryEncoderSpinBox.ui +0 -0
  126. {qinstrument-2.4.1 → qinstrument-3.0.1}/widgets/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QInstrument
3
- Version: 2.4.1
3
+ Version: 3.0.1
4
4
  Summary: Qt-based framework for controlling scientific instruments over serial ports
5
5
  Author-email: "David G. Grier" <david.grier@nyu.edu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QInstrument
3
- Version: 2.4.1
3
+ Version: 3.0.1
4
4
  Summary: Qt-based framework for controlling scientific instruments over serial ports
5
5
  Author-email: "David G. Grier" <david.grier@nyu.edu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -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/QInstrumentWorker.py
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/QInstrumentWorker.py
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
@@ -13,6 +13,7 @@ class QFakeProscan(QFakeInstrument, QProscan):
13
13
  '''
14
14
 
15
15
  positionChanged = QtCore.Signal(object)
16
+ limitsChanged = QtCore.Signal(object)
16
17
 
17
18
  def _registerProperties(self) -> None:
18
19
  for name, default in (('speed', 50),
@@ -2,13 +2,15 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from qtpy import QtCore
5
+ from QInstrument.lib.QAbstractInstrument import QAbstractInstrument
6
+ from QInstrument.lib.QPollingMixin import QPollingMixin
5
7
  from QInstrument.lib.QSerialInstrument import QSerialInstrument
6
8
 
7
9
 
8
10
  logger = logging.getLogger(__name__)
9
11
 
10
12
 
11
- class QProscan(QSerialInstrument):
13
+ class QProscan(QPollingMixin, QSerialInstrument):
12
14
  '''Prior Scientific Proscan II/III Microscope Stage Controller.
13
15
 
14
16
  Controls the XY stage and Z focus drive of a Prior Scientific
@@ -19,6 +21,10 @@ class QProscan(QSerialInstrument):
19
21
  positionChanged(list[int])
20
22
  Emitted by :meth:`position` with the current ``[x, y, z]``
21
23
  coordinates in µm.
24
+ limitsChanged(object)
25
+ Emitted by :meth:`_poll` with the result of :meth:`active_limits`
26
+ after each position update. Value is a
27
+ ``tuple[bool, bool, bool, bool]`` or ``None``.
22
28
 
23
29
  Properties
24
30
  ==========
@@ -209,6 +215,23 @@ class QProscan(QSerialInstrument):
209
215
  '''
210
216
 
211
217
  positionChanged = QtCore.Signal(object)
218
+ limitsChanged = QtCore.Signal(object)
219
+
220
+ POLL_INTERVAL: int = 200
221
+
222
+ _VOLATILE: frozenset[str] = frozenset({'speed', 'zspeed'})
223
+ '''Properties excluded from save/restore.
224
+
225
+ ``speed`` and ``zspeed`` reflect the stage's live motion limits.
226
+ Silently writing a stale saved value on reconnect could cause
227
+ unexpected or unsafe stage behaviour, so they are excluded from
228
+ :attr:`settings`.
229
+
230
+ To exclude additional properties in a subclass, redefine
231
+ ``_VOLATILE`` as a superset::
232
+
233
+ _VOLATILE = QProscan._VOLATILE | frozenset({'stepsize'})
234
+ '''
212
235
 
213
236
  comm = dict(baudRate=QSerialInstrument.BaudRate.Baud9600,
214
237
  dataBits=QSerialInstrument.DataBits.Data8,
@@ -217,22 +240,31 @@ class QProscan(QSerialInstrument):
217
240
  flowControl=QSerialInstrument.FlowControl.NoFlowControl,
218
241
  eol='\r')
219
242
 
243
+ @property
244
+ def settings(self) -> QAbstractInstrument.Settings:
245
+ return {k: v for k, v in super().settings.items()
246
+ if k not in self._VOLATILE}
247
+
248
+ @settings.setter
249
+ def settings(self, s: QAbstractInstrument.Settings) -> None:
250
+ QAbstractInstrument.settings.fset(
251
+ self, {k: v for k, v in s.items()
252
+ if k not in self._VOLATILE})
253
+
220
254
  def _registerProperties(self) -> None:
221
255
  self._flip: bool = False
222
256
  self._mirror: bool = False
223
- for name, cmd, persist in (
224
- ('speed', 'SMS', False),
225
- ('acceleration', 'SAS', True),
226
- ('scurve', 'SCS', True),
227
- ('zspeed', 'SMZ', False),
228
- ('zacceleration', 'SAZ', True),
229
- ('zscurve', 'SCZ', True)):
257
+ for name, cmd in (('speed', 'SMS'),
258
+ ('acceleration', 'SAS'),
259
+ ('scurve', 'SCS'),
260
+ ('zspeed', 'SMZ'),
261
+ ('zacceleration', 'SAZ'),
262
+ ('zscurve', 'SCZ')):
230
263
  self.registerProperty(
231
264
  name,
232
265
  getter=lambda c=cmd: self.getValue(c, int),
233
266
  setter=lambda v, c=cmd: self.expect(f'{c},{int(v)}', '0'),
234
- ptype=int,
235
- persist=persist)
267
+ ptype=int)
236
268
  self.registerProperty(
237
269
  'stepsize',
238
270
  getter=lambda: float(self.handshake('X').split(',')[0]),
@@ -317,6 +349,26 @@ class QProscan(QSerialInstrument):
317
349
  '''Return the 3-character firmware version string.'''
318
350
  return self.handshake('VERSION')
319
351
 
352
+ def _poll(self) -> None:
353
+ '''Query position and limit switches, emitting both signals.
354
+
355
+ Overrides :meth:`QPollingMixin._poll` to batch the two most
356
+ time-sensitive reads — stage position and active limits — into
357
+ a single poll cycle. Position is emitted via
358
+ :attr:`positionChanged`; limits via :attr:`limitsChanged`.
359
+ Parse errors are logged at DEBUG level and skipped without
360
+ stopping the loop.
361
+ '''
362
+ if not getattr(self, '_polling', False):
363
+ return
364
+ try:
365
+ self.position()
366
+ self.limitsChanged.emit(self.active_limits())
367
+ except (ValueError, TypeError) as exc:
368
+ logger.debug('poll error: %s', exc)
369
+ if getattr(self, '_polling', False):
370
+ QtCore.QTimer.singleShot(self.POLL_INTERVAL, self._poll)
371
+
320
372
  def position(self) -> list[int]:
321
373
  '''Return the current stage position and emit :attr:`positionChanged`.
322
374
 
@@ -30,19 +30,18 @@ class QProscanWidget(QInstrumentWidget):
30
30
 
31
31
  def __init__(self, *args,
32
32
  interval: int | None = None, **kwargs) -> None:
33
- '''Initialize the widget and start a timer to poll the stage.
33
+ '''Initialize the widget.
34
34
 
35
35
  Parameters
36
36
  ----------
37
- interval: int or None, optional
38
- The timer interval in milliseconds for polling position and
39
- limit status. Default: 200
37
+ interval : int or None, optional
38
+ Poll interval in milliseconds for position and limit updates.
39
+ Overrides :attr:`QProscan.POLL_INTERVAL`. Default: 200.
40
40
  '''
41
41
  super().__init__(*args, **kwargs)
42
42
  self._interval = int(interval or 200)
43
- self.joystick.setRange(-200., 200.)
44
43
  self._prev_limits = None
45
- self._startPolling()
44
+ self.joystick.setRange(-200., 200.)
46
45
 
47
46
  def _connectSignals(self) -> None:
48
47
  super()._connectSignals()
@@ -54,6 +53,15 @@ class QProscanWidget(QInstrumentWidget):
54
53
  self.set_origin.clicked.connect(self.device.set_origin)
55
54
  self.advancedToggle.toggled.connect(self._onAdvancedToggled)
56
55
  self.advanced.setVisible(False)
56
+ self.device.positionChanged.connect(self._onPositionChanged)
57
+ self.device.limitsChanged.connect(self._onLimitsChanged)
58
+
59
+ def _firstShow(self) -> None:
60
+ super()._firstShow()
61
+ self.device.POLL_INTERVAL = self._interval
62
+ QtCore.QMetaObject.invokeMethod(
63
+ self.device, 'startPolling',
64
+ QtCore.Qt.ConnectionType.QueuedConnection)
57
65
 
58
66
  @QtCore.Slot(bool)
59
67
  def _onAdvancedToggled(self, checked: bool) -> None:
@@ -67,23 +75,20 @@ class QProscanWidget(QInstrumentWidget):
67
75
  super().showEvent(event)
68
76
  self.window().adjustSize()
69
77
 
70
- def _startPolling(self) -> None:
71
- self._timer = QtCore.QTimer(self)
72
- self._timer.timeout.connect(self._poll)
73
- if self.device is not None and self.device.isOpen():
74
- self._timer.start(self._interval)
75
-
76
- @QtCore.Slot()
77
- def _poll(self) -> None:
78
- '''Query and display the current stage position and limit status.'''
78
+ @QtCore.Slot(object)
79
+ def _onPositionChanged(self, pos: list[int]) -> None:
80
+ '''Update the XYZ position displays.'''
79
81
  try:
80
- x, y, z = self.device.position()
81
- limits = self.device.active_limits()
82
- except (ValueError, TypeError):
82
+ x, y, z = pos
83
+ except (TypeError, ValueError):
83
84
  return
84
85
  self.x.display(x)
85
86
  self.y.display(y)
86
87
  self.z.display(z)
88
+
89
+ @QtCore.Slot(object)
90
+ def _onLimitsChanged(self, limits: object) -> None:
91
+ '''Update limit-switch indicator styles and log new activations.'''
87
92
  if limits and not self._prev_limits:
88
93
  logger.warning(
89
94
  f'Limit switch active: X={limits[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 once from ``__init__``. Subclasses that extend the property
112
- set should call ``super()._registerProperties()`` first.
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 once from ``__init__``. Subclasses that add methods should
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)
@@ -0,0 +1,10 @@
1
+ from QInstrument.lib.lazy import make_getattr
2
+
3
+ _lazy = {
4
+ 'QSR830': 'instrument',
5
+ 'QFakeSR830': 'fake',
6
+ 'QSR830Widget': 'widget',
7
+ }
8
+
9
+ __getattr__ = make_getattr(_lazy, __name__)
10
+ __all__ = list(_lazy)
@@ -6,17 +6,12 @@ from QInstrument.instruments.StanfordResearch.SR830.instrument import QSR830
6
6
  class QFakeSR830(QFakeInstrument, QSR830):
7
7
  '''Fake SR830 for UI development without hardware.
8
8
 
9
- All standard read/write properties are backed by an in-memory store
10
- via the MRO auto-mock pattern. The four read-only output channels
11
- (x, y, r, theta) are re-registered here to return ``0.0`` from the
12
- store rather than attempting wire communication.
9
+ All read/write properties are backed by an in-memory store via the
10
+ MRO auto-mock pattern.
13
11
  '''
14
12
 
15
13
  def _registerProperties(self) -> None:
16
14
  QSR830._registerProperties(self)
17
- for name in ('x', 'y', 'r', 'theta'):
18
- self.registerProperty(name, setter=None, ptype=float,
19
- getter=lambda n=name: self._store.get(n, 0.))
20
15
  self.identification = 'Fake SR830 Lock-in Amplifier'
21
16
 
22
17
  def identify(self) -> bool:
@@ -84,16 +84,6 @@ class QSR830(QSerialInstrument):
84
84
  8: 100 ms 18: 10 ks
85
85
  9: 300 ms 19: 30 ks
86
86
 
87
- Output (read-only)
88
- ------------------
89
- x : float [V]
90
- In-phase (X) component of the lock-in signal.
91
- y : float [V]
92
- Quadrature (Y) component of the lock-in signal.
93
- r : float [V]
94
- Magnitude R of the lock-in signal.
95
- theta : float [degrees]
96
- Phase angle theta of the lock-in signal.
97
87
  '''
98
88
 
99
89
  comm = dict(baudRate=QSerialInstrument.BaudRate.Baud9600,
@@ -106,8 +96,9 @@ class QSR830(QSerialInstrument):
106
96
  def _registerProperties(self) -> None:
107
97
  '''Register all instrument properties via ``registerProperty()``.
108
98
 
109
- Called once from ``__init__``. Subclasses that extend the property
110
- set should call ``super()._registerProperties()`` first.
99
+ Called automatically by ``QAbstractInstrument.__init__``. Subclasses
100
+ that extend the property set should call
101
+ ``super()._registerProperties()`` first.
111
102
  '''
112
103
  # Reference and Phase
113
104
  self._register('amplitude', 'SLVL', float)
@@ -127,21 +118,12 @@ class QSR830(QSerialInstrument):
127
118
  self._register('sensitivity', 'SENS', int)
128
119
  self._register('synchronous_filter', 'SYNC', bool)
129
120
  self._register('time_constant', 'OFLT', int)
130
- # Output channels (read-only)
131
- self.registerProperty('x', setter=None, ptype=float,
132
- getter=lambda: self.getValue('OUTP?1', float))
133
- self.registerProperty('y', setter=None, ptype=float,
134
- getter=lambda: self.getValue('OUTP?2', float))
135
- self.registerProperty('r', setter=None, ptype=float,
136
- getter=lambda: self.getValue('OUTP?3', float))
137
- self.registerProperty('theta', setter=None, ptype=float,
138
- getter=lambda: self.getValue('OUTP?4', float))
139
121
 
140
122
  def _registerMethods(self) -> None:
141
123
  '''Register all instrument methods via ``registerMethod()``.
142
124
 
143
- Called once from ``__init__``. Subclasses that add methods should
144
- call ``super()._registerMethods()`` first.
125
+ Called automatically by ``QAbstractInstrument.__init__``. Subclasses
126
+ that add methods should call ``super()._registerMethods()`` first.
145
127
  '''
146
128
  self.registerMethod('reset', self.reset)
147
129
  self.registerMethod('auto_gain', self.auto_gain)
@@ -0,0 +1,10 @@
1
+ from QInstrument.lib.lazy import make_getattr
2
+
3
+ _lazy = {
4
+ 'QSR844': 'instrument',
5
+ 'QFakeSR844': 'fake',
6
+ 'QSR844Widget': 'widget',
7
+ }
8
+
9
+ __getattr__ = make_getattr(_lazy, __name__)
10
+ __all__ = list(_lazy)
@@ -0,0 +1,27 @@
1
+ import numpy as np
2
+ from QInstrument.lib.QFakeInstrument import QFakeInstrument
3
+ from QInstrument.instruments.StanfordResearch.SR844.instrument import QSR844
4
+
5
+
6
+ class QFakeSR844(QFakeInstrument, QSR844):
7
+ '''Fake SR844 for UI development without hardware.
8
+
9
+ All read/write properties are backed by an in-memory store via the
10
+ MRO auto-mock pattern.
11
+ '''
12
+
13
+ def _registerProperties(self) -> None:
14
+ QSR844._registerProperties(self)
15
+ self.identification = 'Fake SR844 RF Lock-in Amplifier'
16
+
17
+ def identify(self) -> bool:
18
+ return True
19
+
20
+ def report(self) -> list[float]:
21
+ '''Return simulated [frequency, R, theta].'''
22
+ data = np.random.rand(3)
23
+ data[2] *= 360.
24
+ return data.tolist()
25
+
26
+
27
+ __all__ = ['QFakeSR844']
@@ -67,20 +67,6 @@ class QSR844(QSerialInstrument):
67
67
  7: 300 ms 16: 10 ks
68
68
  8: 1 s 17: 30 ks
69
69
 
70
- Output (read-only)
71
- ------------------
72
- reference_frequency : int [Hz]
73
- Actual reference frequency being used.
74
- if_frequency : int [Hz]
75
- IF frequency (reference frequency mod 200 MHz).
76
- x : float [V]
77
- In-phase (X) component of the lock-in signal.
78
- y : float [V]
79
- Quadrature (Y) component of the lock-in signal.
80
- r : float [V]
81
- Magnitude R of the lock-in signal.
82
- theta : float [degrees]
83
- Phase angle theta of the lock-in signal.
84
70
  '''
85
71
 
86
72
  comm = dict(baudRate=QSerialInstrument.BaudRate.Baud19200,
@@ -93,8 +79,9 @@ class QSR844(QSerialInstrument):
93
79
  def _registerProperties(self) -> None:
94
80
  '''Register all instrument properties via ``registerProperty()``.
95
81
 
96
- Called once from ``__init__``. Subclasses that extend the property
97
- set should call ``super()._registerProperties()`` first.
82
+ Called automatically by ``QAbstractInstrument.__init__``. Subclasses
83
+ that extend the property set should call
84
+ ``super()._registerProperties()`` first.
98
85
  '''
99
86
  # Reference and Phase
100
87
  self._register('frequency', 'FREQ', float)
@@ -110,26 +97,12 @@ class QSR844(QSerialInstrument):
110
97
  self._register('low_pass_slope', 'OFSL', int)
111
98
  self._register('sensitivity', 'SENS', int)
112
99
  self._register('time_constant', 'OFLT', int)
113
- # Read-only frequency displays
114
- self.registerProperty('reference_frequency', setter=None, ptype=int,
115
- getter=lambda: self.getValue('FRAQ?', int))
116
- self.registerProperty('if_frequency', setter=None, ptype=int,
117
- getter=lambda: self.getValue('FRIQ?', int))
118
- # Output channels (read-only)
119
- self.registerProperty('x', setter=None, ptype=float,
120
- getter=lambda: self.getValue('OUTP?1', float))
121
- self.registerProperty('y', setter=None, ptype=float,
122
- getter=lambda: self.getValue('OUTP?2', float))
123
- self.registerProperty('r', setter=None, ptype=float,
124
- getter=lambda: self.getValue('OUTP?3', float))
125
- self.registerProperty('theta', setter=None, ptype=float,
126
- getter=lambda: self.getValue('OUTP?4', float))
127
100
 
128
101
  def _registerMethods(self) -> None:
129
102
  '''Register all instrument methods via ``registerMethod()``.
130
103
 
131
- Called once from ``__init__``. Subclasses that add methods should
132
- call ``super()._registerMethods()`` first.
104
+ Called automatically by ``QAbstractInstrument.__init__``. Subclasses
105
+ that add methods should call ``super()._registerMethods()`` first.
133
106
  '''
134
107
  self.registerMethod('reset', self.reset)
135
108
  self.registerMethod('auto_gain', self.auto_gain)
@@ -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) -> None:
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 ``obj.settings`` is empty.
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 with a ``settings`` property returning a
111
- ``dict[str, bool | int | float | str]``.
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)