Skip to content

Commit

Permalink
Example refactor docs Agilent
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed May 17, 2024
1 parent 1e56676 commit 8fa757a
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 30 deletions.
1 change: 1 addition & 0 deletions docs/drivers_api/Agilent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Agilent Drivers

.. automodule:: qcodes.instrument_drivers.agilent
:autosummary:
:no-inherited-members:
18 changes: 18 additions & 0 deletions src/qcodes/instrument/exp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# %%

from typing_extensions import reveal_type

from qcodes.instrument_drivers.mock_instruments import (
DummyAttrInstrument,
DummyInstrument,
)

# %%
a = DummyAttrInstrument("foo")


# %%
b = DummyInstrument(name="bar")

reveal_type(a.ch1)
reveal_type(b.dac3)
4 changes: 2 additions & 2 deletions src/qcodes/instrument_drivers/agilent/Agilent_34401A.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._Agilent_344xxA import _Agilent344xxA
from ._Agilent_344xxA import Agilent344xxA


class Agilent34401A(_Agilent344xxA):
class Agilent34401A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34401A DMM.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/qcodes/instrument_drivers/agilent/Agilent_34410A.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._Agilent_344xxA import _Agilent344xxA
from ._Agilent_344xxA import Agilent344xxA


class Agilent34410A(_Agilent344xxA):
class Agilent34410A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34410A DMM.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/qcodes/instrument_drivers/agilent/Agilent_34411A.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._Agilent_344xxA import _Agilent344xxA
from ._Agilent_344xxA import Agilent344xxA


