1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
import pytest
from pymeasure.test import expected_protocol
from pymeasure.instruments.hp import HP33120A
def test_init():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None)],
):
pass # Verify the expected communication.
def test_amplitude_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:VOLT 4', None)],
) as inst:
inst.amplitude = 4
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:VOLT?', b'+4.00000E+00')],
4.0),
))
def test_amplitude_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.amplitude == value
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:VOLT:UNIT?', b'VPP')],
'Vpp'),
))
def test_amplitude_units_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.amplitude_units == value
def test_burst_count_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:NCYC 500', None)],
) as inst:
inst.burst_count = 500
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:NCYC?', b'+1.00000E+00')],
1.0),
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:NCYC?', b'+5.00000E+02')],
500.0),
))
def test_burst_count_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.burst_count == value
def test_burst_enabled_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:STATE 1', None)],
) as inst:
inst.burst_enabled = True
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:STATE?', b'1')],
True),
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:STATE?', b'0')],
False),
))
def test_burst_enabled_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.burst_enabled == value
def test_burst_phase_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:PHAS 20', None)],
) as inst:
inst.burst_phase = 20
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:PHAS?', b'+0.00000E+00')],
0.0),
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:PHAS?', b'+2.00000E+01')],
20.0),
))
def test_burst_phase_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.burst_phase == value
def test_burst_rate_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:INT:RATE 250', None)],
) as inst:
inst.burst_rate = 250
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:INT:RATE?', b'+1.00000E+02')],
100.0),
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:INT:RATE?', b'+2.50000E+02')],
250.0),
))
def test_burst_rate_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.burst_rate == value
def test_burst_source_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:SOURCE INT', None)],
) as inst:
inst.burst_source = 'INT'
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'BM:SOURCE?', b'INT')],
'INT'),
))
def test_burst_source_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.burst_source == value
def test_frequency_setter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:FREQ 2000', None)],
) as inst:
inst.frequency = 2000.0
@pytest.mark.parametrize("comm_pairs, value", (
([(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:FREQ?', b'+2.00000000000E+03')],
2000.0),
([(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:FREQ?', b'+2.00000000000E+03')],
2000.0),
))
def test_frequency_getter(comm_pairs, value):
with expected_protocol(
HP33120A,
comm_pairs,
) as inst:
assert inst.frequency == value
def test_offset_getter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:VOLT:OFFS?', b'+0.00000E+00')],
) as inst:
assert inst.offset == 0.0
def test_shape_getter():
with expected_protocol(
HP33120A,
[(b'SOUR:VOLT:UNIT VPP', None),
(b'SOUR:FUNC:SHAP?', b'SIN')],
) as inst:
assert inst.shape == 'sinusoid'
|