Debian Codegraph @

tests/instruments/siglenttechnologies/test_siglent_spd1305x.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 from pymeasure.test import expected_protocol
25 from pymeasure.instruments.siglenttechnologies.siglent_spd1305x import SPD1305X
26
27
28 def test_set_current():
29 with expected_protocol(
30 SPD1305X,
31 [("CH1:CURR 0.5", None),
32 ("CH1:CURR?", "0.5")]
33 ) as inst:
34 inst.ch_1.current_limit = 0.5
35 assert inst.ch_1.current_limit == 0.5
36
37
38 def test_set_current_trunc():
39 with expected_protocol(
40 SPD1305X,
41 [("CH1:CURR 5", None),
42 ("CH1:CURR?", "5")]
43 ) as inst:
44 inst.ch_1.current_limit = 10 # too large, gets truncated
45 assert inst.ch_1.current_limit == 5
46
47
48 def test_set_voltage():
49 with expected_protocol(
50 SPD1305X,
51 [("CH1:VOLT 0.5", None),
52 ("CH1:VOLT?", "0.5")]
53 ) as inst:
54 inst.ch_1.voltage_setpoint = 0.5
55 assert inst.ch_1.voltage_setpoint == 0.5
56
57
58 def test_set_voltage_trunc():
59 with expected_protocol(
60 SPD1305X,
61 [("CH1:VOLT 30", None),
62 ("CH1:VOLT?", "30")]
63 ) as inst:
64 inst.ch_1.voltage_setpoint = 35 # too large, gets truncated
65 assert inst.ch_1.voltage_setpoint == 30
66
67
68 def test_configure_timer():
69 with expected_protocol(
70 SPD1305X,
71 [("TIME:SET CH1,1,5.001,5.000,30", None)]
72 ) as inst:
73 inst.ch_1.configure_timer(1, 5.001, 8.55, 30)