QInstrument 3.0.0__tar.gz → 3.0.2__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 (118) hide show
  1. {qinstrument-3.0.0 → qinstrument-3.0.2}/PKG-INFO +1 -1
  2. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/PKG-INFO +1 -1
  3. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/fake.py +1 -0
  4. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/instrument.py +29 -1
  5. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/widget.py +23 -18
  6. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/fake.py +2 -7
  7. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/instrument.py +1 -39
  8. qinstrument-3.0.2/instruments/StanfordResearch/SR844/fake.py +27 -0
  9. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR844/instrument.py +1 -48
  10. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QInstrumentTree.py +8 -14
  11. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QInstrumentWidget.py +6 -11
  12. {qinstrument-3.0.0 → qinstrument-3.0.2}/pyproject.toml +1 -1
  13. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QInstrumentWidget.py +1 -15
  14. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QProscan.py +59 -0
  15. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QSR830.py +1 -40
  16. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QSR844.py +1 -41
  17. qinstrument-3.0.0/instruments/StanfordResearch/SR844/fake.py +0 -36
  18. {qinstrument-3.0.0 → qinstrument-3.0.2}/LICENSE.md +0 -0
  19. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/SOURCES.txt +0 -0
  20. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/dependency_links.txt +0 -0
  21. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/entry_points.txt +0 -0
  22. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/requires.txt +0 -0
  23. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrument.egg-info/top_level.txt +0 -0
  24. {qinstrument-3.0.0 → qinstrument-3.0.2}/QInstrumentRack.py +0 -0
  25. {qinstrument-3.0.0 → qinstrument-3.0.2}/README.md +0 -0
  26. {qinstrument-3.0.0 → qinstrument-3.0.2}/__init__.py +0 -0
  27. {qinstrument-3.0.0 → qinstrument-3.0.2}/__main__.py +0 -0
  28. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/IPGLaserWidget.ui +0 -0
  29. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/__init__.py +0 -0
  30. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/fake.py +0 -0
  31. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/instrument.py +0 -0
  32. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/tree.py +0 -0
  33. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/IPGLaser/widget.py +0 -0
  34. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/IPGPhotonics/__init__.py +0 -0
  35. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/OpusWidget.ui +0 -0
  36. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/__init__.py +0 -0
  37. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/fake.py +0 -0
  38. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/instrument.py +0 -0
  39. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/tree.py +0 -0
  40. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus/widget.py +0 -0
  41. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus1064/__init__.py +0 -0
  42. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus1064/fake.py +0 -0
  43. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus1064/instrument.py +0 -0
  44. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus1064/tree.py +0 -0
  45. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus1064/widget.py +0 -0
  46. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus532/__init__.py +0 -0
  47. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus532/fake.py +0 -0
  48. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus532/instrument.py +0 -0
  49. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus532/tree.py +0 -0
  50. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus532/widget.py +0 -0
  51. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus660/__init__.py +0 -0
  52. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus660/fake.py +0 -0
  53. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus660/instrument.py +0 -0
  54. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus660/tree.py +0 -0
  55. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/Opus660/widget.py +0 -0
  56. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Novanta/__init__.py +0 -0
  57. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/PDUS210Widget.ui +0 -0
  58. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/__init__.py +0 -0
  59. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/fake.py +0 -0
  60. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/instrument.py +0 -0
  61. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/tree.py +0 -0
  62. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/PDUS210/widget.py +0 -0
  63. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PiezoDrive/__init__.py +0 -0
  64. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/ProscanWidget.ui +0 -0
  65. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/__init__.py +0 -0
  66. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/Proscan/tree.py +0 -0
  67. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/PriorScientific/__init__.py +0 -0
  68. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/DS345Widget.ui +0 -0
  69. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/__init__.py +0 -0
  70. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/fake.py +0 -0
  71. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/instrument.py +0 -0
  72. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/tree.py +0 -0
  73. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/DS345/widget.py +0 -0
  74. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/SR830Widget.ui +0 -0
  75. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/__init__.py +0 -0
  76. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/tree.py +0 -0
  77. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR830/widget.py +0 -0
  78. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR844/SR844Widget.ui +0 -0
  79. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR844/__init__.py +0 -0
  80. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR844/tree.py +0 -0
  81. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/SR844/widget.py +0 -0
  82. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/StanfordResearch/__init__.py +0 -0
  83. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Tektronix/TDS1000/__init__.py +0 -0
  84. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Tektronix/TDS1000/instrument.py +0 -0
  85. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/Tektronix/__init__.py +0 -0
  86. {qinstrument-3.0.0 → qinstrument-3.0.2}/instruments/__init__.py +0 -0
  87. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/Configure.py +0 -0
  88. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QAbstractInstrument.py +0 -0
  89. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QFakeInstrument.py +0 -0
  90. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QPollingMixin.py +0 -0
  91. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QReconcileDialog.py +0 -0
  92. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QSerialInstrument.py +0 -0
  93. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/QSerialInterface.py +0 -0
  94. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/__init__.py +0 -0
  95. {qinstrument-3.0.0 → qinstrument-3.0.2}/lib/lazy.py +0 -0
  96. {qinstrument-3.0.0 → qinstrument-3.0.2}/setup.cfg +0 -0
  97. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_Configure.py +0 -0
  98. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QAbstractInstrument.py +0 -0
  99. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QDS345.py +0 -0
  100. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QFakeInstrument.py +0 -0
  101. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QIPGLaser.py +0 -0
  102. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QInstrumentRack.py +0 -0
  103. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QInstrumentTree.py +0 -0
  104. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QLedWidget.py +0 -0
  105. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QOpus.py +0 -0
  106. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QPDUS210.py +0 -0
  107. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QPollingMixin.py +0 -0
  108. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QReconcileDialog.py +0 -0
  109. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QRotaryEncoderSpinBox.py +0 -0
  110. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QSerialInstrument.py +0 -0
  111. {qinstrument-3.0.0 → qinstrument-3.0.2}/tests/test_QSerialInterface.py +0 -0
  112. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QJoystick.py +0 -0
  113. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QJoystickPad.py +0 -0
  114. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QLedWidget.py +0 -0
  115. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QRotaryEncoder.py +0 -0
  116. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QRotaryEncoderSpinBox.py +0 -0
  117. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/QRotaryEncoderSpinBox.ui +0 -0
  118. {qinstrument-3.0.0 → qinstrument-3.0.2}/widgets/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QInstrument
