| 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_spd1168x import SPD1168X |
| 26 |
|
| 27 |
|
| 28 |
def test_enable_4W_mode(): |
| 29 |
with expected_protocol( |
| 30 |
SPD1168X, |
| 31 |
[("MODE:SET 4W", None), |
| 32 |
("MODE:SET 2W", None)] |
| 33 |
) as inst: |
| 34 |
inst.enable_4W_mode(True) |
| 35 |
inst.enable_4W_mode(False) |
| 36 |
|
| 37 |
|
| 38 |
def test_save_config(): |
| 39 |
with expected_protocol( |
| 40 |
SPD1168X, |
| 41 |
[("*SAV 1", None), |
| 42 |
("*SAV 5", None)] |
| 43 |
) as inst: |
| 44 |
inst.save_config(1) |
| 45 |
inst.save_config(5) |
| 46 |
|
| 47 |
|
| 48 |
def test_recall_config(): |
| 49 |
with expected_protocol( |
| 50 |
SPD1168X, |
| 51 |
[("*RCL 1", None), |
| 52 |
("*RCL 5", None)] |
| 53 |
) as inst: |
| 54 |
inst.recall_config(1) |
| 55 |
inst.recall_config(5) |
| 56 |
|
| 57 |
|
| 58 |
def test_set_current(): |
| 59 |
with expected_protocol( |
| 60 |
SPD1168X, |
| 61 |
[("CH1:CURR 0.5", None), |
| 62 |
("CH1:CURR?", "0.5")] |
| 63 |
) as inst: |
| 64 |
inst.ch_1.current_limit = 0.5 |
| 65 |
assert inst.ch_1.current_limit == 0.5 |
| 66 |
|
| 67 |
|
| 68 |
def test_set_current_trunc(): |
| 69 |
with expected_protocol( |
| 70 |
SPD1168X, |
| 71 |
[("CH1:CURR 8", None), |
| 72 |
("CH1:CURR?", "8")] |
| 73 |
) as inst: |
| 74 |
inst.ch_1.current_limit = 10 # too large, gets truncated |
| 75 |
assert inst.ch_1.current_limit == 8 |
| 76 |
|
| 77 |
|
| 78 |
def test_enable_output(): |
| 79 |
with expected_protocol( |
| 80 |
SPD1168X, |
| 81 |
[("INST CH1", None), |
| 82 |
("OUTP CH1,ON", None), |
| 83 |
("INST CH1", None), |
| 84 |
("OUTP CH1,OFF", None)] |
| 85 |
) as inst: |
| 86 |
inst.ch_1.enable_output() |
| 87 |
inst.ch_1.enable_output(False) |
| 88 |
|
| 89 |
|
| 90 |
def test_enable_timer(): |
| 91 |
with expected_protocol( |
| 92 |
SPD1168X, |
| 93 |
[("TIME CH1,ON", None), |
| 94 |
("TIME CH1,OFF", None)] |
| 95 |
) as inst: |
| 96 |
inst.ch_1.enable_timer() |
| 97 |
inst.ch_1.enable_timer(False) |
| 98 |
|
| 99 |
|
| 100 |
def test_configure_timer(): |
| 101 |
with expected_protocol( |
| 102 |
SPD1168X, |
| 103 |
[("TIME:SET CH1,1,5.001,8.000,30", None)] |
| 104 |
) as inst: |
| 105 |
inst.ch_1.configure_timer(1, 5.001, 8.55, 30) |