| 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 |
|
| 26 |
from pymeasure.instruments.hp.hp11713a import HP11713A, Attenuator_110dB |
| 27 |
|
| 28 |
import pytest |
| 29 |
|
| 30 |
|
| 31 |
class TestHP11713A: |
| 32 |
@pytest.mark.parametrize("channel", list(range(0, 9))) |
| 33 |
def test_channels(self, channel): |
| 34 |
with expected_protocol( |
| 35 |
HP11713A, |
| 36 |
[(f"A{channel}", None), |
| 37 |
(f"B{channel}", None)], |
| 38 |
) as instr: |
| 39 |
ch = getattr(instr, f"ch_{channel}") |
| 40 |
ch.enabled = True |
| 41 |
ch.enabled = False |
| 42 |
|
| 43 |
def test_attenuation_x(self): |
| 44 |
with expected_protocol( |
| 45 |
HP11713A, |
| 46 |
[("A1", None), |
| 47 |
("B2", None), |
| 48 |
("B3", None), |
| 49 |
("B4", None), |
| 50 |
("A1", None), |
| 51 |
("A2", None), |
| 52 |
("A3", None), |
| 53 |
("A4", None)], |
| 54 |
) as instr: |
| 55 |
instr.ATTENUATOR_X = Attenuator_110dB |
| 56 |
instr.attenuation_x(10) |
| 57 |
instr.attenuation_x(110) |
| 58 |
|
| 59 |
def test_attenuation_y(self): |
| 60 |
with expected_protocol( |
| 61 |
HP11713A, |
| 62 |
[("A5", None), |
| 63 |
("B6", None), |
| 64 |
("B7", None), |
| 65 |
("B8", None), |
| 66 |
("A5", None), |
| 67 |
("A6", None), |
| 68 |
("A7", None), |
| 69 |
("A8", None)], |
| 70 |
) as instr: |
| 71 |
instr.ATTENUATOR_Y = Attenuator_110dB |
| 72 |
instr.attenuation_y(10) |
| 73 |
instr.attenuation_y(110) |
| 74 |
|
| 75 |
def test_attenuation_x_rounding(self): |
| 76 |
with expected_protocol( |
| 77 |
HP11713A, |
| 78 |
[("A1", None), |
| 79 |
("B2", None), |
| 80 |
("B3", None), |
| 81 |
("B4", None), |
| 82 |
("A1", None), |
| 83 |
("A2", None), |
| 84 |
("A3", None), |
| 85 |
("A4", None)], |
| 86 |
) as instr: |
| 87 |
instr.ATTENUATOR_X = Attenuator_110dB |
| 88 |
instr.attenuation_x(12.5) |
| 89 |
instr.attenuation_x(109) |
| 90 |
|
| 91 |
def test_deactivate_all(self): |
| 92 |
with expected_protocol( |
| 93 |
HP11713A, |
| 94 |
[("B1234567890", None)], |
| 95 |
) as instr: |
| 96 |
instr.deactivate_all() |