| 1 |
# |
| 2 |
# This file is part of the PyMeasure package. |
| 3 |
# |
| 4 |
# Copyright (c) 2013-2023 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 |
import pytest |
| 25 |
|
| 26 |
from pymeasure.test import expected_protocol |
| 27 |
from pymeasure.instruments.mksinst.mks974b import MKS974B, Unit |
| 28 |
|
| 29 |
|
| 30 |
def test_device_type(): |
| 31 |
"""Verify the communication of the device type.""" |
| 32 |
with expected_protocol( |
| 33 |
MKS974B, |
| 34 |
[("@253DT?", "@253ACKQUADMAG"), |
| 35 |
(None, b"FF")], |
| 36 |
) as inst: |
| 37 |
assert inst.device_type == "QUADMAG" |
| 38 |
|
| 39 |
|
| 40 |
def test_status(): |
| 41 |
"""Verify the communication of the status.""" |
| 42 |
with expected_protocol( |
| 43 |
MKS974B, |
| 44 |
[("@253T?", "@253ACKO"), |
| 45 |
(None, b"FF")], |
| 46 |
) as inst: |
| 47 |
assert inst.status == "Ok" |
| 48 |
|
| 49 |
|
| 50 |
def test_pressure(): |
| 51 |
"""Verify the communication of the pressure getter.""" |
| 52 |
with expected_protocol( |
| 53 |
MKS974B, |
| 54 |
[("@253PR4?", "@253ACK1.234E-3"), |
| 55 |
(None, b"FF")], |
| 56 |
) as inst: |
| 57 |
assert inst.pressure == pytest.approx(1.234e-3) |
| 58 |
|
| 59 |
|
| 60 |
def test_pirani_pressure(): |
| 61 |
"""Verify the communication of the pirani pressure getter.""" |
| 62 |
with expected_protocol( |
| 63 |
MKS974B, |
| 64 |
[("@253PR1?", "@253ACK1.23E-3"), |
| 65 |
(None, b"FF")], |
| 66 |
) as inst: |
| 67 |
assert inst.pirani_pressure == pytest.approx(1.23e-3) |
| 68 |
|
| 69 |
|
| 70 |
def test_unit_setter(): |
| 71 |
"""Verify the communication of the unit setter.""" |
| 72 |
with expected_protocol( |
| 73 |
MKS974B, |
| 74 |
[("@253U!PASCAL", "@253ACKPASCAL"), |
| 75 |
(None, b"FF")], |
| 76 |
) as inst: |
| 77 |
inst.unit = Unit.Pa |
| 78 |
|
| 79 |
|
| 80 |
def test_unit_getter(): |
| 81 |
"""Verify the communication of the unit getter.""" |
| 82 |
with expected_protocol( |
| 83 |
MKS974B, |
| 84 |
[("@253U?", "@253ACKTORR"), |
| 85 |
(None, b"FF")], |
| 86 |
) as inst: |
| 87 |
assert inst.unit == Unit.Torr |
| 88 |
|
| 89 |
|
| 90 |
def test_switch_enabled(): |
| 91 |
"""Verify the communication of the user swith getter.""" |
| 92 |
with expected_protocol( |
| 93 |
MKS974B, |
| 94 |
[("@253SW?", "@253ACKON"), |
| 95 |
(None, b"FF")], |
| 96 |
) as inst: |
| 97 |
assert inst.switch_enabled is True |
| 98 |
|
| 99 |
|
| 100 |
def test_relay_value(): |
| 101 |
"""Verify the communication of the relay setpoint getter.""" |
| 102 |
with expected_protocol( |
| 103 |
MKS974B, |
| 104 |
[("@253SP1?", "@253ACK2.00E+1"), |
| 105 |
(None, b"FF")], |
| 106 |
) as inst: |
| 107 |
assert inst.relay_1.setpoint == pytest.approx(2.00e1) |
| 108 |
|
| 109 |
|
| 110 |
def test_relay_direction(): |
| 111 |
"""Verify the communication of the relay direction.""" |
| 112 |
with expected_protocol( |
| 113 |
MKS974B, |
| 114 |
[("@253SD2?", "@253ACKBELOW"), |
| 115 |
(None, b"FF")], |
| 116 |
) as inst: |
| 117 |
assert inst.relay_2.direction == "BELOW" |
| 118 |
|
| 119 |
|
| 120 |
def test_relay_enabled(): |
| 121 |
"""Verify the communication of the relay enabled property.""" |
| 122 |
with expected_protocol( |
| 123 |
MKS974B, |
| 124 |
[("@253EN3?", "@253ACKPIR"), |
| 125 |
(None, b"FF")], |
| 126 |
) as inst: |
| 127 |
assert inst.relay_3.enabled == "pirani" |