3
- Version: 3.0.0
3
+ Version: 3.0.2
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: 3.0.0
3
+ Version: 3.0.2
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
@@ -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),
@@ -3,13 +3,14 @@ from __future__ import annotations
3
3
  import logging
4
4
  from qtpy import QtCore
5
5
  from QInstrument.lib.QAbstractInstrument import QAbstractInstrument
6
+ from QInstrument.lib.QPollingMixin import QPollingMixin
6
7
  from QInstrument.lib.QSerialInstrument import QSerialInstrument
7
8
 
8
9
 
9
10
  logger = logging.getLogger(__name__)
10
11
 
11
12
 
12
- class QProscan(QSerialInstrument):
13
+ class QProscan(QPollingMixin, QSerialInstrument):
13
14
  '''Prior Scientific Proscan II/III Microscope Stage Controller.
14
15
 
15
16
  Controls the XY stage and Z focus drive of a Prior Scientific
@@ -20,6 +21,10 @@ class QProscan(QSerialInstrument):
20
21
  positionChanged(list[int])
21
22
  Emitted by :meth:`position` with the current ``[x, y, z]``
22
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``.
23
28
 
24
29
  Properties
25
30
  ==========
@@ -210,6 +215,9 @@ class QProscan(QSerialInstrument):
210
215
  '''
211
216
 
212
217
  positionChanged = QtCore.Signal(object)
218
+ limitsChanged = QtCore.Signal(object)
219
+
220
+ POLL_INTERVAL: int = 200
213
221
 
