Debian Codegraph @

tests/instruments/keithley/test_keithley2306_with_device.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 import time
25
26 import pytest
27 import math
28 from pymeasure.instruments.keithley.keithley2306 import Keithley2306
29
30 pytest.skip('Only work with connected hardware', allow_module_level=True)
31
32
33 class TestKeithley2306:
34 """
35 Unit tests for Keithley2306 class.
36
37 This test suite, needs the following setup to work properly:
38 - A Keithley2306 device should be connected to the computer;
39 - The device's address must be set in the RESOURCE constant;
40 """
41
42 ##################################################
43 # Keithley2306 device address goes here:
44 RESOURCE = "USB0::10893::6039::CN57266430::INSTR"
45 ##################################################
46
47 #########################
48 # PARAMETRIZATION CASES #
49 #########################
50
51 CHANNELS = [1, 2]
52 RELAYS = [1, 2, 3, 4]
53 BOOLEANS = [False, True]
54 BRIGHTNESSES = [0, 0.12, 0.25, 0.3, 0.5, 0.6, 0.75, 0.8, 1]
55 DISPLAY_TEXT_DATAS = ['', 'Hello', '0123456789012345678901234578901']
56 BANDWIDTHS = ['high', 'low']
57 IMPEDANCES = [0, 0.01, 0.1, 0.2, 0.25, 0.5, 0.77, 0.99, 1]
58 SENSE_MODES = ['voltage', 'current', 'dvm']
59 NPLCS = [0.01, 0.1, 1, 2, 4, 10]
60 AVERAGE_COUNTS = [1, 2, 5, 10]
61 CURRENT_RANGES = [0.005, 5]
62 PULSE_CURRENT_AVERAGE_COUNTS = [1, 2, 5, 100, 500, 1000, 5000]
63 PULSE_CURRENT_MODES = ['high', 'low', 'average']
64 PULSE_CURRENT_TIMES = [33.33333e-06, 1.2E-3, 0.8333]
65 PULSE_CURRENT_STEP_COUNTS = [0, 1, 5, 19]
66 PULSE_CURRENT_STEP_TIMES = [33.33333e-06, 1.2E-3, 100e-3]
67 PULSE_CURRENT_STEP_TIMEOUTS = [2e-3, 20.1e-3, 200e-3]
68 PULSE_CURRENT_STEP_TIMEOUT_INITIALS = [10e-3, 210.3e-3, 60]
69 PULSE_CURRENT_STEP_DELAYS = [0, 10e-3, 57.32e-3, 100e-3]
70 PULSE_CURRENT_STEP_RANGES = [100e-3, 1, 5]
71 PULSE_CURRENT_STEP_INDICES = [1, 2, 5, 20]
72 PULSE_CURRENT_STEP_TRIGGER_LEVELS = [0, 50e-3, 100e-3, 500e-3, 1, 2.5, 5]
73 PULSE_CURRENT_TRIGGER_DELAYS = [0, 0.05, 0.1, 1, 2, 5]
74 PULSE_CURRENT_TRIGGER_LEVELS = [0, 50e-3, 100e-3, 500e-3, 1, 2.5, 5]
75 PULSE_CURRENT_TRIGGER_LEVEL_RANGES = [100e-3, 1, 5]
76 PULSE_CURRENT_TIMEOUTS = [0.005, 1, 32]
77 LONG_INTEGRATION_TRIGGER_EDGES = ['rising', 'falling', 'neither']
78 LONG_INTEGRATION_TIMES = [0.850, 1, 30, 60]
79 LONG_INTEGRATION_TRIGGER_LEVELS = [0, 50e-3, 100e-3, 500e-3, 1, 2.5, 5]
80 LONG_INTEGRATION_TIMEOUTS = [1, 30, 63]
81 LONG_INTEGRATION_TRIGGER_LEVEL_RANGES = [100e-3, 1, 5]
82 SOURCE_VOLTAGES = [0, 3.3, 15]
83 SOURCE_VOLTAGE_PROTECTIONS = [0, 4, 8]
84 SOURCE_CURRENTS = [0.006, 1, 5]
85 SOURCE_CURRENT_LIMIT_TYPES = ['limit', 'trip']
86
87 INSTR = Keithley2306(RESOURCE)
88
89 ############
90 # FIXTURES #
91 ############
92
93 def reset_display(self):
94 self.INSTR.display_enabled = True
95 self.INSTR.display_text_enabled = False
96 self.INSTR.display_text_data = ''
97 self.INSTR.display_brightness = 1.0
98
99 def reset_relays(self):
100 for i in range(1, 5):
101 self.INSTR.relay(i).closed = False
102
103 @pytest.fixture
104 def instr(self):
105 self.INSTR.reset()
106 return self.INSTR
107
108 #########
109 # TESTS #
110 #########
111
112 @pytest.mark.parametrize("case", BOOLEANS)
113 def test_display_enabled(self, instr, case):
114 try:
115 assert instr.display_enabled
116 instr.display_enabled = case
117 assert instr.display_enabled == case
118 finally:
119 self.reset_display()
120
121 @pytest.mark.parametrize("case", BRIGHTNESSES)
122 def test_display_brightness(self, instr, case):
123 try:
124 assert instr.display_brightness == 1.0
125 instr.display_brightness = case
126 assert instr.display_brightness == math.ceil(4 * case) / 4
127 finally:
128 self.reset_display()
129
130 @pytest.mark.parametrize("case", CHANNELS)
131 def test_display_channel(self, instr, case):
132 assert instr.display_channel == 1
133 instr.display_channel = case
134 assert instr.display_channel == case
135
136 @pytest.mark.parametrize("display_text_data", DISPLAY_TEXT_DATAS)
137 @pytest.mark.parametrize("case", BOOLEANS)
138 def test_display_text(self, instr, display_text_data, case):
139 try:
140 assert instr.display_text_data == ''
141 assert not instr.display_text_enabled
142 instr.display_text_data = display_text_data
143 instr.display_text_enabled = case
144 assert instr.display_text_data == display_text_data
145 assert instr.display_text_enabled == case
146 finally:
147 self.reset_display()
148
149 @pytest.mark.parametrize("channel", CHANNELS)
150 @pytest.mark.parametrize("case", BOOLEANS)
151 def test_output_enabled(self, instr, channel, case):
152 assert not instr.ch(channel).enabled
153 instr.ch(channel).enabled = case
154 assert instr.ch(channel).enabled == case
155
156 @pytest.mark.parametrize("channel", CHANNELS)
157 @pytest.mark.parametrize("case", BANDWIDTHS)
158 def test_output_bandwidth(self, instr, channel, case):
159 instr = instr
160 assert instr.ch(channel).bandwidth == 'low' if channel == 1 else 'high'
161 instr.ch(channel).bandwidth = case
162 assert instr.ch(channel).bandwidth == case
163
164 @pytest.mark.parametrize("case", IMPEDANCES)
165 def test_output_impedance(self, instr, case):
166 assert instr.ch1.impedance == 0.0
167 instr.ch1.impedance = case
168 assert instr.ch1.impedance == case
169
170 @pytest.mark.parametrize("relay", RELAYS)
171 @pytest.mark.parametrize("case", BOOLEANS)
172 def test_relay_closed(self, instr, relay, case):
173 try:
174 assert not instr.relay(relay).closed
175 instr.relay(relay).closed = case
176 assert instr.relay(relay).closed == case
177 finally:
178 self.reset_relays()
179
180 @pytest.mark.parametrize("case", BOOLEANS)
181 def test_both_channels_enabled(self, instr, case):
182 assert not instr.ch1.enabled
183 assert not instr.ch2.enabled
184 instr.both_channels_enabled = case
185 assert instr.ch1.enabled == case
186 assert instr.ch2.enabled == case
187
188 @pytest.mark.parametrize("channel", CHANNELS)
189 @pytest.mark.parametrize("case", SENSE_MODES)
190 def test_sense_mode(self, instr, channel, case):
191 assert instr.ch(channel).sense_mode == 'voltage'
192 instr.ch(channel).sense_function = case
193 assert instr.ch(channel).sense_function == case
194
195 @pytest.mark.parametrize("channel", CHANNELS)
196 @pytest.mark.parametrize("case", NPLCS)
197 def test_nplc(self, instr, channel, case):
198 assert instr.ch(channel).nplc == 1
199 instr.ch(channel).nplc = case
200 time.sleep(0.5)
201 assert instr.ch(channel).nplc == case
202 instr.ch(channel).nplc == 1
203
204 @pytest.mark.parametrize("channel", CHANNELS)
205 @pytest.mark.parametrize("case", AVERAGE_COUNTS)
206 def test_average_count(self, instr, channel, case):
207 assert instr.ch(channel).average_count == 1
208 instr.ch(channel).average_count = case
209 assert instr.ch(channel).average_count == case
210
211 @pytest.mark.parametrize("channel", CHANNELS)
212 @pytest.mark.parametrize("case", CURRENT_RANGES)
213 def test_current_range(self, instr, channel, case):
214 assert instr.ch(channel).current_range == 5
215 instr.ch(channel).current_range = case
216 assert instr.ch(channel).current_range == case
217
218 @pytest.mark.parametrize("channel", CHANNELS)
219 @pytest.mark.parametrize("case", BOOLEANS)
220 def test_current_range_auto(self, instr, channel, case):
221 assert not instr.ch(channel).current_range_auto
222 instr.ch(channel).current_range_auto = case
223 assert instr.ch(channel).current_range_auto == case
224
225 @pytest.mark.parametrize("channel", CHANNELS)
226 @pytest.mark.parametrize("pulse_current_measure_enabled", BOOLEANS)
227 @pytest.mark.parametrize("case", PULSE_CURRENT_AVERAGE_COUNTS)
228 def test_pulse_current_average_count(self, instr, channel, pulse_current_measure_enabled, case):
229 instr.ch(channel).pulse_current_fast_enabled = True
230 assert instr.ch(channel).pulse_current_average_count == 1
231 instr.ch(channel).pulse_current_measure_enabled = pulse_current_measure_enabled
232 if not pulse_current_measure_enabled or case <= 100:
233 instr.ch(channel).pulse_current_average_count = case
234 assert instr.ch(channel).pulse_current_average_count == case
235
236 @pytest.mark.parametrize("channel", CHANNELS)
237 @pytest.mark.parametrize("case", BOOLEANS)
238 def test_pulse_current_measure_enabled(self, instr, channel, case):
239 instr.ch(channel).pulse_current_fast_enabled = True
240 assert instr.ch(channel).pulse_current_measure_enabled
241 instr.ch(channel).pulse_current_measure_enabled = case
242 assert instr.ch(channel).pulse_current_measure_enabled == case
243
244 @pytest.mark.parametrize("channel", CHANNELS)
245 @pytest.mark.parametrize("case", PULSE_CURRENT_MODES)
246 def test_pulse_current_mode(self, instr, channel, case):
247 instr.ch(channel).pulse_current_fast_enabled = True
248 assert instr.ch(channel).pulse_current_mode == 'high'
249 instr.ch(channel).pulse_current_mode = case
250 assert instr.ch(channel).pulse_current_mode == case
251
252 @pytest.mark.parametrize("channel", CHANNELS)
253 @pytest.mark.parametrize("case", PULSE_CURRENT_TIMES)
254 def test_pulse_current_time_high(self, instr, channel, case):
255 instr.ch(channel).pulse_current_fast_enabled = True
256 assert instr.ch(channel).pulse_current_time_high == 33.33333e-06
257 instr.ch(channel).pulse_current_time_high = case
258 assert instr.ch(channel).pulse_current_time_high == case
259
260 @pytest.mark.parametrize("channel", CHANNELS)
261 @pytest.mark.parametrize("case", PULSE_CURRENT_TIMES)
262 def test_pulse_current_time_low(self, instr, channel, case):
263 instr.ch(channel).pulse_current_fast_enabled = True
264 assert instr.ch(channel).pulse_current_time_low == 33.33333e-06
265 instr.ch(channel).pulse_current_time_low = case
266 assert instr.ch(channel).pulse_current_time_low == case
267
268 @pytest.mark.parametrize("channel", CHANNELS)
269 @pytest.mark.parametrize("case", PULSE_CURRENT_TIMES)
270 def test_pulse_current_time_average(self, instr, channel, case):
271 instr.ch(channel).pulse_current_fast_enabled = True
272 assert instr.ch(channel).pulse_current_time_average == 33.33333e-06
273 instr.ch(channel).pulse_current_time_average = case
274 assert instr.ch(channel).pulse_current_time_average == case
275
276 @pytest.mark.parametrize("channel", CHANNELS)
277 @pytest.mark.parametrize("case", PULSE_CURRENT_TIMES)
278 def test_pulse_current_time_digitize(self, instr, channel, case):
279 instr.ch(channel).pulse_current_fast_enabled = True
280 assert instr.ch(channel).pulse_current_time_digitize == 33.33333e-06
281 instr.ch(channel).pulse_current_time_digitize = case
282 assert instr.ch(channel).pulse_current_time_digitize == case
283
284 @pytest.mark.parametrize("case", BOOLEANS)
285 def test_pulse_current_step_enabled(self, instr, case):
286 instr.ch1.pulse_current_fast_enabled = True
287 assert not instr.ch1.pulse_current_step_enabled
288 instr.ch1.pulse_current_step_enabled = case
289 assert instr.ch1.pulse_current_step_enabled == case
290
291 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_COUNTS)
292 def test_pulse_current_step_up_count(self, instr, case):
293 instr.ch1.pulse_current_fast_enabled = True
294 assert instr.ch1.pulse_current_step_up_count == 1
295 instr.ch1.pulse_current_step_up_count = case
296 assert instr.ch1.pulse_current_step_up_count == case
297
298 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_COUNTS)
299 def test_pulse_current_step_down_count(self, instr, case):
300 instr.ch1.pulse_current_fast_enabled = True
301 assert instr.ch1.pulse_current_step_down_count == 1
302 instr.ch1.pulse_current_step_down_count = case
303 assert instr.ch1.pulse_current_step_down_count == case
304
305 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_TIMES)
306 def test_pulse_current_step_time(self, instr, case):
307 instr.ch1.pulse_current_fast_enabled = True
308 assert instr.ch1.pulse_current_step_time == 200e-6
309 instr.ch1.pulse_current_step_time = case
310 assert instr.ch1.pulse_current_step_time == case
311
312 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_TIMEOUTS)
313 def test_pulse_current_step_timeout(self, instr, case):
314 instr.ch1.pulse_current_fast_enabled = True
315 assert instr.ch1.pulse_current_step_timeout == 2e-3
316 instr.ch1.pulse_current_step_timeout = case
317 assert instr.ch1.pulse_current_step_timeout == case
318
319 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_TIMEOUT_INITIALS)
320 def test_pulse_current_step_timeout_initial(self, instr, case):
321 instr.ch1.pulse_current_fast_enabled = True
322 assert instr.ch1.pulse_current_step_timeout_initial == 2
323 instr.ch1.pulse_current_step_timeout_initial = case
324 assert instr.ch1.pulse_current_step_timeout_initial == case
325
326 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_DELAYS)
327 def test_pulse_current_step_delay(self, instr, case):
328 instr.ch1.pulse_current_fast_enabled = True
329 assert instr.ch1.pulse_current_step_delay == 0
330 instr.ch1.pulse_current_step_delay = case
331 assert instr.ch1.pulse_current_step_delay == case
332
333 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_RANGES)
334 def test_pulse_current_step_range(self, instr, case):
335 instr.ch1.pulse_current_fast_enabled = True
336 assert instr.ch1.pulse_current_step_range == 5
337 instr.ch1.pulse_current_step_range = case
338 assert instr.ch1.pulse_current_step_range == case
339
340 @pytest.mark.parametrize("range", PULSE_CURRENT_STEP_RANGES)
341 @pytest.mark.parametrize("step", PULSE_CURRENT_STEP_INDICES)
342 @pytest.mark.parametrize("case", PULSE_CURRENT_STEP_TRIGGER_LEVELS)
343 def test_pulse_current_step_trigger_level(self, instr, range, step, case):
344 instr.ch1.pulse_current_fast_enabled = True
345 assert instr.ch1.pulse_current_step(step).trigger_level == 0.0
346 if case <= range:
347 instr.ch1.pulse_current_step(step).trigger_level = case
348 assert instr.ch1.pulse_current_step(step).trigger_level == case
349
350 @pytest.mark.parametrize("channel", CHANNELS)
351 @pytest.mark.parametrize("pulse_current_measure_enabled", BOOLEANS)
352 @pytest.mark.parametrize("case", PULSE_CURRENT_TRIGGER_DELAYS)
353 def test_pulse_current_trigger_delay(self, instr, channel, pulse_current_measure_enabled, case):
354 instr.ch(channel).pulse_current_fast_enabled = True
355 assert instr.ch(channel).pulse_current_trigger_delay == 0
356 instr.ch(channel).pulse_current_measure_enabled = pulse_current_measure_enabled
357 if not pulse_current_measure_enabled or case <= 0.1:
358 instr.ch(channel).pulse_current_trigger_delay = case
359 assert instr.ch(channel).pulse_current_trigger_delay == case
360
361 @pytest.mark.parametrize("case", PULSE_CURRENT_TRIGGER_LEVEL_RANGES)
362 def test_pulse_current_trigger_level_range(self, instr, case):
363 instr.ch1.pulse_current_fast_enabled = True
364 assert instr.ch1.pulse_current_trigger_level_range == 5
365 instr.ch1.pulse_current_trigger_level_range = case
366 assert instr.ch1.pulse_current_trigger_level_range == case
367
368 @pytest.mark.parametrize("channel", CHANNELS)
369 @pytest.mark.parametrize("case", PULSE_CURRENT_TRIGGER_LEVELS)
370 def test_pulse_current_trigger_level(self, instr, channel, case):
371 instr.ch(channel).pulse_current_fast_enabled = True
372 assert instr.ch(channel).pulse_current_trigger_level == 0
373 instr.ch(channel).pulse_current_trigger_level = case
374 assert instr.ch(channel).pulse_current_trigger_level == case
375
376 @pytest.mark.parametrize("channel", CHANNELS)
377 @pytest.mark.parametrize("case", BOOLEANS)
378 def test_pulse_current_fast_enabled(self, instr, channel, case):
379 assert not instr.ch(channel).pulse_current_fast_enabled
380 instr.ch(channel).pulse_current_fast_enabled = case
381 assert instr.ch(channel).pulse_current_fast_enabled == case
382
383 @pytest.mark.parametrize("channel", CHANNELS)
384 @pytest.mark.parametrize("case", BOOLEANS)
385 def test_pulse_current_search_enabled(self, instr, channel, case):
386 instr.ch(channel).pulse_current_fast_enabled = True
387 assert instr.ch(channel).pulse_current_search_enabled
388 instr.ch(channel).pulse_current_search_enabled = case
389 assert instr.ch(channel).pulse_current_search_enabled == case
390
391 @pytest.mark.parametrize("channel", CHANNELS)
392 @pytest.mark.parametrize("case", BOOLEANS)
393 def test_pulse_current_detect_enabled(self, instr, channel, case):
394 instr.ch(channel).pulse_current_fast_enabled = True
395 assert not instr.ch(channel).pulse_current_detect_enabled
396 instr.ch(channel).pulse_current_detect_enabled = case
397 assert instr.ch(channel).pulse_current_detect_enabled == case
398
399 @pytest.mark.parametrize("channel", CHANNELS)
400 @pytest.mark.parametrize("case", PULSE_CURRENT_TIMEOUTS)
401 def test_pulse_current_timeouts(self, instr, channel, case):
402 instr.ch(channel).pulse_current_fast_enabled = True
403 assert instr.ch(channel).pulse_current_timeout == 1
404 instr.ch(channel).pulse_current_timeout = case
405 assert instr.ch(channel).pulse_current_timeout == case
406
407 @pytest.mark.parametrize("channel", CHANNELS)
408 @pytest.mark.parametrize("case", LONG_INTEGRATION_TRIGGER_EDGES)
409 def test_long_integration_trigger_edge(self, instr, channel, case):
410 instr.ch(channel).long_integration_fast_enabled = True
411 assert instr.ch(channel).long_integration_trigger_edge == 'rising'
412 instr.ch(channel).long_integration_trigger_edge = case
413 assert instr.ch(channel).long_integration_trigger_edge == case
414
415 @pytest.mark.parametrize("channel", CHANNELS)
416 @pytest.mark.parametrize("case", LONG_INTEGRATION_TIMES)
417 def test_long_integration_time(self, instr, channel, case):
418 instr.ch(channel).long_integration_fast_enabled = True
419 assert instr.ch(channel).long_integration_time == 1.0
420 instr.ch(channel).long_integration_time = case
421 assert instr.ch(channel).long_integration_time == case
422
423 @pytest.mark.parametrize("channel", CHANNELS)
424 @pytest.mark.parametrize("case", LONG_INTEGRATION_TRIGGER_LEVELS)
425 def test_long_integration_trigger_level(self, instr, channel, case):
426 instr.ch(channel).long_integration_fast_enabled = True
427 instr.ch(channel).long_integration_timeout = 1
428 assert instr.ch(channel).long_integration_trigger_level == 0
429 instr.ch(channel).long_integration_trigger_level = case
430 assert instr.ch(channel).long_integration_trigger_level == case
431
432 @pytest.mark.parametrize("channel", CHANNELS)
433 @pytest.mark.parametrize("case", LONG_INTEGRATION_TIMEOUTS)
434 def test_long_integration_timeout(self, instr, channel, case):
435 instr.ch(channel).long_integration_fast_enabled = True
436 assert instr.ch(channel).long_integration_timeout == 16
437 instr.ch(channel).long_integration_timeout = case
438 assert instr.ch(channel).long_integration_timeout == case
439
440 @pytest.mark.parametrize("channel", CHANNELS)
441 @pytest.mark.parametrize("case", BOOLEANS)
442 def test_long_integration_fast_enabled(self, instr, channel, case):
443 assert not instr.ch(channel).long_integration_fast_enabled
444 instr.ch(channel).long_integration_fast_enabled = case
445 assert instr.ch(channel).long_integration_fast_enabled == case
446
447 @pytest.mark.parametrize("channel", CHANNELS)
448 @pytest.mark.parametrize("case", BOOLEANS)
449 def test_long_integration_search_enabled(self, instr, channel, case):
450 instr.ch(channel).long_integration_fast_enabled = True
451 assert instr.ch(channel).long_integration_search_enabled
452 instr.ch(channel).long_integration_search_enabled = case
453 assert instr.ch(channel).long_integration_search_enabled == case
454
455 @pytest.mark.parametrize("channel", CHANNELS)
456 @pytest.mark.parametrize("case", BOOLEANS)
457 def test_long_integration_detect_enabled(self, instr, channel, case):
458 instr.ch(channel).long_integration_fast_enabled = True
459 assert not instr.ch(channel).long_integration_detect_enabled
460 instr.ch(channel).long_integration_detect_enabled = case
461 assert instr.ch(channel).long_integration_detect_enabled == case
462
463 @pytest.mark.parametrize("case", LONG_INTEGRATION_TRIGGER_LEVEL_RANGES)
464 def test_long_integration_trigger_level_range(self, instr, case):
465 instr.ch1.long_integration_fast_enabled = True
466 instr.ch1.long_integration_timeout = 1
467 assert instr.ch1.long_integration_trigger_level_range == 5
468 instr.ch1.long_integration_trigger_level_range = case
469 assert instr.ch1.long_integration_trigger_level_range == case
470
471 @pytest.mark.parametrize("channel", CHANNELS)
472 @pytest.mark.parametrize("case", SOURCE_VOLTAGES)
473 def test_source_voltage(self, instr, channel, case):
474 assert instr.ch(channel).source_voltage == 0
475 instr.ch(channel).source_voltage = case
476 assert instr.ch(channel).source_voltage == case
477
478 @pytest.mark.parametrize("channel", CHANNELS)
479 @pytest.mark.parametrize("case", SOURCE_VOLTAGE_PROTECTIONS)
480 def test_source_voltage_protection(self, instr, channel, case):
481 assert instr.ch(channel).source_voltage_protection == 8
482 instr.ch(channel).source_voltage_protection = case
483 assert instr.ch(channel).source_voltage_protection == case
484
485 @pytest.mark.parametrize("channel", CHANNELS)
486 def test_source_voltage_protection_enabled(self, instr, channel):
487 assert not instr.ch(channel).source_voltage_protection_enabled
488 assert isinstance(instr.ch(channel).source_voltage_protection_enabled, bool)
489
490 @pytest.mark.parametrize("channel", CHANNELS)
491 @pytest.mark.parametrize("case", BOOLEANS)
492 def test_source_voltage_protection_clamp_enabled(self, instr, channel, case):
493 assert not instr.ch(channel).source_voltage_protection_clamp_enabled
494 instr.ch(channel).source_voltage_protection_clamp_enabled = case
495 assert instr.ch(channel).source_voltage_protection_clamp_enabled == case
496
497 @pytest.mark.parametrize("channel", CHANNELS)
498 @pytest.mark.parametrize("case", SOURCE_CURRENTS)
499 def test_source_current_limit(self, instr, channel, case):
500 assert instr.ch(channel).source_current_limit == 0.25
501 instr.ch(channel).source_current_limit = case
502 assert instr.ch(channel).source_current_limit == case
503
504 @pytest.mark.parametrize("channel", CHANNELS)
505 @pytest.mark.parametrize("case", SOURCE_CURRENT_LIMIT_TYPES)
506 def test_source_current_limit_type(self, instr, channel, case):
507 assert instr.ch(channel).source_current_limit_type == 'limit'
508 instr.ch(channel).source_current_limit_type = case
509 assert instr.ch(channel).source_current_limit_type == case
510
511 @pytest.mark.parametrize("channel", CHANNELS)
512 def test_source_current_limit_enabled(self, instr, channel):
513 assert not instr.ch(channel).source_current_limit_enabled
514 assert isinstance(instr.ch(channel).source_current_limit_enabled, bool)
515
516 @pytest.mark.parametrize("sense_mode", SENSE_MODES)
517 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
518 @pytest.mark.parametrize("channel", CHANNELS)
519 def test_reading(self, instr, sense_mode, average_count, channel):
520 instr.ch(channel).sense_mode = sense_mode
521 instr.ch(channel).average_count = average_count
522 time.sleep(0.1)
523 assert type(instr.ch(channel).reading) == float
524
525 @pytest.mark.parametrize("sense_mode", SENSE_MODES)
526 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
527 @pytest.mark.parametrize("channel", CHANNELS)
528 def test_readings(self, instr, sense_mode, average_count, channel):
529 instr.ch(channel).sense_mode = sense_mode
530 instr.ch(channel).average_count = average_count
531 time.sleep(0.2)
532 readings = instr.ch(channel).readings
533 assert type(readings) == list
534 assert len(readings) == average_count
535 assert type(readings[0]) == float
536
537 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
538 @pytest.mark.parametrize("channel", CHANNELS)
539 def test_measured_voltage(self, instr, average_count, channel):
540 instr.ch(channel).average_count = average_count
541 time.sleep(0.1)
542 assert type(instr.ch(channel).measured_voltage) == float
543 assert instr.ch(channel).sense_mode == 'voltage'
544
545 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
546 @pytest.mark.parametrize("channel", CHANNELS)
547 def test_measured_voltages(self, instr, average_count, channel):
548 instr.ch(channel).average_count = average_count
549 time.sleep(0.2)
550 measured_voltages = instr.ch(channel).measured_voltages
551 assert type(measured_voltages) == list
552 assert len(measured_voltages) == average_count
553 assert type(measured_voltages[0]) == float
554 assert instr.ch(channel).sense_mode == 'voltage'
555
556 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
557 @pytest.mark.parametrize("channel", CHANNELS)
558 def test_measured_current(self, instr, average_count, channel):
559 instr.ch(channel).average_count = average_count
560 time.sleep(0.1)
561 assert type(instr.ch(channel).measured_current) == float
562 assert instr.ch(channel).sense_mode == 'current'
563
564 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
565 @pytest.mark.parametrize("channel", CHANNELS)
566 def test_measured_currents(self, instr, average_count, channel):
567 instr.ch(channel).average_count = average_count
568 time.sleep(0.2)
569 measured_currents = instr.ch(channel).measured_currents
570 assert type(measured_currents) == list
571 assert len(measured_currents) == average_count
572 assert type(measured_currents[0]) == float
573 assert instr.ch(channel).sense_mode == 'current'
574
575 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
576 @pytest.mark.parametrize("channel", CHANNELS)
577 def test_dvm_voltage(self, instr, average_count, channel):
578 instr.ch(channel).average_count = average_count
579 time.sleep(0.1)
580 assert type(instr.ch(channel).dvm_voltage) == float
581 assert instr.ch(channel).sense_mode == 'dvm'
582
583 @pytest.mark.parametrize("average_count", AVERAGE_COUNTS)
584 @pytest.mark.parametrize("channel", CHANNELS)
585 def test_dvm_voltages(self, instr, average_count, channel):
586 instr.ch(channel).average_count = average_count
587 time.sleep(0.2)
588 dvm_voltages = instr.ch(channel).dvm_voltages
589 assert type(dvm_voltages) == list
590 assert len(dvm_voltages) == average_count
591 assert type(dvm_voltages[0]) == float
592 assert instr.ch(channel).sense_mode == 'dvm'