Instrument architecture and drivers¶
The instrument subsystem is built around composition and discovery:
stoner_measurement.instruments.base_instrument.BaseInstrumentcomposes a transport and a protocol.stoner_measurement.instruments.driver_manager.InstrumentDriverManagerdiscovers concrete driver classes.
BaseInstrument composition model¶
Each instrument instance contains:
a transport object (byte-level I/O and connection lifecycle), and
a protocol object (command/query formatting, response parsing, and error checks).
This keeps instrument behaviour independent from physical connection details. A single driver can be reused with different transports (for example serial, Ethernet, GPIB, or null transport for tests) as long as the protocol matches the instrument command set.
Base instrument class providing the composition of transport and protocol.
BaseInstrument is the foundation of the instrument hierarchy. Every
concrete instrument class is a (possibly indirect) subclass of
BaseInstrument and gains the ability to communicate with a physical
instrument by holding references to a BaseTransport and a
BaseProtocol instance.
Base class for all instrument drivers. |
Transport layer classes for instrument communications.
Provides an abstract BaseTransport interface and concrete implementations
for serial (RS-232/RS-485), Ethernet (TCP/IP socket), UDP, and GPIB connections,
plus a NullTransport suitable for simulation and unit tests.
Abstract base for all instrument transport layers. |
|
TCP/IP socket transport for network-connected instruments. |
|
An FTDI D2XX operation failed. |
|
Access an FTDI device directly through the native D2XX library. |
|
GPIB transport using PyVISA. |
|
Passthrough Keithley 6221 GPIB transport. |
|
Loopback transport for simulation and unit testing. |
|
Serial transport with character-at-a-time return-echo handshaking. |
|
Serial-port transport using pyserial. |
|
UDP socket transport for network-connected instruments. |
Protocol layer classes for instrument communications.
Provides an abstract BaseProtocol interface and concrete
implementations for SCPI (ScpiProtocol), Oxford Instruments
carriage-return-terminated (OxfordProtocol), and Lakeshore
simple-ASCII (LakeshoreProtocol) protocols.
Abstract base for all instrument communication protocols. |
|
Return the payload from a complete IEEE 488.2 binary-block response. |
|
Lakeshore simple ASCII CRLF-terminated protocol. |
|
CR-terminated Leybold CENTER THREE RS232 protocol framing. |
|
PR4000B-S compact ASCII protocol with carriage-return framing. |
|
PSR-family ASCII protocol using CR for commands and CRLF replies. |
|
Minimal protocol descriptor for Modbus RTU binary frames. |
|
Oxford Instruments carriage-return-terminated ASCII protocol. |
|
SCPI protocol — newline-terminated ASCII messages. |
|
Format 7265 commands and remove its optional RS-232 prompt. |
Driver discovery process¶
InstrumentDriverManager uses two
discovery paths:
Built-in discovery scans modules in
stoner_measurement.instruments(excluding theprotocolandtransportsubpackages) and registers non-abstractBaseInstrumentsubclasses.Third-party discovery loads entry points in the
stoner_measurement.instrumentsgroup and registers non-abstractBaseInstrumentsubclasses.
Use drivers_by_type()
to filter the discovered registry by an instrument base type such as
TemperatureController, MagnetController, or SourceMeter.
Instrument driver discovery and filtering utilities.
Provides InstrumentDriverManager for discovering concrete instrument
driver classes from the local package and third-party entry-points.
Discover and provide access to concrete instrument driver classes. |
Instrument hierarchy and concrete classes¶
Hierarchy overview:
Concrete classes currently included in the package:
Source meter drivers:
Keithley2400,Keithley2410,Keithley2450Temperature controller drivers:
Lakeshore335,Lakeshore336,Lakeshore340,OxfordITC503,OxfordMercuryTemperatureControllerMagnet controller drivers:
Lakeshore625,OxfordIPS120X-ray diffractometer drivers:
LegacyXrayDiffractometer,SimulatedXrayDiffractometer
The legacy Oxford ITC503 and IPS120 drivers share acknowledgement and numeric
response handling through OxfordProtocol. Setting commands wait for and
validate their command-letter reply, even when auto_check_errors is disabled.
Q communications-mode commands and commands prefixed with $ do not wait
for a reply. A rejected or malformed acknowledgement raises InstrumentError;
a missing reply propagates the transport timeout. Actions are not automatically
retried, since the setting may already have been applied.
Instrument driver framework for stoner_measurement.
Provides a two-layer composition architecture for communicating with laboratory instruments:
Transport layer (physical byte-level I/O):
BaseTransport— abstract baseSerialTransport— RS-232/RS-485 via pyserialEthernetTransport— TCP/IP socketGpibTransport— GPIB/IEEE-488 via PyVISANullTransport— loopback for testing
Protocol layer (command formatting and response parsing):
BaseProtocol— abstract baseScpiProtocol— SCPI / IEEE 488.2OxfordProtocol— Oxford Instruments CR protocolLakeshoreProtocol— Lakeshore CRLF ASCII
Instrument hierarchy:
BaseInstrument— holds transport + protocolTemperatureController— abstract typeMagnetController— abstract typeSourceMeter— abstract typeCurrentSource— abstract typeLockInAmplifier— abstract typeMotorController— abstract typeDigitalMultimeter— abstract typeElectrometer— abstract typeNanovoltmeter— abstract typeNetworkAnalyser— abstract typeEurotherm2000Series— concrete temperature controllerEurotherm3200Series— concrete temperature controllerKeithley2000— concrete DMM driverKeithley2700— concrete DMM driverKeithley2182A— concrete nanovoltmeter driverKeithley182— concrete nanovoltmeter driverKeithley2400— concrete SMU driverKeithley2410— concrete SMU driverKeithley2450— concrete SMU driverKeithley6221— concrete current-source driverKeithley6485— concrete picoammeter driverKeithley6514— concrete electrometer driverKeithley6517— concrete electrometer driverLakeshoreM81CurrentSource— concrete current-source driverOxfordIPS120— concrete magnet supply driverOxfordMercuryIPS— concrete magnet supply driverSRS830— concrete lock-in amplifier driverLakeshoreM81LockIn— concrete lock-in amplifier driverThorlabsHDR50— concrete motor driverSimulatedTemperatureController— concrete simulated temperature controllerSimulatedMagnetController— concrete simulated magnet controllerSimulatedMotorController— concrete simulated motor controllerThorlabsKDC101KPRMTE— concrete motor driverAgilentE5062A— concrete ENA driverAgilentN5222A— concrete PNA driver
Agilent E5062A ENA driver using numbered channels and traces. |
|
Conservative N5222A PNA driver using named-measurement selection. |
|
Abstract base class for precision current-source instruments. |
|
Static capability descriptor for a current-source driver. |
|
Configuration for a current-source sweep. |
|
Point-spacing mode for a built-in current sweep. |
|
Output waveform mode of a current-source instrument. |
|
Pulse parameters for a pulsed current sweep. |
|
Abstract base class for digital multimeter instruments. |
|
Static capability descriptor for a DMM driver. |
|
Measurement functions for digital multimeters. |
|
Trigger-source selection for digital multimeters. |
|
Abstract base class for electrometer and picoammeter instruments. |
|
Static capability descriptor for an electrometer driver. |
|
Data transfer format used for query responses. |
|
Measurement function selected on an electrometer. |
|
Configuration for trigger and arm model settings. |
|
Trigger source for a simple trigger model. |
|
Raised when an instrument reports a command or execution error. |
|
Eurotherm 2000-series Modbus RTU temperature controller. |
|
Eurotherm 3200-series/32h8 Modbus RTU temperature controller. |
|
Driver for the Leybold CENTER THREE RS232 gauge controller. |
|
Analogue-I/O driver facade for the Leybold DISPLAY THREE. |
|
Abstract base class for lock-in amplifier instruments. |
|
Static capability descriptor for a lock-in amplifier driver. |
|
Expand factor for output offset operations. |
|
Input-coupling selection for lock-in amplifiers. |
|
Input shield grounding selection for lock-in amplifiers. |
|
Input source selection for lock-in amplifiers. |
|
Line-frequency notch filter configuration for lock-in amplifiers. |
|
Output channel selection for offset and expand operations. |
|
Reference-source selection for lock-in amplifiers. |
|
Dynamic-reserve operating modes. |
|
Magnet-supply driver for the Kepco BOP-GL 1 kW family. |
|
Abstract base class for superconducting magnet power supply drivers. |
|
Operating limits for a superconducting magnet power supply. |
|
Operational state of a superconducting magnet power supply. |
|
Consolidated status snapshot of a magnet power supply. |
|
Abstract base class for mass-flow controllers and readout/controllers. |
|
Static capability descriptor for mass-flow-controller drivers. |
|
Driver for the MKS PR4000B-S single-channel controller. |
|
Driver for the MKS PSR1A single-channel controller. |
|
Driver for the MKS PSR4A four-channel controller. |
|
Protocol describing the expected motor interface. |
|
Abstract base class for motor controller drivers. |
|
Consolidated status snapshot of a motor controller. |
|
Abstract base class for nanovoltmeter instruments. |
|
Static capability descriptor for a nanovoltmeter driver. |
|
Measurement functions for nanovoltmeters. |
|
Trigger-source selection for nanovoltmeters. |
|
SCPI binary-transfer byte orders. |
|
Numeric transfer encodings supported by network analysers. |
|
Abstract base class for vector network analysers. |
|
Runtime capability descriptor for a network analyser. |
|
Portable network-analyser trigger sources. |
|
A synchronized collection of network-analyser traces. |
|
One acquired network-analyser trace. |
|
Portable configuration for one network-analyser channel. |
|
Portable network-analyser sweep modes. |
|
Portable display formats for network-analyser traces. |
|
Static pressure-controller capability descriptor. |
|
Abstract base class for pressure-gauge controller instruments. |
|
One pressure-channel reading. |
|
Relay state reported by a pressure-gauge controller. |
|
Relay/setpoint threshold configuration. |
|
Normalised pressure-channel status. |
|
Pressure units reported by supported gauge controllers. |
|
Simple simulated superconducting magnet controller. |
|
Simple simulated mass-flow controller. |
|
Simple simulated motor controller. |
|
Simple simulated pressure-gauge controller. |
|
Simple simulated temperature controller. |
|
Measurement function selected on an SMU. |
|
Abstract base class for source-measure unit (SMU) instruments. |
|
Static capability descriptor for a source-meter driver. |
|
Source output mode of an SMU. |
|
Configuration for a source sweep. |
|
Point-spacing mode for a built-in source sweep. |
|
Configuration for simple trigger and arm models. |
|
Trigger or arm source for a trigger-model configuration. |
|
Alarm status for a sensor channel. |
|
Operating mode of a PID control loop. |
|
Static capability descriptor for a temperature controller driver. |
|
Configuration settings for a single sensor input channel. |
|
A snapshot of one PID control loop's complete state. |
|
PID gain parameters for one control loop. |
|
Whether a control loop's setpoint is currently being ramped. |
|
Validity and range status of a temperature sensor reading. |
|
Abstract base class for temperature controller instruments. |
|
A snapshot of a single sensor channel reading. |
|
A full controller status snapshot. |
|
One entry in a temperature controller's zone / table control table. |
|
Control an HDR50/BSC201 through direct Thorlabs APT.dll calls. |
|
Driver for a Thorlabs KDC101 controller with a KPRMTE servo stage. |
|
Control the two host-stepped axes and scalar counter over a byte stream. |
|
One atomic counter and two-axis position snapshot. |
|
Fast, reproducible simulation of motion, snapshots and scalar counts. |
|
Confirmed mechanics profile for both axes. |
|
Contract implemented by physical and simulated X-ray controllers. |
Keithley instrument drivers.
Contains concrete drivers for Keithley source-measure units
(Keithley2400,
Keithley2410,
Keithley2450),
precision current sources
(Keithley6221),
digital multimeters
(Keithley2000,
Keithley2700),
nanovoltmeters
(Keithley2182A,
Keithley182), and
electrometers/picoammeters
(Keithley6485,
Keithley6514,
Keithley6517).
Byte order used for Keithley IEEE-754 response data. |
|
Concrete driver for the non-SCPI Keithley Model 182 nanovoltmeter. |
|
Driver for the Keithley 2000 digital multimeter. |
|
Driver for the Keithley 2700 multimeter/data-acquisition system. |
|
Driver for the Keithley 2182A nanovoltmeter. |
|
Driver for the Keithley 2400 Series SourceMeter. |
|
Driver for the Keithley 2410 SourceMeter. |
|
Driver for the Keithley 2450 SourceMeter. |
|
Driver for the Keithley 6221 precision AC/DC current source. |
|
Driver for the Keithley 6514 electrometer. |
|
Driver for the Keithley 6517 electrometer. |
|
Driver for the Keithley 6485 picoammeter. |
Lakeshore instrument drivers.
Driver for the Lakeshore M81 balanced current-source outputs. |
|
Driver for the Lakeshore M81 SSM voltage-measurement module in LIA mode. |
|
Driver for a Lakeshore 625 superconducting magnet power supply. |
|
Concrete driver for the Lakeshore 335 temperature controller. |
|
Concrete driver for the Lakeshore 336 temperature controller. |
|
Model 340 native control commands for the standard A/B input hardware. |
Oxford Instruments drivers.
Driver for an Oxford Instruments IPS120 magnet power supply. |
|
Driver for an Oxford Instruments Mercury iPS magnet power supply. |
|
Oxford ITC503 control using the Issue 4 handbook's command set. |
|
Mercury iTC native protocol, based on the Issue 05 operator's manual. |
Abstract instrument contract for two-axis X-ray diffractometers.
Direction of increasing or decreasing angular coordinate. |
|
Installation-specific mechanics for one host-stepped axis. |
|
A completed count with its actual monotonic elapsed time. |
|
Motion was requested before the mechanics profile was confirmed. |
|
Base class for rejected or unsuccessful diffractometer motion. |
|
A cooperative move or count operation was cancelled. |
|
The measured position did not agree with the requested motion. |
|
A requested target or backlash excursion exceeded a soft limit. |
|
Return whether a callable or event cancellation token is set. |
Legacy X-ray diffractometer driver and binary protocol.
Raw and provisional status flags from snapshot bytes one and two. |
|
Framing metadata for the controller's fixed binary response. |
|
A snapshot contained a non-decimal packed-BCD nibble. |
|
A snapshot did not contain exactly twelve bytes. |
|
The complete set of opcodes recovered from the legacy application. |
|
Base class for malformed X-ray controller data. |
|
Decode packed decimal pairs whose least-significant digit comes first. |
|
Validate and decode one fixed twelve-byte response. |
|
Decode the controller's modulo-one-million signed representation. |