class Agilent34411A(_Agilent344xxA):
class Agilent34411A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34411A DMM.
"""
Expand Down
14 changes: 9 additions & 5 deletions src/qcodes/instrument_drivers/agilent/Agilent_E8257D.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import qcodes.validators as vals
from qcodes.instrument import VisaInstrument, VisaInstrumentKWArgs
from qcodes.parameters import create_on_off_val_mapping
from qcodes.parameters import Parameter, create_on_off_val_mapping

if TYPE_CHECKING:
from typing_extensions import Unpack
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(
self._min_power = -20
self._max_power = 5

self.add_parameter(
self.frequency: Parameter = self.add_parameter(
name="frequency",
label="Frequency",
unit="Hz",
Expand All @@ -101,8 +101,9 @@ def __init__(
set_parser=float,
vals=vals.Numbers(self._min_freq, self._max_freq),
)
"""Parameter frequency"""

self.add_parameter(
self.phase: Parameter = self.add_parameter(
name="phase",
label="Phase",
unit="deg",
Expand All @@ -112,8 +113,9 @@ def __init__(
set_parser=self.deg_to_rad,
vals=vals.Numbers(-180, 180),
)
"""Parameter phase"""

self.add_parameter(
self.power: Parameter = self.add_parameter(
name="power",
label="Power",
unit="dBm",
Expand All @@ -123,13 +125,15 @@ def __init__(
set_parser=float,
vals=vals.Numbers(self._min_power, self._max_power),
)
"""Parameter power"""

self.add_parameter(
self.output_enabled: Parameter = self.add_parameter(
"output_enabled",
get_cmd=":OUTP?",
set_cmd="OUTP {}",
val_mapping=create_on_off_val_mapping(on_val="1", off_val="0"),
)
"""Parameter output_enabled"""

self.connect_message()

Expand Down
30 changes: 21 additions & 9 deletions src/qcodes/instrument_drivers/agilent/Agilent_E8267C.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
if TYPE_CHECKING:
from typing_extensions import Unpack

from qcodes.parameters import Parameter


class AgilentE8267C(VisaInstrument):
"""
This is the QCoDeS driver for the Agilent E8267C signal generator.
Expand All @@ -23,7 +26,7 @@ def __init__(
) -> None:
super().__init__(name, address, **kwargs)
# general commands
self.add_parameter(
self.frequency: Parameter = self.add_parameter(
name="frequency",
label="Frequency",
unit="Hz",
Expand All @@ -32,7 +35,8 @@ def __init__(
get_parser=float,
vals=Numbers(min_value=100e3, max_value=40e9),
)
self.add_parameter(
"""Parameter frequency"""
self.freq_offset: Parameter = self.add_parameter(
name="freq_offset",
label="Frequency offset",
unit="Hz",
Expand All @@ -41,22 +45,25 @@ def __init__(
get_parser=float,
vals=Numbers(min_value=-200e9, max_value=200e9),
)
self.add_parameter(
"""Parameter freq_offset"""
self.freq_mode: Parameter = self.add_parameter(
"freq_mode",
label="Frequency mode",
set_cmd="FREQ:MODE {}",
get_cmd="FREQ:MODE?",
vals=Enum("FIX", "CW", "SWE", "LIST"),
)
self.add_parameter(
"""Parameter freq_mode"""
self.pulse_width: Parameter = self.add_parameter(
"pulse_width",
label="Pulse width",
unit="ns",
set_cmd="PULM:INT:PWID {}",
get_cmd="PULM:INT:PWID?",
vals=Numbers(min_value=10e-9, max_value=20e-9),
)
self.add_parameter(
"""Parameter pulse_width"""
self.phase: Parameter = self.add_parameter(
name="phase",
label="Phase",
unit="deg",
Expand All @@ -66,7 +73,8 @@ def __init__(
set_parser=self.deg_to_rad,
vals=Numbers(min_value=-180, max_value=179),
)
self.add_parameter(
"""Parameter phase"""
self.power: Parameter = self.add_parameter(
name="power",
label="Power",
unit="dBm",
Expand All @@ -75,7 +83,8 @@ def __init__(
get_parser=float,
vals=Numbers(min_value=-135, max_value=25),
)
self.add_parameter(
"""Parameter power"""
self.power_offset: Parameter = self.add_parameter(
name="power_offset",
label="Power offset",
unit="dBm",
Expand All @@ -84,18 +93,21 @@ def __init__(
get_parser=float,
vals=Numbers(min_value=-200, max_value=200),
)
self.add_parameter(
"""Parameter power_offset"""
self.output_rf: Parameter = self.add_parameter(
name="output_rf",
get_cmd="OUTP?",
set_cmd="OUTP {}",
val_mapping={"OFF": 0, "ON": 1},
)
self.add_parameter(
"""Parameter output_rf"""
self.modulation_rf: Parameter = self.add_parameter(
name="modulation_rf",
get_cmd="OUTP:MOD?",
set_cmd="OUTP:MOD {}",
val_mapping={"OFF": 0, "ON": 1},
)
"""Parameter modulation_rf"""
# reset values after each reconnect
self.power(0)
self.power_offset(0)
Expand Down
31 changes: 21 additions & 10 deletions src/qcodes/instrument_drivers/agilent/_Agilent_344xxA.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing_extensions import Unpack


class _Agilent344xxA(VisaInstrument):
class Agilent344xxA(VisaInstrument):
"""
This is the QCoDeS driver for the Agilent_34400A DMM Series,
tested with Agilent_34401A, Agilent_34410A, and Agilent_34411A.
Expand Down Expand Up @@ -64,11 +64,12 @@ def __init__(
)
"""Resolution """

self.add_parameter(
self.volt: Parameter = self.add_parameter(
"volt", get_cmd="READ?", label="Voltage", get_parser=float, unit="V"
)
"""Parameter volt"""

self.add_parameter(
self.fetch: Parameter = self.add_parameter(
"fetch",
get_cmd="FETCH?",
label="Voltage",
Expand All @@ -83,8 +84,9 @@ def __init__(
"for data in the first place!"
),
)
"""Parameter fetch"""

self.add_parameter(
self.NPLC: Parameter = self.add_parameter(
"NPLC",
get_cmd="VOLT:NPLC?",
get_parser=float,
Expand All @@ -93,46 +95,55 @@ def __init__(
label="Integration time",
unit="NPLC",
)
"""Parameter NPLC"""

self.add_parameter("terminals", get_cmd="ROUT:TERM?")
self.terminals: Parameter = self.add_parameter(
"terminals", get_cmd="ROUT:TERM?"
)
"""Parameter terminals"""

self.add_parameter(
self.range_auto: Parameter = self.add_parameter(
"range_auto",
get_cmd="VOLT:RANG:AUTO?",
set_cmd="VOLT:RANG:AUTO {:d}",
val_mapping={"on": 1, "off": 0},
)
"""Parameter range_auto"""

self.add_parameter(
self.range: Parameter = self.add_parameter(
"range",
get_cmd="SENS:VOLT:DC:RANG?",
get_parser=float,
set_cmd="SENS:VOLT:DC:RANG {:f}",
vals=Enum(0.1, 1.0, 10.0, 100.0, 1000.0),
)
"""Parameter range"""

if self.model in ["34401A"]:
self.add_parameter(
self.display_text: Parameter = self.add_parameter(
"display_text",
get_cmd="DISP:TEXT?",
set_cmd='DISP:TEXT "{}"',
vals=Strings(),
)
"""Parameter display_text"""

elif self.model in ["34410A", "34411A"]:
self.add_parameter(
self.display_text: Parameter = self.add_parameter(
"display_text",
get_cmd="DISP:WIND1:TEXT?",
set_cmd='DISP:WIND1:TEXT "{}"',
vals=Strings(),
)
"""Parameter display_text"""

self.add_parameter(
self.display_text_2: Parameter = self.add_parameter(
"display_text_2",
get_cmd="DISP:WIND2:TEXT?",
set_cmd='DISP:WIND2:TEXT "{}"',
vals=Strings(),
)
"""Parameter display_text_2"""

self.connect_message()

Expand Down
2 changes: 2 additions & 0 deletions src/qcodes/instrument_drivers/agilent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from ._Agilent_344xxA import Agilent344xxA
from .Agilent_34401A import Agilent34401A
from .Agilent_34410A import Agilent34410A
from .Agilent_34411A import Agilent34411A
from .Agilent_E8257D import AgilentE8257D
from .Agilent_E8267C import AgilentE8267C

__all__ = [
"Agilent344xxA",
"Agilent34401A",
"Agilent34410A",
"Agilent34411A",
Expand Down

0 comments on commit 8fa757a

Please sign in to comment.