2
2
import numpy as np
3
3
from contextlib import ExitStack
4
4
from functools import partial
5
- from typing import Sequence
5
+ from typing import Sequence , Tuple
6
+ from distutils .version import LooseVersion
6
7
7
8
import qcodes .utils .validators as vals
8
9
from qcodes import VisaInstrument , InstrumentChannel
@@ -119,7 +120,7 @@ def __init__(self, parent: '_Keysight_344xxA', name: str, **kwargs):
119
120
it buffers one trigger.""" )
120
121
_trigger_source_vals = vals .Enum ('IMM' , 'EXT' , 'BUS' )
121
122
122
- if self .parent .is_34465A_34470A and self . parent . has_DIG :
123
+ if self .parent .has_DIG :
123
124
_trigger_source_vals = vals .Enum ('IMM' , 'EXT' , 'BUS' , 'INT' )
124
125
# extra empty lines are needed for readability of the docstring
125
126
_trigger_source_docstring += textwrap .dedent ("""\
@@ -149,11 +150,11 @@ def __init__(self, parent: '_Keysight_344xxA', name: str, **kwargs):
149
150
super (Sample , self ).__init__ (parent , name , ** kwargs )
150
151
151
152
if self .parent .is_34465A_34470A :
152
- _max_sample_count = 1e9
153
+ _max_sample_count = int ( 1e9 )
153
154
elif self .parent .model == "34410A" :
154
155
_max_sample_count = 50_000
155
156
else :
156
- _max_sample_count = 1e6
157
+ _max_sample_count = int ( 1e6 )
157
158
158
159
self .add_parameter ('count' ,
159
160
label = 'Sample Count' ,
@@ -172,18 +173,29 @@ def __init__(self, parent: '_Keysight_344xxA', name: str, **kwargs):
172
173
option) or 2,000,000 readings (with the MEM option)""" ))
173
174
174
175
if self .parent .has_DIG :
176
+ if self .parent .has_MEM :
177
+ _max_pretrig_count = int (2e6 ) - 1
178
+ else :
179
+ _max_pretrig_count = int (5e4 ) - 1
180
+
175
181
self .add_parameter ('pretrigger_count' ,
176
182
label = 'Sample Pretrigger Count' ,
177
183
set_cmd = 'SAMPle:COUNt:PRETrigger {}' ,
178
184
get_cmd = 'SAMPle:COUNt:PRETrigger?' ,
179
185
vals = vals .MultiType (
180
- vals .Numbers (0 , 2e6 - 1 ),
186
+ vals .Numbers (0 , _max_pretrig_count ),
181
187
vals .Enum ('MIN' , 'MAX' , 'DEF' )),
182
188
get_parser = int ,
183
189
docstring = textwrap .dedent ("""\
184
190
Allows collection of the data being digitized the trigger.
185
191
Reserves memory for pretrigger samples up to the specified
186
- num. of pretrigger samples.""" ))
192
+ num. of pretrigger samples.
193
+
194
+ Note that the maximum number of pretrigger counts is bounded
195
+ by the current number of sample counts as specified via the
196
+ ``sample.count`` parameter. Refer to the doc of the
197
+ ``sample.count`` parameter for information on the maximum
198
+ number of sample counts.""" ))
187
199
188
200
if self .parent .is_34465A_34470A :
189
201
self .add_parameter ('source' ,
@@ -438,7 +450,15 @@ def __init__(self, name: str, address: str, silent: bool = False,
438
450
####################################
439
451
# Instrument specifications
440
452
441
- self .has_DIG = 'DIG' in self ._licenses ()
453
+ options = self ._options ()
454
+ self .has_DIG = self .is_34465A_34470A and (
455
+ 'DIG' in options
456
+ or LooseVersion ('A.03' ) <= LooseVersion (idn ['firmware' ])
457
+ )
458
+ # Note that the firmware version check is still needed becuase ``_options``
459
+ # (the ``*OPT?`` command) returns 'DIG' option for firmware 3.0 only
460
+ # if it has been purchased before
461
+ self .has_MEM = self .is_34465A_34470A and 'MEM' in options
442
462
443
463
PLCs = {'34410A' : [0.006 , 0.02 , 0.06 , 0.2 , 1 , 2 , 10 , 100 ],
444
464
'34460A' : [0.02 , 0.2 , 1 , 10 , 100 ],
@@ -756,6 +776,21 @@ def _licenses(self) -> Sequence[str]:
756
776
return licenses_list
757
777
return tuple ()
758
778
779
+ def _options (self ) -> Tuple [str , ...]:
780
+ """
781
+ Return enabled options of the DMM returned by ``*OPT?`` command.
782
+ The 34410A model does not have options, hence always returns an empty tuple.
783
+
784
+ Note that for firmware version 3.0, output of ```*OPT?`` will contain
785
+ the ``DIG`` option only if it has been purchased before, although the option
786
+ itself is enabled by default in the firmware version 3.0.
787
+ """
788
+ if self .model != '34410A' :
789
+ options_raw = self .ask ('*OPT?' )
790
+ options_list = [opt for opt in options_raw .split (',' ) if opt != '0' ]
791
+ return tuple (options_list )
792
+ return tuple ()
793
+
759
794
def _get_parameter (self , sense_function : str = "DC Voltage" ) -> float :
760
795
"""
761
796
Measure the parameter given by sense_function
0 commit comments