Skip to content

Commit

Permalink
Merge pull request #6089 from jenshnielsen/refactor_agilent
Browse files Browse the repository at this point in the history
Refactor Agilent drivers
  • Loading branch information
jenshnielsen authored May 22, 2024
2 parents 8713dbc + 6959423 commit 6e27c03
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 56 deletions.
6 changes: 6 additions & 0 deletions docs/changes/newsfragments/6089.improved_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The Agilent drivers shipping with QCoDeS have been updated to ensure all Parameters are set as static
attributes that are documented and can be type checked. The docs for the Agilent drivers have been
updated to not document inherited members. This makes the documentation significantly more readable
as it focuses on specific members for a given instrument. The documentation now also links superclasses.
Please consult these for inherited members. It is the plan to make the same change to all drivers shipping
with QCoDeS in the near future.
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:
31 changes: 28 additions & 3 deletions src/qcodes/instrument_drivers/agilent/Agilent_34401A.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
from ._Agilent_344xxA import _Agilent344xxA
from typing import TYPE_CHECKING

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.validators import Strings

class Agilent34401A(_Agilent344xxA):
from ._Agilent_344xxA import Agilent344xxA

if TYPE_CHECKING:
from typing_extensions import Unpack

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.parameters import Parameter


class Agilent34401A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34401A DMM.
"""

pass
def __init__(
self,
name: str,
address: str,
**kwargs: "Unpack[VisaInstrumentKWArgs]",
) -> None:
super().__init__(name, address, **kwargs)

self.display_text: Parameter = self.add_parameter(
"display_text",
get_cmd="DISP:TEXT?",
set_cmd='DISP:TEXT "{}"',
vals=Strings(),
)
"""Parameter display_text"""
39 changes: 36 additions & 3 deletions src/qcodes/instrument_drivers/agilent/Agilent_34410A.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
from ._Agilent_344xxA import _Agilent344xxA
from typing import TYPE_CHECKING

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.validators import Strings

class Agilent34410A(_Agilent344xxA):
from ._Agilent_344xxA import Agilent344xxA

if TYPE_CHECKING:
from typing_extensions import Unpack

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.parameters import Parameter


class Agilent34410A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34410A DMM.
"""

pass
def __init__(
self,
name: str,
address: str,
**kwargs: "Unpack[VisaInstrumentKWArgs]",
) -> None:
super().__init__(name, address, **kwargs)

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.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"""
39 changes: 36 additions & 3 deletions src/qcodes/instrument_drivers/agilent/Agilent_34411A.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
from ._Agilent_344xxA import _Agilent344xxA
from typing import TYPE_CHECKING

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.validators import Strings

class Agilent34411A(_Agilent344xxA):
from ._Agilent_344xxA import Agilent344xxA

if TYPE_CHECKING:
from typing_extensions import Unpack

from qcodes.instrument import VisaInstrumentKWArgs
from qcodes.parameters import Parameter


class Agilent34411A(Agilent344xxA):
"""
This is the QCoDeS driver for the Agilent 34411A DMM.
"""

pass
def __init__(
self,
name: str,
address: str,
**kwargs: "Unpack[VisaInstrumentKWArgs]",
) -> None:
super().__init__(name, address, **kwargs)

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.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"""
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
Loading

0 comments on commit 6e27c03

Please sign in to comment.