Debian Codegraph @

tests/instruments/keithley/test_keithley2200.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2022 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
25 from pymeasure.test import expected_protocol
26
27 from pymeasure.instruments.keithley.keithley2200 import Keithley2200
28
29
30 def test_init():
31 with expected_protocol(
32 Keithley2200,
33 [],
34 ):
35 pass # Verify the expected communication.
36
37
38 def test_voltage():
39 # instr.ch1.voltage should produce the following commands
40 with expected_protocol(
41 Keithley2200,
42 [
43 (b"INST:SEL CH1;VOLT 1.456", None),
44 (b"INST:SEL CH1;VOLT?", 1.456),
45 (b"INST:SEL CH1;MEAS:VOLT?", 1.456),
46 (b"INST:SEL CH3;VOLT 1.456", None),
47 ],
48 ) as instr:
49 instr.ch_1.voltage_setpoint = 1.456
50 assert instr.ch_1.voltage_setpoint == 1.456
51 assert instr.ch_1.voltage == 1.456
52 instr.ch_3.voltage_setpoint = 1.456
53
54
55 def test_current():
56 # instr.ch1.voltage should produce the following commands
57 with expected_protocol(
58 Keithley2200,
59 [(b"INST:SEL CH3;CURR 1.456", None), (b"INST:SEL CH1;CURR 2.654", None)],
60 ) as instr:
61 instr.ch_3.current_limit = 1.456
62 instr.ch_1.current_limit = 2.654
63
64
65 def test_output_enabled():
66 with expected_protocol(
67 Keithley2200,
68 [(b"INST:SEL CH1;SOURCE:OUTP:ENAB 1", None)],
69 ) as instr:
70 instr.ch_1.output_enabled = True