|
1 | 1 | import logging |
2 | 2 | from functools import partial |
3 | | -from typing import TYPE_CHECKING, Any, ClassVar, cast |
| 3 | +from typing import TYPE_CHECKING, Any, ClassVar |
4 | 4 |
|
5 | 5 | from qcodes import validators as vals |
6 | 6 | from qcodes.instrument import ( |
7 | | - ChannelList, |
8 | 7 | InstrumentBaseKWArgs, |
9 | 8 | InstrumentChannel, |
10 | 9 | VisaInstrument, |
11 | 10 | VisaInstrumentKWArgs, |
12 | 11 | ) |
| 12 | +from qcodes.instrument.channel import ChannelTuple |
13 | 13 | from qcodes.utils import partial_with_docstring |
14 | 14 |
|
15 | 15 | if TYPE_CHECKING: |
|
20 | 20 | log = logging.getLogger(__name__) |
21 | 21 |
|
22 | 22 |
|
23 | | -class RigolDG1062Burst(InstrumentChannel): |
| 23 | +class RigolDG1062Burst(InstrumentChannel["RigolDG1062"]): |
24 | 24 | """ |
25 | 25 | Burst commands for the DG1062. We make a separate channel for these to |
26 | 26 | group burst commands together. |
@@ -129,7 +129,7 @@ def trigger(self) -> None: |
129 | 129 | self.parent.write_raw(f":SOUR{self.channel}:BURS:TRIG") |
130 | 130 |
|
131 | 131 |
|
132 | | -class RigolDG1062Channel(InstrumentChannel): |
| 132 | +class RigolDG1062Channel(InstrumentChannel["RigolDG1062"]): |
133 | 133 | min_impedance = 1 |
134 | 134 | max_impedance = 10000 |
135 | 135 |
|
@@ -261,10 +261,9 @@ def __init__( |
261 | 261 | For other waveforms it will give the user an error |
262 | 262 | """ |
263 | 263 |
|
264 | | - burst = RigolDG1062Burst( |
265 | | - cast("RigolDG1062", self.parent), "burst", self.channel |
266 | | - ) |
267 | | - self.add_submodule("burst", burst) |
| 264 | + burst = RigolDG1062Burst(self.parent, "burst", self.channel) |
| 265 | + self.burst: RigolDG1062Burst = self.add_submodule("burst", burst) |
| 266 | + """"Burst submodule""" |
268 | 267 |
|
269 | 268 | # We want to be able to do the following: |
270 | 269 | # >>> help(gd.channels[0].sin) |
@@ -371,7 +370,7 @@ def _set_waveform_params(self, **params_dict: float) -> None: |
371 | 370 | string += ",".join(values) |
372 | 371 | self.parent.write_raw(string) |
373 | 372 |
|
374 | | - def _get_duty_cycle(self) -> float: |
| 373 | + def _get_duty_cycle(self) -> str: |
375 | 374 | """ |
376 | 375 | Reads the duty cycle after checking waveform |
377 | 376 | """ |
@@ -415,13 +414,20 @@ def __init__( |
415 | 414 | ): |
416 | 415 | super().__init__(name, address, **kwargs) |
417 | 416 |
|
418 | | - channels = ChannelList(self, "channel", RigolDG1062Channel, snapshotable=False) |
419 | | - |
420 | | - for ch_num in [1, 2]: |
421 | | - ch_name = f"ch{ch_num}" |
422 | | - channel = RigolDG1062Channel(self, ch_name, ch_num) |
423 | | - channels.append(channel) |
424 | | - self.add_submodule(ch_name, channel) |
425 | | - |
426 | | - 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""" |
427 | 433 | self.connect_message() |
0 commit comments