214
222
  _VOLATILE: frozenset[str] = frozenset({'speed', 'zspeed'})
215
223
  '''Properties excluded from save/restore.
@@ -341,6 +349,26 @@ class QProscan(QSerialInstrument):
341
349
  '''Return the 3-character firmware version string.'''
342
350
  return self.handshake('VERSION')
343
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
+
344
372
  def position(self) -> list[int]:
345
373
  '''Return the current stage position and emit :attr:`positionChanged`.
346
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]}, '
@@ -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:
@@ -1,13 +1,11 @@
1
1
  import logging
2
- from qtpy import QtCore
3
- from QInstrument.lib.QPollingMixin import QPollingMixin
4
2
  from QInstrument.lib.QSerialInstrument import QSerialInstrument
5
3
 
6
4
 
7
5
  logger = logging.getLogger(__name__)
8
6
 
9
7
 
10
- class QSR830(QPollingMixin, QSerialInstrument):
8
+ class QSR830(QSerialInstrument):
11
9
  '''SRS SR830 Lock-in Amplifier
12
10
 
13
11
  Properties
@@ -86,16 +84,6 @@ class QSR830(QPollingMixin, QSerialInstrument):
86
84
  8: 100 ms 18: 10 ks
87
85
  9: 300 ms 19: 30 ks
88
86
 
89
- Output (read-only)
90
- ------------------
91
- x : float [V]
92
- In-phase (X) component of the lock-in signal.
93
- y : float [V]
94
- Quadrature (Y) component of the lock-in signal.
95
- r : float [V]
96
- Magnitude R of the lock-in signal.
97
- theta : float [degrees]
98
- Phase angle theta of the lock-in signal.
99
87
  '''
100
88
 
