| 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 |
import pytest |
| 26 |
|
| 27 |
from pymeasure.test import expected_protocol |
| 28 |
from pymeasure.instruments.aja.dcxs import DCXS |
| 29 |
|
| 30 |
|
| 31 |
def test_id(): |
| 32 |
""" |
| 33 |
Test DCXS identification property |
| 34 |
""" |
| 35 |
with expected_protocol( |
| 36 |
DCXS, |
| 37 |
[("?", "DCXS750-4"), ], |
| 38 |
) as inst: |
| 39 |
assert inst.id == "DCXS750-4" |
| 40 |
|
| 41 |
|
| 42 |
@pytest.mark.parametrize("setpoint", [5, 97]) |
| 43 |
def test_setpoint(setpoint): |
| 44 |
""" |
| 45 |
Test DCXS setpoint |
| 46 |
""" |
| 47 |
with expected_protocol( |
| 48 |
DCXS, |
| 49 |
[ |
| 50 |
(f"C{setpoint:04d}", None), |
| 51 |
("b", f"{setpoint:04d}"), |
| 52 |
], |
| 53 |
) as inst: |
| 54 |
inst.setpoint = setpoint |
| 55 |
assert setpoint == inst.setpoint |
| 56 |
|
| 57 |
|
| 58 |
def test_regulation_mode(): |
| 59 |
""" |
| 60 |
Test DCXS regulation mode |
| 61 |
""" |
| 62 |
with expected_protocol( |
| 63 |
DCXS, |
| 64 |
[ |
| 65 |
("D0", None), |
| 66 |
("c", 0), |
| 67 |
], |
| 68 |
) as inst: |
| 69 |
inst.regulation_mode = "power" |
| 70 |
assert "power" == inst.regulation_mode |
| 71 |
|
| 72 |
|
| 73 |
def test_enabled(): |
| 74 |
""" |
| 75 |
Test DCXS enabled |
| 76 |
""" |
| 77 |
with expected_protocol( |
| 78 |
DCXS, |
| 79 |
[ |
| 80 |
("A", None), |
| 81 |
("a", "1"), |
| 82 |
], |
| 83 |
) as inst: |
| 84 |
inst.enabled = True |
| 85 |
assert inst.enabled is True |
| 86 |
|
| 87 |
|
| 88 |
def test_material(): |
| 89 |
""" |
| 90 |
Test DCXS material name and its truncation |
| 91 |
""" |
| 92 |
with expected_protocol( |
| 93 |
DCXS, |
| 94 |
[ |
| 95 |
("IALongNam", None), |
| 96 |
("n", "ALongNam"), |
| 97 |
], |
| 98 |
) as inst: |
| 99 |
inst.material = "ALongNameWhichGetsTruncated" |
| 100 |
assert "ALongNam" == inst.material |