Skip to content

Commit f8aa47e

Browse files
committed
Rigol asign modules to attributes
1 parent c6f7e9f commit f8aa47e

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

src/qcodes/instrument/channel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import sys
66
import warnings
77
from collections.abc import Callable, Iterable, Iterator, MutableSequence, Sequence
8-
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, overload
8+
from typing import TYPE_CHECKING, Any, Generic, cast, overload
9+
10+
from typing_extensions import TypeVar
911

1012
from qcodes.metadatable import MetadatableWithName
1113
from qcodes.parameters import (

src/qcodes/instrument_drivers/rigol/Rigol_DG1062.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from qcodes import validators as vals
66
from qcodes.instrument import (
7-
ChannelList,
87
InstrumentBaseKWArgs,
98
InstrumentChannel,
109
VisaInstrument,
1110
VisaInstrumentKWArgs,
1211
)
12+
from qcodes.instrument.channel import ChannelTuple
1313
from qcodes.utils import partial_with_docstring
1414

1515
if TYPE_CHECKING:
@@ -20,7 +20,7 @@
2020
log = logging.getLogger(__name__)
2121

2222

23-
class RigolDG1062Burst(InstrumentChannel):
23+
class RigolDG1062Burst(InstrumentChannel["RigolDG1062"]):
2424
"""
2525
Burst commands for the DG1062. We make a separate channel for these to
2626
group burst commands together.
@@ -262,7 +262,8 @@ def __init__(
262262
"""
263263

264264
burst = RigolDG1062Burst(self.parent, "burst", self.channel)
265-
self.add_submodule("burst", burst)
265+
self.burst: RigolDG1062Burst = self.add_submodule("burst", burst)
266+
""""Burst submodule"""
266267

267268
# We want to be able to do the following:
268269
# >>> help(gd.channels[0].sin)
@@ -413,13 +414,20 @@ def __init__(
413414
):
414415
super().__init__(name, address, **kwargs)
415416

416-
channels = ChannelList(self, "channel", RigolDG1062Channel, snapshotable=False)
417-
418-
for ch_num in [1, 2]:
419-
ch_name = f"ch{ch_num}"
420-
channel = RigolDG1062Channel(self, ch_name, ch_num)
421-
channels.append(channel)
422-
self.add_submodule(ch_name, channel)
423-
424-
self.add_submodule("channels", channels.to_channel_tuple())
417+
self.ch1 = self.add_submodule("ch1", RigolDG1062Channel(self, "ch1", 1))
418+
"""Channel 1 submodule"""
419+
self.ch2 = self.add_submodule("ch2", RigolDG1062Channel(self, "ch2", 2))
420+
"""Channel 2 submodule"""
421+
422+
self.channels: ChannelTuple[RigolDG1062Channel] = self.add_submodule(
423+
"channels",
424+
ChannelTuple(
425+
self,
426+
"channel",
427+
chan_type=RigolDG1062Channel,
428+
chan_list=(self.ch1, self.ch2),
429+
snapshotable=False,
430+
),
431+
)
432+
"""Tuple of channels"""
425433
self.connect_message()

0 commit comments

Comments
 (0)