From a87004eeacb769d327dbbbf7ca9bddfed984d83d Mon Sep 17 00:00:00 2001 From: konosubakonoakua Date: Tue, 13 Aug 2024 16:35:52 +0800 Subject: [PATCH 1/5] fix rigol dg4000 value mappings --- src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py index 31ff4811e33..1ad6f0d95ae 100644 --- a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py +++ b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py @@ -238,14 +238,14 @@ def __init__( ch + "output_polarity", get_cmd=output + "POL?", set_cmd=output + "POL {}", - val_mapping={"normal": "NORM", "inverted": "INV"}, + val_mapping={"normal": "NORMAL\n", "inverted": "INVERTED\n"}, ) self.add_parameter( ch + "output_enabled", get_cmd=output + "STAT?", set_cmd=output + "STAT {}", - val_mapping=on_off_map, + val_mapping={True: "ON\n", False: "OFF\n"} , ) self.add_parameter( @@ -460,7 +460,7 @@ def __init__( self.add_parameter( ch + "harmonic_order", get_cmd=source + "HARM:ORDE?", - get_parser=int, + get_parser=float, set_cmd=source + "HARM:ORDE {}", vals=Ints(2, 16), ) @@ -618,7 +618,7 @@ def __init__( self.add_parameter( ch + "sweep_step", get_cmd=source + "SWE:STEP?", - get_parser=int, + get_parser=float, set_cmd=source + "SWE:STEP {}", vals=Ints(2, 2048), ) From ef802a7ff548d2d65595006f410950c353f1a45b Mon Sep 17 00:00:00 2001 From: konosubakonoakua Date: Wed, 14 Aug 2024 00:41:46 +0800 Subject: [PATCH 2/5] add custom get_parser for abnormal terminator `\n\n` --- src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py index 1ad6f0d95ae..ad2e8f1a8d8 100644 --- a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py +++ b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py @@ -35,6 +35,9 @@ def clean_string(s: str) -> str: return s +def parse_string_strip(s: str) -> str: + """Parse an output of the VISA instrument, remove redundant terminators like \n""" + return s.strip() def parse_string_output(s: str) -> float | str: """Parse an output of the VISA instrument into either text of a number""" @@ -238,14 +241,16 @@ def __init__( ch + "output_polarity", get_cmd=output + "POL?", set_cmd=output + "POL {}", - val_mapping={"normal": "NORMAL\n", "inverted": "INVERTED\n"}, + get_parser=parse_string_strip, + val_mapping={"normal": "NORMAL", "inverted": "INVERTED"}, ) self.add_parameter( ch + "output_enabled", get_cmd=output + "STAT?", set_cmd=output + "STAT {}", - val_mapping={True: "ON\n", False: "OFF\n"} , + get_parser=parse_string_strip, + val_mapping={True: "ON", False: "OFF"} , ) self.add_parameter( From 6e277a8c48081186221b6738ed88578c7870273d Mon Sep 17 00:00:00 2001 From: konosubakonoakua Date: Wed, 14 Aug 2024 00:44:34 +0800 Subject: [PATCH 3/5] minor fix --- src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py index ad2e8f1a8d8..014ab3f76ee 100644 --- a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py +++ b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py @@ -250,7 +250,7 @@ def __init__( get_cmd=output + "STAT?", set_cmd=output + "STAT {}", get_parser=parse_string_strip, - val_mapping={True: "ON", False: "OFF"} , + val_mapping=on_off_map, ) self.add_parameter( From cfc95df9fc752647a382c95e29c97f9235bfeaf7 Mon Sep 17 00:00:00 2001 From: konosubakonoakua Date: Fri, 20 Sep 2024 01:45:51 +0800 Subject: [PATCH 4/5] rename function and reset get_parser to int --- src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py index 014ab3f76ee..052c989686b 100644 --- a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py +++ b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py @@ -35,7 +35,7 @@ def clean_string(s: str) -> str: return s -def parse_string_strip(s: str) -> str: +def _parse_string_strip(s: str) -> str: """Parse an output of the VISA instrument, remove redundant terminators like \n""" return s.strip() @@ -241,7 +241,7 @@ def __init__( ch + "output_polarity", get_cmd=output + "POL?", set_cmd=output + "POL {}", - get_parser=parse_string_strip, + get_parser=_parse_string_strip, val_mapping={"normal": "NORMAL", "inverted": "INVERTED"}, ) @@ -249,7 +249,7 @@ def __init__( ch + "output_enabled", get_cmd=output + "STAT?", set_cmd=output + "STAT {}", - get_parser=parse_string_strip, + get_parser=_parse_string_strip, val_mapping=on_off_map, ) @@ -465,7 +465,7 @@ def __init__( self.add_parameter( ch + "harmonic_order", get_cmd=source + "HARM:ORDE?", - get_parser=float, + get_parser=int, set_cmd=source + "HARM:ORDE {}", vals=Ints(2, 16), ) @@ -623,7 +623,7 @@ def __init__( self.add_parameter( ch + "sweep_step", get_cmd=source + "SWE:STEP?", - get_parser=float, + get_parser=int, set_cmd=source + "SWE:STEP {}", vals=Ints(2, 2048), ) From bae333b67a92174e843b9e6f1f57058058d0602c Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 23 Sep 2024 17:20:14 +0200 Subject: [PATCH 5/5] Run precommit hooks --- src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py index 052c989686b..3bdf95cb551 100644 --- a/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py +++ b/src/qcodes/instrument_drivers/rigol/Rigol_DG4000.py @@ -35,10 +35,12 @@ def clean_string(s: str) -> str: return s + def _parse_string_strip(s: str) -> str: """Parse an output of the VISA instrument, remove redundant terminators like \n""" return s.strip() + def parse_string_output(s: str) -> float | str: """Parse an output of the VISA instrument into either text of a number""" s = clean_string(s)