| 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 |
|
| 25 |
import pytest |
| 26 |
|
| 27 |
from pymeasure.test import expected_protocol |
| 28 |
from pymeasure.instruments.aimtti.aimttiPL import PL303QMTP, PL303QMDP |
| 29 |
|
| 30 |
|
| 31 |
def test_voltage_setpoint(): |
| 32 |
with expected_protocol( |
| 33 |
PL303QMTP, |
| 34 |
[("V2V 1.2", None), |
| 35 |
("V2?", "V2 1.2") |
| 36 |
], |
| 37 |
) as inst: |
| 38 |
inst.ch_2.voltage_setpoint = 1.2 |
| 39 |
assert inst.ch_2.voltage_setpoint == 1.2 |
| 40 |
|
| 41 |
|
| 42 |
def test_voltage(): |
| 43 |
with expected_protocol( |
| 44 |
PL303QMTP, |
| 45 |
[("V2O?", "1.2V") |
| 46 |
], |
| 47 |
) as inst: |
| 48 |
assert inst.ch_2.voltage == 1.2 |
| 49 |
|
| 50 |
|
| 51 |
def test_current_limit(): |
| 52 |
with expected_protocol( |
| 53 |
PL303QMTP, |
| 54 |
[("I2 0.1", None), |
| 55 |
("I2?", "I2 0.1") |
| 56 |
], |
| 57 |
) as inst: |
| 58 |
inst.ch_2.current_limit = 0.1 |
| 59 |
assert inst.ch_2.current_limit == 0.1 |
| 60 |
|
| 61 |
|
| 62 |
def test_current(): |
| 63 |
with expected_protocol( |
| 64 |
PL303QMTP, |
| 65 |
[("I2O?", "0.123A") |
| 66 |
], |
| 67 |
) as inst: |
| 68 |
assert inst.ch_2.current == 0.123 |
| 69 |
|
| 70 |
|
| 71 |
def test_current_range(): |
| 72 |
with expected_protocol( |
| 73 |
PL303QMTP, |
| 74 |
[("IRANGE2 2", None), |
| 75 |
("IRANGE2?", "2"), |
| 76 |
("IRANGE2 1", None), |
| 77 |
("IRANGE2?", "1") |
| 78 |
], |
| 79 |
) as inst: |
| 80 |
inst.ch_2.current_range = "HIGH" |
| 81 |
assert inst.ch_2.current_range == "HIGH" |
| 82 |
inst.ch_2.current_range = "LOW" |
| 83 |
assert inst.ch_2.current_range == "LOW" |
| 84 |
|
| 85 |
|
| 86 |
def test_enable(): |
| 87 |
with expected_protocol( |
| 88 |
PL303QMTP, |
| 89 |
[("OP2 1", None), |
| 90 |
("OP2?", "1"), |
| 91 |
("OP2 0", None), |
| 92 |
("OPALL 1", None), |
| 93 |
("OPALL 0", None) |
| 94 |
], |
| 95 |
) as inst: |
| 96 |
inst.ch_2.output_enabled = True |
| 97 |
assert inst.ch_2.output_enabled is True |
| 98 |
inst.ch_2.output_enabled = False |
| 99 |
inst.all_outputs_enabled = True |
| 100 |
inst.all_outputs_enabled = False |
| 101 |
|
| 102 |
|
| 103 |
def test_triple(): |
| 104 |
with expected_protocol( |
| 105 |
PL303QMTP, |
| 106 |
[("V3O?", "1.2V")], |
| 107 |
) as inst: |
| 108 |
assert inst.ch_3.voltage == 1.2 |
| 109 |
|
| 110 |
|
| 111 |
def test_strict_range_error(): |
| 112 |
with expected_protocol( |
| 113 |
PL303QMDP, |
| 114 |
[], |
| 115 |
) as inst: |
| 116 |
with pytest.raises(ValueError): |
| 117 |
inst.ch_1.voltage_setpoint = 31 |