From 65fb12194c6b4600adeacad3e3475aca4373bcfa Mon Sep 17 00:00:00 2001 From: mltls Date: Tue, 23 Jan 2018 14:06:23 +0100 Subject: [PATCH 1/2] Add test for keysight 34465a (#944) * added test for keysight 34465a * add yaml file for keysight 34465a * removed trailing whitespace * removed keysight 34465a from .coveragerc * conform to pep-8 --- qcodes/.coveragerc | 1 - qcodes/instrument/sims/Keysight_34465A.yaml | 72 +++++++++++++++++++ .../Keysight/Keysight_34465A.py | 4 +- qcodes/tests/drivers/test_keysight_34465a.py | 43 +++++++++++ 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 qcodes/instrument/sims/Keysight_34465A.yaml create mode 100644 qcodes/tests/drivers/test_keysight_34465a.py diff --git a/qcodes/.coveragerc b/qcodes/.coveragerc index 818472ec932..b52327d8d64 100644 --- a/qcodes/.coveragerc +++ b/qcodes/.coveragerc @@ -35,7 +35,6 @@ omit = instrument_drivers/Keysight/Infiniium.py instrument_drivers/Keysight/Keysight_33500B.py instrument_drivers/Keysight/Keysight_33500B_channels.py - instrument_drivers/Keysight/Keysight_34465A.py instrument_drivers/Keysight/Keysight_E8267D.py instrument_drivers/Keysight/M3201A.py instrument_drivers/Keysight/M3300A.py diff --git a/qcodes/instrument/sims/Keysight_34465A.yaml b/qcodes/instrument/sims/Keysight_34465A.yaml new file mode 100644 index 00000000000..50943dbdb03 --- /dev/null +++ b/qcodes/instrument/sims/Keysight_34465A.yaml @@ -0,0 +1,72 @@ +# Simulated Keysight 34465A instrument +spec: "1.0" +devices: + device 1: + eom: + GPIB INSTR: + q: "\n" + r: "\n" + error: ERROR + dialogues: + - q: "*IDN?" + r: "Keysight, 34465A, 1000, 0.1" + properties: + voltage: + default: 10 + getter: + q: "READ?" + r: "{}" + dc_autorange: + default: 0 + getter: + q: "SENSe:VOLTage:DC:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:RANGe:AUTO {}" + r: "{}" + specs: + valid: [0, 1] + type: int + dc_range: + default: 1 + getter: + q: "SENSe:VOLTage:DC:RANGe?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:RANGe {}" + r: "{}" + specs: + valid: [0.1, 1, 10, 100, 1000] + type: float + NPLC: + default: 10.0 + getter: + q: "SENSe:VOLTage:DC:NPLC?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:NPLC {}" + r: "{}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, .2, 1, 10, 100] + type: float + resolution: + default: +3.00000000E-05 + getter: + q: "SENSe:VOLTage:DC:RESolution?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:RESolution {}" + r: "{}" + apterture_enabled: + default: 0 + getter: + q: "SENSe:VOLTage:DC:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:APERture:ENABled {}" + r: "{}" + + +resources: + GPIB::1::INSTR: + device: device 1 \ No newline at end of file diff --git a/qcodes/instrument_drivers/Keysight/Keysight_34465A.py b/qcodes/instrument_drivers/Keysight/Keysight_34465A.py index 7441db9d235..a4c0dc7fae1 100644 --- a/qcodes/instrument_drivers/Keysight/Keysight_34465A.py +++ b/qcodes/instrument_drivers/Keysight/Keysight_34465A.py @@ -231,8 +231,8 @@ def errorparser(rawmssg: str) -> (int, str): self.add_parameter('autorange', label='Autorange', - set_cmd='SENSe:VOLtage:DC:RANGe:AUTO {}', - get_cmd='SENSe:VOLtage:DC:RANGe:AUTO?', + set_cmd='SENSe:VOLTage:DC:RANGe:AUTO {}', + get_cmd='SENSe:VOLTage:DC:RANGe:AUTO?', val_mapping={'ON': 1, 'OFF': 0}, vals=vals.Enum('ON', 'OFF')) diff --git a/qcodes/tests/drivers/test_keysight_34465a.py b/qcodes/tests/drivers/test_keysight_34465a.py new file mode 100644 index 00000000000..b326d74bcde --- /dev/null +++ b/qcodes/tests/drivers/test_keysight_34465a.py @@ -0,0 +1,43 @@ +import pytest + +import qcodes.instrument.sims as sims +from qcodes.instrument_drivers.Keysight.Keysight_34465A import Keysight_34465A +visalib = sims.__file__.replace('__init__.py', 'Keysight_34465A.yaml@sim') + + +@pytest.fixture(scope='function') +def driver(): + keysight_sim = Keysight_34465A('keysight_34465A_sim', + address='GPIB::1::65535::INSTR', + visalib=visalib) + + yield keysight_sim + + keysight_sim.close() + + +def test_init(driver): + idn = driver.IDN() + assert idn['vendor'] == 'Keysight' + + +def test_NPLC(driver): + assert driver.NPLC.get() == 10.0 + driver.NPLC.set(0.2) + assert driver.NPLC.get() == 0.2 + + +def test_get_voltage(driver): + voltage = driver.volt.get() + assert voltage == 10.0 + + +def test_set_get_autorange(driver): + ar = driver.autorange.get() + assert ar == 'OFF' + driver.autorange.set('ON') + ar = driver.autorange.get() + assert ar == 'ON' + driver.autorange.set('OFF') + ar = driver.autorange.get() + assert ar == 'OFF' From 6e751117d46f8fa9fb4c1d94b434d4def4c11bcf Mon Sep 17 00:00:00 2001 From: Sebastian Pauka Date: Thu, 25 Jan 2018 20:46:57 +1100 Subject: [PATCH 2/2] Remove references to deprecated set_validator (#951) Replaces all set_validator calls in the SRS instruments with directs sets of self.vals --- qcodes/instrument_drivers/stanford_research/SR830.py | 8 ++++---- qcodes/instrument_drivers/stanford_research/SR86x.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qcodes/instrument_drivers/stanford_research/SR830.py b/qcodes/instrument_drivers/stanford_research/SR830.py index 0c89bb68fb3..a707d729162 100644 --- a/qcodes/instrument_drivers/stanford_research/SR830.py +++ b/qcodes/instrument_drivers/stanford_research/SR830.py @@ -550,20 +550,20 @@ def _get_input_config(self, s): mode = self._N_TO_INPUT_CONFIG[int(s)] if mode in ['a', 'a-b']: - self.sensitivity.set_validator(self._VOLT_ENUM) + self.sensitivity.vals = self._VOLT_ENUM self._set_units('V') else: - self.sensitivity.set_validator(self._CURR_ENUM) + self.sensitivity.vals = self._CURR_ENUM self._set_units('A') return mode def _set_input_config(self, s): if s in ['a', 'a-b']: - self.sensitivity.set_validator(self._VOLT_ENUM) + self.sensitivity.vals = self._VOLT_ENUM self._set_units('V') else: - self.sensitivity.set_validator(self._CURR_ENUM) + self.sensitivity.vals = self._CURR_ENUM self._set_units('A') return self._INPUT_CONFIG_TO_N[s] diff --git a/qcodes/instrument_drivers/stanford_research/SR86x.py b/qcodes/instrument_drivers/stanford_research/SR86x.py index 4e2ed9e22c6..624ad6df44e 100644 --- a/qcodes/instrument_drivers/stanford_research/SR86x.py +++ b/qcodes/instrument_drivers/stanford_research/SR86x.py @@ -539,20 +539,20 @@ def _get_input_config(self, s): mode = self._N_TO_INPUT_SIGNAL[int(s)] if mode == 'voltage': - self.sensitivity.set_validator(self._VOLT_ENUM) + self.sensitivity.vals = self._VOLT_ENUM self._set_units('V') else: - self.sensitivity.set_validator(self._CURR_ENUM) + self.sensitivity.vals = self._CURR_ENUM self._set_units('A') return mode def _set_input_config(self, s): if s == 'voltage': - self.sensitivity.set_validator(self._VOLT_ENUM) + self.sensitivity.vals = self._VOLT_ENUM self._set_units('V') else: - self.sensitivity.set_validator(self._CURR_ENUM) + self.sensitivity.vals = self._CURR_ENUM self._set_units('A') return self._INPUT_SIGNAL_TO_N[s]