Repository navigation
Add types to generic instrument parameteres #8658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jens Hedegaard Nielsen (jenshnielsen)
merged 45 commits into
microsoft:main
from
jenshnielsen:add_parameter_annotations
Oct 27, 2026
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
a80172f
Add value types to Keysight driver parameters
jenshnielsen 395bf8c
Add value types to Keithley, HP and Agilent driver parameters
jenshnielsen 7cbc624
Add value types to Tektronix and Rigol driver parameters
jenshnielsen 3efa1bf
Add value types to R&S and SRS driver parameters
jenshnielsen 4651708
Add value types to Alazar, AMI, Oxford and Yokogawa parameters
jenshnielsen 9686640
Add value types to remaining driver parameters
jenshnielsen 7cc6fbf
Parse Keithley 2450 count and line frequency as int
jenshnielsen a3446cd
Parse SR86x captured kilobytes as int
jenshnielsen 4d813ee
Fix Rigol DS4000 enable_auto_scale
jenshnielsen c966d32
Use seconds as unit of Keithley 7510 digitize aperture
jenshnielsen 509d84a
Fix RTO1000 trigger_mode querying the trigger source
jenshnielsen 686a823
Remove stray '?' from Keithley 6500 digits set command
jenshnielsen de106a9
Fix B1500 pch_query missing the '?'
jenshnielsen 057d905
Only allow Lakeshore 325 high output range on loop 1
jenshnielsen 8f877fe
Remove unused vals from Rigol DG1062 polarity
jenshnielsen 88f7df8
Parse Keithley 2450 nplc and source delay as float
jenshnielsen a8ec2f7
Parse Keithley 7510 delay, counts and sample rate as numbers
jenshnielsen dcbce9d
Fix Agilent E8267C pulse width type and unit
jenshnielsen bba0716
Parse Rigol DG1062 burst settings and duty cycle as numbers
jenshnielsen a13aff6
Parse Rigol DS1074Z trigger level as float
jenshnielsen bc2599a
Parse Tektronix TPS2012 trigger level as float
jenshnielsen 85c37c1
Make Keithley 2000 _get_mode_param generic
jenshnielsen 368299d
Use on/off mapping for Tektronix AWG5014 states
jenshnielsen 4b9b8ae
Parse R&S RTO1000 channel impedance as float
jenshnielsen 593cda7
Parse Keysight E4980A impedance range as float
jenshnielsen c3a2c8e
Type Keysight 34980A modules by slot
jenshnielsen ce0ab04
Pass bool to R&S SGS100A status
jenshnielsen 4989a68
Pass bool to Agilent E8257D output_enabled
jenshnielsen 1d96fdd
Pass bool to CopperMountain averages trigger
jenshnielsen 127787a
Pass bool to Tektronix DPO measurement state
jenshnielsen caafc08
Fix R&S ZNB non-integer bandwidth
jenshnielsen 822da3c
Drop redundant parameter_class in mock instruments
jenshnielsen dceebfe
Fix B1500 compliance and volt monitor validators
jenshnielsen 4494c3a
Add newsfragments for parameter value types
jenshnielsen 066e1a6
Fix Lakeshore 325 curve index and curve data
jenshnielsen 46c86b4
Allow clearing B1517A power compliance
jenshnielsen 09e3c2f
Skip existing slots when rescanning 34980A
jenshnielsen dcb1924
Parse Tektronix DPO record length as int
jenshnielsen 899fa47
Use Ints for Keysight PNA counts and trace number
jenshnielsen ab66340
Raise when no curve is selected on Lakeshore 325
jenshnielsen 897f66a
Test Tektronix DPO7200xx trace data scaling
jenshnielsen 83e6d3e
Add simulated tests for Agilent E8257D
jenshnielsen 881fd6b
Clear B1517A power compliance with current compliance
jenshnielsen 6246265
Accept whole-number floats for Keysight PNA counts
jenshnielsen 27271ec
Accept whole-number floats for Lakeshore 325 curve index
jenshnielsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| Several instrument driver parameters now return numbers or booleans instead of the raw string | ||
| from the instrument, or an integer for an on/off state. Code that compares the returned value to | ||
| a string, or to ``0``/``1`` by identity, needs updating: | ||
|
|
||
| - ``Keithley2450.line_frequency`` and ``Keithley2450Sense.count`` now return ``int``, and | ||
| ``Keithley2450Sense.nplc`` and ``Keithley2450Source.delay`` return ``float``. | ||
| - ``Keithley7510Sense.user_delay`` now returns ``float``, and | ||
| ``Keithley7510Sense.average_count``, ``Keithley7510DigitizeSense.acq_rate`` and | ||
| ``Keithley7510DigitizeSense.count`` return ``int``. | ||
| - ``SR86xBuffer.count_capture_kilobytes`` now returns ``int``. | ||
| - ``RigolDG1062Burst.ncycles`` now returns ``int``, and ``RigolDG1062Burst.phase``, | ||
| ``RigolDG1062Burst.time_delay`` and ``RigolDG1062Channel.duty_cycle`` return ``float``. | ||
| - ``RigolDS1074Z.trigger_level`` and ``TektronixTPS2012.trigger_level`` now return ``float``. | ||
| - ``TektronixDPOHorizontal.record_length`` now returns ``int`` instead of ``float``, as the | ||
| record length is a number of samples. | ||
| - ``AgilentE8267C.pulse_width`` now returns ``float`` and its unit is ``s`` instead of ``ns``, | ||
| matching the value sent to and returned by the instrument. | ||
| - ``RohdeSchwarzRTO1000ScopeChannel.impedance`` and ``KeysightE4980A.range`` now return | ||
| ``float``. | ||
| - ``RohdeSchwarzZNBChannel.bandwidth`` now returns ``float``, e.g. ``10000.0`` instead of | ||
| ``10000``. | ||
| - The channel ``state`` and ``direct_output`` and the instrument ``DC_output`` of | ||
| ``TektronixAWG5014`` now return ``bool``. They accept ``True``/``False``, ``1``/``0`` and | ||
| ``"on"``/``"off"``. ``TektronixAWG5014.sequence_pos`` now returns ``int``. | ||
| - ``KeysightB1520A.ac_dc_volt_monitor`` now returns ``bool`` and also accepts ``1``/``0`` | ||
| and ``"on"``/``"off"``. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| Most instrument driver parameters are now annotated with the type of their value, e.g. | ||
| ``Parameter[float, Self]``, so static type checkers can infer the type returned by ``get`` | ||
| and accepted by ``set``. As part of this, the mock instruments no longer pass the default | ||
| ``parameter_class=Parameter`` explicitly, and ``Keysight34980A.module`` is typed as a mapping | ||
| from slot number to switch matrix submodule. | ||
|
|
||
| Fixed the following driver bugs found along the way: | ||
|
|
||
| - ``RigolDS4000.enable_auto_scale`` always read back as ``True``, since ``bool("0")`` is | ||
| ``True``, and was set with ``True``/``False`` instead of ``1``/``0``. | ||
| - ``RohdeSchwarzRTO1000.trigger_mode`` queried the trigger source instead of the trigger mode. | ||
| - ``Keithley6500.digits`` sent a set command with a stray ``?``. | ||
| - ``MessageBuilder.pch_query`` of the Keysight B1500 sent ``PCH`` instead of ``PCH?``. | ||
| - ``LakeshoreModel325Heater.output_range`` accepted the high (25 W) range on loop 2, which is | ||
| only supported on loop 1. | ||
| - ``LakeshoreModel325Sensor.curve_index`` now accepts ``0`` (no curve), which the instrument | ||
| also reports when the selected curve does not match the input, and rejects non-integer values. | ||
| Whole-number floats such as ``23.0`` are still accepted and sent as integers. | ||
| - The ``LakeshoreModel325`` curve list now includes user curve 35, so ``upload_curve(35, ...)`` | ||
| no longer raises an ``IndexError``. | ||
| - ``LakeshoreModel325Curve.get_data`` now reads all 200 points of a curve instead of 199. | ||
| - ``LakeshoreModel325Curve.set_data`` now writes curve points with 6 significant digits, the | ||
| resolution of the instrument, instead of rounding them to 3 decimals. | ||
| - ``LakeshoreModel325Sensor.curve`` now raises a ``RuntimeError`` when no curve is selected for | ||
| the sensor, instead of returning a curve 0, which the instrument does not have. | ||
| - ``RohdeSchwarzZNBChannel.bandwidth`` failed to read a non-integer bandwidth such as 1.5 Hz, | ||
| which the instrument supports. | ||
| - The ``current_compliance`` and ``power_compliance`` of the ``KeysightB1517A`` sweep could not | ||
| be set back to ``None``, which leaves the compliance out of the ``WV`` command. Since a power | ||
| compliance can only be sent together with a current compliance, clearing the current | ||
| compliance also clears the power compliance. | ||
| - ``Keysight34980A.scan_slots`` can now be called again; it skips slots that already have a | ||
| module instead of failing to register a duplicate submodule. | ||
| - ``Keithley7510DigitizeSense.aperture`` was labelled in ``us`` although the instrument uses | ||
| seconds; its unit is now ``s``. | ||
| - ``averages``, ``points`` and ``active_trace`` of the Keysight PNA (``KeysightPNABase``) drivers | ||
| now reject non-integer values. Previously ``averages`` failed to format a float such as | ||
| ``2.5`` and the others sent it to the instrument. Whole-number floats such as ``2.0`` are | ||
| still accepted and sent as integers. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # SIMULATED INSTRUMENT FOR Agilent E8257D | ||
| # Only covers what is needed to create the driver and switch the RF output. | ||
| # The installed options are frequency option 520 (20 GHz) and the step | ||
| # attenuator (1E1). | ||
| spec: "1.0" | ||
| devices: | ||
| device 1: | ||
| eom: | ||
| GPIB INSTR: | ||
| q: "\n" | ||
| r: "\n" | ||
| error: ERROR | ||
| dialogues: | ||
| - q: "*IDN?" | ||
| r: "Agilent Technologies, E8257D, US00000000, C.06.28" | ||
| - q: "DIAG:CPU:INFO:OPT:DET?" | ||
| r: "1E1,520,UNT" | ||
|
|
||
| properties: | ||
| output_enabled: | ||
| default: "0" | ||
| getter: | ||
| q: ":OUTP?" | ||
| r: "{}" | ||
| setter: | ||
| q: "OUTP {}" | ||
|
|
||
| resources: | ||
| GPIB::1::INSTR: | ||
| device: device 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| spec: "1.0" | ||
| devices: | ||
| device 1: | ||
| eom: | ||
| GPIB INSTR: | ||
| q: "\n" | ||
| r: "\n" | ||
| error: ERROR | ||
| dialogues: | ||
| - q: "*IDN?" | ||
| r: "Agilent Technologies, E8267C, US00000000, C.04.84" | ||
|
|
||
| properties: | ||
| power: | ||
| default: 0 | ||
| getter: | ||
| q: "POW?" | ||
| r: "{}" | ||
| setter: | ||
| q: "POW {}" | ||
|
|
||
| power_offset: | ||
| default: 0 | ||
| getter: | ||
| q: "POW:OFFS?" | ||
| r: "{}" | ||
| setter: | ||
| q: "POW:OFFS {}" | ||
|
|
||
| pulse_width: | ||
| # *RST value according to the E8257D/67D SCPI command reference | ||
| default: "+1.00000000E-006" | ||
| getter: | ||
| q: "PULM:INT:PWID?" | ||
| r: "{}" | ||
| setter: | ||
| q: "PULM:INT:PWID {}" | ||
|
|
||
| resources: | ||
| GPIB::1::INSTR: | ||
| device: device 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| spec: "1.0" | ||
| devices: | ||
| device 1: | ||
| eom: | ||
| GPIB INSTR: | ||
| q: "\n" | ||
| r: "\n" | ||
| error: ERROR | ||
| dialogues: | ||
| - q: "*IDN?" | ||
| r: "KEITHLEY INSTRUMENTS,MODEL DMM6500,04000000,1.0.0" | ||
| - q: "*LANG?" | ||
| r: "SCPI" | ||
|
|
||
| properties: | ||
| data_format: | ||
| default: ASCII | ||
| getter: | ||
| q: "FORM:DATA?" | ||
| r: "{}" | ||
| setter: | ||
| q: "FORM:DATA {}" | ||
|
|
||
| display_digits: | ||
| default: 6 | ||
| getter: | ||
| q: "DISP:VOLT:DC:DIG?" | ||
| r: "{}" | ||
| setter: | ||
| q: "DISP:VOLT:DC:DIG {}" | ||
| specs: | ||
| type: int | ||
| min: 4 | ||
| max: 7 | ||
|
|
||
| resources: | ||
| GPIB::1::INSTR: | ||
| device: device 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # SIMULATED INSTRUMENT FOR Keysight PNA N5222B | ||
| # Only covers what is needed to create the driver and a few parameters. | ||
| # The instrument has a single measurement "CH1_S11_1" (trace number 1). | ||
| # Commands that are only written are modelled as properties with a setter | ||
| # without a response, so that they do not leave a reply in the read buffer. | ||
| spec: "1.0" | ||
| devices: | ||
| N5222B: | ||
| eom: | ||
| GPIB INSTR: | ||
| q: "\n" | ||
| r: "\n" | ||
| error: ERROR | ||
| dialogues: | ||
| - q: "*IDN?" | ||
| r: "Keysight Technologies,N5222B,MY12345678,A.13.95.09" | ||
| - q: "*OPT?" | ||
| r: '""' | ||
| - q: "CALC:PAR:CAT:EXT?" | ||
| r: '"CH1_S11_1,S11"' | ||
|
|
||
| properties: | ||
|
|
||
| data_format: | ||
| default: "REAL,32" | ||
| setter: | ||
| q: "FORM {}" | ||
|
|
||
| byte_order: | ||
| default: "NORM" | ||
| setter: | ||
| q: "FORM:BORD {}" | ||
|
|
||
| selected_measurement_name: | ||
| default: "'CH1_S11_1'" | ||
| setter: | ||
| q: "CALC:PAR:SEL {}" | ||
|
|
||
| active_trace: | ||
| default: 1 | ||
| getter: | ||
| q: "CALC:PAR:MNUM?" | ||
| r: "{}" | ||
| setter: | ||
| q: "CALC:PAR:MNUM {}" | ||
|
|
||
| averages: | ||
| default: 1 | ||
| getter: | ||
| q: "SENS:AVER:COUN?" | ||
| r: "{}" | ||
| setter: | ||
| q: "SENS:AVER:COUN {}" | ||
|
|
||
| points: | ||
| default: 201 | ||
| getter: | ||
| q: "SENS:SWE:POIN?" | ||
| r: "{}" | ||
| setter: | ||
| q: "SENS:SWE:POIN {}" | ||
|
|
||
| resources: | ||
| GPIB::1::INSTR: | ||
| device: N5222B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.