101
89
  comm = dict(baudRate=QSerialInstrument.BaudRate.Baud9600,
@@ -130,15 +118,6 @@ class QSR830(QPollingMixin, QSerialInstrument):
130
118
  self._register('sensitivity', 'SENS', int)
131
119
  self._register('synchronous_filter', 'SYNC', bool)
132
120
  self._register('time_constant', 'OFLT', int)
133
- # Output channels (read-only)
134
- self.registerProperty('x', setter=None, ptype=float,
135
- getter=lambda: self.getValue('OUTP?1', float))
136
- self.registerProperty('y', setter=None, ptype=float,
137
- getter=lambda: self.getValue('OUTP?2', float))
138
- self.registerProperty('r', setter=None, ptype=float,
139
- getter=lambda: self.getValue('OUTP?3', float))
140
- self.registerProperty('theta', setter=None, ptype=float,
141
- getter=lambda: self.getValue('OUTP?4', float))
142
121
 
143
122
  def _registerMethods(self) -> None:
144
123
  '''Register all instrument methods via ``registerMethod()``.
@@ -187,23 +166,6 @@ class QSR830(QPollingMixin, QSerialInstrument):
187
166
  '''
188
167
  return 'SR830' in self.handshake('*IDN?')
189
168
 
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
-
207
169
  def report(self) -> list[float]:
208
170
  '''Return the current frequency, magnitude, and phase.
209
171
 
@@ -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']
@@ -1,13 +1,11 @@
1
1
  import logging
2
- from qtpy import QtCore
3
- from QInstrument.lib.QPollingMixin import QPollingMixin
4
2
  from QInstrument.lib.QSerialInstrument import QSerialInstrument
5
3
 
6
4
 
7
5
  logger = logging.getLogger(__name__)
8
6
 
9
7
 
10
- class QSR844(QPollingMixin, QSerialInstrument):
8
+ class QSR844(QSerialInstrument):
11
9
  '''SRS SR844 RF Lock-in Amplifier
12
10
 
13
11
  Properties
@@ -69,20 +67,6 @@ class QSR844(QPollingMixin, QSerialInstrument):
69
67
  7: 300 ms 16: 10 ks
70
68
  8: 1 s 17: 30 ks
71
69
 
72
- Output (read-only)
73
- ------------------
74
- reference_frequency : int [Hz]
75
- Actual reference frequency being used.
76
- if_frequency : int [Hz]
77
- IF frequency (reference frequency mod 200 MHz).
78
- x : float [V]
79
- In-phase (X) component of the lock-in signal.
80
- y : float [V]
81
- Quadrature (Y) component of the lock-in signal.
82
- r : float [V]
83
- Magnitude R of the lock-in signal.
84
- theta : float [degrees]
85
- Phase angle theta of the lock-in signal.
86
70
  '''
87
71
 
88
72
  comm = dict(baudRate=QSerialInstrument.BaudRate.Baud19200,
@@ -113,20 +97,6 @@ class QSR844(QPollingMixin, QSerialInstrument):
113
97
  self._register('low_pass_slope', 'OFSL', int)
114
98
  self._register('sensitivity', 'SENS', int)
115
99
  self._register('time_constant', 'OFLT', int)
116
- # Read-only frequency displays
117
- self.registerProperty('reference_frequency', setter=None, ptype=int,
118
- getter=lambda: self.getValue('FRAQ?', int))
119
- self.registerProperty('if_frequency', setter=None, ptype=int,
120
- getter=lambda: self.getValue('FRIQ?', int))
121
- # Output channels (read-only)
122
- self.registerProperty('x', setter=None, ptype=float,
123
- getter=lambda: self.getValue('OUTP?1', float))
124
- self.registerProperty('y', setter=None, ptype=float,
125
- getter=lambda: self.getValue('OUTP?2', float))
126
- self.registerProperty('r', setter=None, ptype=float,
127
- getter=lambda: self.getValue('OUTP?3', float))
128
- self.registerProperty('theta', setter=None, ptype=float,
129
- getter=lambda: self.getValue('OUTP?4', float))
130
100
 
131
101
  def _registerMethods(self) -> None:
132
102
  '''Register all instrument methods via ``registerMethod()``.
@@ -175,23 +145,6 @@ class QSR844(QPollingMixin, QSerialInstrument):
175
145
  '''
176
146
  return 'SR844' in self.handshake('*IDN?')
177
147
 
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
-
195
148
  def report(self) -> list[float]:
196
149
  '''Return the current frequency, magnitude, and phase simultaneously.
197
150
 
@@ -268,23 +268,17 @@ class QInstrumentTree(ParameterTree):
268
268
 
269
269
  @QtCore.Slot()
270
270
  def _firstShow(self) -> None:
271
- '''Restore settings, start the device thread, and sync the tree.
272
-
273
- Runs after the event loop is idle on the first show. Settings
274
- are restored synchronously while the device is still on the main
275
- thread; the device is then moved to a worker thread before the
276
- async property sync is requested. If the device has a
277
- :meth:`startPolling` slot (i.e. inherits
278
- :class:`QPollingMixin`), it is invoked via a queued connection
279
- so it runs inside the worker thread's event loop.
271
+ '''Restore settings, sync the tree, then start the device thread.
272
+
273
+ Restores saved settings and syncs the tree while the device is
274
+ still on the main thread, then moves the device to a dedicated
275
+ worker thread. Polling is not started automatically; call
276
+ :meth:`startPolling` explicitly or connect a control to it when
277
+ continuous updates are needed.
280
278
  '''
281
279
  self._restoreSettings()
282
- self._startDeviceThread()
283
280
  self._syncProperties()
284
- if hasattr(self._device, 'startPolling'):
285
- QtCore.QMetaObject.invokeMethod(
286
- self._device, 'startPolling',
287
- QtCore.Qt.ConnectionType.QueuedConnection)
281
+ self._startDeviceThread()
288
282
 
289
283
  def _restoreSettings(self) -> None:
290
284
  '''Reconcile hardware state with the saved configuration file.
@@ -431,20 +431,15 @@ class QInstrumentWidget(QtWidgets.QWidget):
431
431
  def _firstShow(self) -> None:
432
432
  '''Run first-show reconciliation after the event loop is idle.
433
433
 
434
- Restores saved settings synchronously while the device is still
435
- on the main thread, then moves the device to a worker thread
436
- before requesting a full property sync. If the device has a
437
- :meth:`startPolling` slot (i.e. inherits
438
- :class:`QPollingMixin`), it is invoked via a queued connection
439
- so it runs inside the worker thread's event loop.
434
+ Restores saved settings and syncs the UI while the device is still
435
+ on the main thread, then moves the device to a dedicated worker
436
+ thread. Polling is not started automatically; call
437
+ :meth:`startPolling` explicitly or connect a control to it when
438
+ continuous updates are needed.
440
439
  '''
441
440
  self._restoreSettings()
442
- self._startDeviceThread()
443
441
  self._syncProperties()
444
- if hasattr(self._device, 'startPolling'):
445
- QtCore.QMetaObject.invokeMethod(
446
- self._device, 'startPolling',
447
- QtCore.Qt.ConnectionType.QueuedConnection)
442
+ self._startDeviceThread()
448
443
 
449
444
  def _startDeviceThread(self) -> None:
450
445
  '''Move the device into a dedicated worker thread.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "QInstrument"
7
- version = "3.0.0"
7
+ version = "3.0.2"
8
8
  description = "Qt-based framework for controlling scientific instruments over serial ports"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE.md" }
@@ -543,22 +543,8 @@ class TestPollingIntegration:
543
543
  qtbot.addWidget(w)
544
544
  return w, device
545
545
 
546
- def test_firstShow_invokes_startPolling_when_device_has_slot(
547
- self, qtbot):
546
+ def test_firstShow_does_not_auto_start_polling(self, qtbot):
548
547
  w, device = self._make_polling_widget(qtbot)
549
- with patch.object(w, '_restoreSettings'), \
550
- patch.object(w, '_syncProperties'), \
551
- patch('lib.QInstrumentWidget.QtCore.QMetaObject.invokeMethod'
552
- ) as mock_invoke:
553
- w._firstShow()
554
- mock_invoke.assert_called_once_with(
555
- device, 'startPolling',
556
- QtCore.Qt.ConnectionType.QueuedConnection)
557
-
558
- def test_firstShow_does_not_invoke_startPolling_when_absent(
559
- self, qtbot):
560
- device = TwoPropertyDevice()
561
- w = _make_widget(qtbot, device)
562
548
  with patch.object(w, '_restoreSettings'), \
563
549
  patch.object(w, '_syncProperties'), \
564
550
  patch('lib.QInstrumentWidget.QtCore.QMetaObject.invokeMethod'
@@ -1,4 +1,5 @@
1
1
  import pytest
2
+ from unittest.mock import patch, MagicMock
2
3
  from instruments.PriorScientific.Proscan.fake import QFakeProscan
3
4
  from instruments.PriorScientific.Proscan.instrument import QProscan
4
5
 
@@ -173,3 +174,61 @@ class TestFakeBehaviour:
173
174
 
174
175
  def test_stop_returns_true(self, proscan):
175
176
  assert proscan.stop() is True
177
+
178
+
179
+ # ---------------------------------------------------------------------------
180
+ # _poll() — position + limits batch
181
+ # ---------------------------------------------------------------------------
182
+
183
+ class TestProscanPoll:
184
+
185
+ @pytest.fixture
186
+ def proscan(self, qtbot):
187
+ return QFakeProscan()
188
+
189
+ def test_poll_emits_position_changed(self, proscan):
190
+ proscan._polling = True
191
+ received = []
192
+ proscan.positionChanged.connect(received.append)
193
+ with patch('qtpy.QtCore.QTimer.singleShot'):
194
+ proscan._poll()
195
+ assert received == [[0, 0, 0]]
196
+
197
+ def test_poll_emits_limits_changed(self, proscan):
198
+ proscan._polling = True
199
+ received = []
200
+ proscan.limitsChanged.connect(received.append)
201
+ with patch('qtpy.QtCore.QTimer.singleShot'):
202
+ proscan._poll()
203
+ assert received == [None]
204
+
205
+ def test_poll_does_not_run_when_stopped(self, proscan):
206
+ proscan._polling = False
207
+ received = []
208
+ proscan.positionChanged.connect(received.append)
209
+ with patch.object(proscan, 'position') as mock_pos:
210
+ proscan._poll()
211
+ mock_pos.assert_not_called()
212
+ assert received == []
213
+
214
+ def test_poll_schedules_next_call(self, proscan):
215
+ proscan._polling = True
216
+ with patch('qtpy.QtCore.QTimer.singleShot') as mock_shot:
217
+ proscan._poll()
218
+ mock_shot.assert_called_once_with(proscan.POLL_INTERVAL, proscan._poll)
219
+
220
+ def test_poll_skips_on_parse_error(self, proscan):
221
+ proscan._polling = True
222
+ received = []
223
+ proscan.limitsChanged.connect(received.append)
224
+ with patch.object(proscan, 'position', side_effect=ValueError('bad')), \
225
+ patch('qtpy.QtCore.QTimer.singleShot'):
226
+ proscan._poll()
227
+ assert received == []
228
+
229
+ def test_poll_reschedules_after_error(self, proscan):
230
+ proscan._polling = True
231
+ with patch.object(proscan, 'position', side_effect=ValueError('bad')), \
232
+ patch('qtpy.QtCore.QTimer.singleShot') as mock_shot:
233
+ proscan._poll()
234
+ mock_shot.assert_called_once_with(proscan.POLL_INTERVAL, proscan._poll)
@@ -19,10 +19,9 @@ class TestSR830(InstrumentContractTests):
19
19
  'dc_coupling', 'input_configuration', 'line_filter', 'shield_grounding',
20
20
  'dynamic_reserve', 'low_pass_slope', 'sensitivity',
21
21
  'synchronous_filter', 'time_constant',
22
- 'x', 'y', 'r', 'theta',
23
22
  }
24
23
 
25
- readonly_properties = {'x', 'y', 'r', 'theta'}
24
+ readonly_properties = set()
26
25
 
27
26
  roundtrip_cases = [
28
27
  ('frequency', 1000.0),
@@ -72,41 +71,3 @@ class TestSR830AutoOffset:
72
71
 
73
72
  def test_invalid_channel_four_ignored(self, sr830):
74
73
  QSR830.auto_offset(sr830, 4)
75
-
76
-
77
- # ---------------------------------------------------------------------------
78
- # _poll() — batched SNAP output
79
- # ---------------------------------------------------------------------------
80
-
81
- class TestSR830Poll:
82
-
83
- @pytest.fixture
84
- def sr830(self, qtbot):
85
- return QFakeSR830()
86
-
87
- def test_poll_emits_frequency_r_theta(self, sr830):
88
- sr830._polling = True
89
- received = {}
90
- sr830.propertyValue.connect(lambda n, v: received.update({n: v}))
91
- with patch.object(sr830, 'report', return_value=[1000.0, 0.5, 45.0]), \
92
- patch('qtpy.QtCore.QTimer.singleShot'):
93
- sr830._poll()
94
- assert received.get('frequency') == pytest.approx(1000.0)
95
- assert received.get('r') == pytest.approx(0.5)
96
- assert received.get('theta') == pytest.approx(45.0)
97
-
98
- def test_poll_does_not_emit_when_stopped(self, sr830):
99
- sr830._polling = False
100
- received = []
101
- sr830.propertyValue.connect(lambda n, v: received.append(n))
102
- with patch.object(sr830, 'report') as mock_report:
103
- sr830._poll()
104
- mock_report.assert_not_called()
105
- assert received == []
106
-
107
- def test_poll_schedules_next_call(self, sr830):
108
- sr830._polling = True
109
- with patch.object(sr830, 'report', return_value=[0., 0., 0.]), \
110
- patch('qtpy.QtCore.QTimer.singleShot') as mock_shot:
111
- sr830._poll()
112
- mock_shot.assert_called_once_with(sr830.POLL_INTERVAL, sr830._poll)
@@ -17,11 +17,9 @@ class TestSR844(InstrumentContractTests):
17
17
  'frequency', 'harmonic', 'internal_reference', 'phase',
18
18
  'reference_impedance', 'input_impedance', 'wide_reserve',
19
19
  'close_reserve', 'low_pass_slope', 'sensitivity', 'time_constant',
20
- 'reference_frequency', 'if_frequency',
21
- 'x', 'y', 'r', 'theta',
22
20
  }
23
21
 
24
- readonly_properties = {'reference_frequency', 'if_frequency', 'x', 'y', 'r', 'theta'}
22
+ readonly_properties = set()
25
23
 
26
24
  roundtrip_cases = [
27
25
  ('frequency', 50e6),
@@ -71,41 +69,3 @@ class TestSR844AutoOffset:
71
69
 
72
70
  def test_invalid_channel_four_ignored(self, sr844):
73
71
  QSR844.auto_offset(sr844, 4)
74
-
75
-
76
- # ---------------------------------------------------------------------------
77
- # _poll() — batched SNAP output
78
- # ---------------------------------------------------------------------------
79
-
80
- class TestSR844Poll:
81
-
82
- @pytest.fixture
83
- def sr844(self, qtbot):
84
- return QFakeSR844()
85
-
86
- def test_poll_emits_frequency_r_theta(self, sr844):
87
- sr844._polling = True
88
- received = {}
89
- sr844.propertyValue.connect(lambda n, v: received.update({n: v}))
90
- with patch.object(sr844, 'report', return_value=[50e6, 0.3, 30.0]), \
91
- patch('qtpy.QtCore.QTimer.singleShot'):
92
- sr844._poll()
93
- assert received.get('frequency') == pytest.approx(50e6)
94
- assert received.get('r') == pytest.approx(0.3)
95
- assert received.get('theta') == pytest.approx(30.0)
96
-
97
- def test_poll_does_not_emit_when_stopped(self, sr844):
98
- sr844._polling = False
99
- received = []
100
- sr844.propertyValue.connect(lambda n, v: received.append(n))
101
- with patch.object(sr844, 'report') as mock_report:
102
- sr844._poll()
103
- mock_report.assert_not_called()
104
- assert received == []
105
-
106
- def test_poll_schedules_next_call(self, sr844):
107
- sr844._polling = True
108
- with patch.object(sr844, 'report', return_value=[0., 0., 0.]), \
109
- patch('qtpy.QtCore.QTimer.singleShot') as mock_shot:
110
- sr844._poll()
111
- mock_shot.assert_called_once_with(sr844.POLL_INTERVAL, sr844._poll)
@@ -1,36 +0,0 @@
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 standard read/write properties are backed by an in-memory store
10
- via the MRO auto-mock pattern. The read-only output channels
11
- (x, y, r, theta, reference_frequency, if_frequency) are re-registered
12
- here to return ``0`` or ``0.0`` from the store rather than attempting
13
- wire communication.
14
- '''
15
-
16
- def _registerProperties(self) -> None:
17
- QSR844._registerProperties(self)
18
- for name in ('x', 'y', 'r', 'theta'):
19
- self.registerProperty(name, setter=None, ptype=float,
20
- getter=lambda n=name: self._store.get(n, 0.))
21
- for name in ('reference_frequency', 'if_frequency'):
22
- self.registerProperty(name, setter=None, ptype=int,
23
- getter=lambda n=name: self._store.get(n, 0))
24
- self.identification = 'Fake SR844 RF Lock-in Amplifier'
25
-
26
- def identify(self) -> bool:
27
- return True
28
-
29
- def report(self) -> list[float]:
30
- '''Return simulated [frequency, R, theta].'''
31
- data = np.random.rand(3)
32
- data[2] *= 360.
33
- return data.tolist()
34
-
35
-
36
- __all__ = ['QFakeSR844']
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes