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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
|
import datetime
import pytest
from pymeasure.test import expected_protocol
from pymeasure.instruments.redpitaya import RedPitayaScpi
def test_init():
with expected_protocol(
RedPitayaScpi,
[],
):
pass # Verify the expected communication.
def test_CLOCK_getter():
with expected_protocol(
RedPitayaScpi,
[],
) as inst:
assert inst.CLOCK == 125000000.0
def test_TRIGGER_SOURCES_getter():
with expected_protocol(
RedPitayaScpi,
[],
) as inst:
assert inst.TRIGGER_SOURCES == ('DISABLED', 'NOW', 'CH1_PE', 'CH1_NE', 'CH2_PE', 'CH2_NE',
'EXT_PE', 'EXT_NE', 'AWG_PE', 'AWG_NE')
def test_acq_buffer_filled_getter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:TRig:FILL?', b'0')],
) as inst:
assert inst.acq_buffer_filled is False
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:DATA:FORMAT ASCII', None)],
'ASCII'),
([(b'ACQ:DATA:FORMAT BIN', None)],
'BIN'),
([(b'ACQ:DATA:FORMAT BIN', None)],
'BIN'),
([(b'ACQ:DATA:FORMAT ASCII', None)],
'ASCII'),
))
def test_acq_format_setter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
inst.acq_format = value
def test_acq_size_getter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:BUF:SIZE?', b'16384')],
) as inst:
assert inst.buffer_length == 16384
def test_acq_trigger_delay_ns_setter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:TRig:DLY -8182', None)],
) as inst:
inst.acq_trigger_delay_ns = -65456
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:TRig:DLY?', b'0')],
0),
([(b'ACQ:TRig:DLY?', b'500')],
4000),
([(b'ACQ:TRig:DLY?', b'-8182')],
-65456),
))
def test_acq_trigger_delay_ns_getter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
assert inst.acq_trigger_delay_ns == value
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:TRig:DLY 0', None)],
0),
([(b'ACQ:TRig:DLY 500', None)],
500),
))
def test_acq_trigger_delay_samples_setter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
inst.acq_trigger_delay_samples = value
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:TRig:DLY?', b'0')],
0),
([(b'ACQ:TRig:DLY?', b'500')],
500),
([(b'ACQ:TRig:DLY?', b'-8182')],
-8182),
))
def test_acq_trigger_delay_samples_getter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
assert inst.acq_trigger_delay_samples == value
def test_acq_trigger_level_setter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:TRig:LEV 0.500000', None)],
) as inst:
inst.acq_trigger_level = 0.5
def test_acq_trigger_level_getter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:TRig:LEV?', b'0.5')],
) as inst:
assert inst.acq_trigger_level == 0.5
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:TRig DISABLED', None)],
'DISABLED'),
([(b'ACQ:TRig NOW', None)],
'NOW'),
([(b'ACQ:TRig CH1_PE', None)],
'CH1_PE'),
([(b'ACQ:TRig CH1_NE', None)],
'CH1_NE'),
([(b'ACQ:TRig CH2_PE', None)],
'CH2_PE'),
([(b'ACQ:TRig CH2_NE', None)],
'CH2_NE'),
([(b'ACQ:TRig EXT_PE', None)],
'EXT_PE'),
([(b'ACQ:TRig EXT_NE', None)],
'EXT_NE'),
([(b'ACQ:TRig AWG_PE', None)],
'AWG_PE'),
([(b'ACQ:TRig AWG_NE', None)],
'AWG_NE'),
))
def test_acq_trigger_source_setter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
inst.acq_trigger_source = value
def test_acq_trigger_status_getter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:TRig:STAT?', b'TD')],
) as inst:
assert inst.acq_trigger_status is True
def test_acq_units_setter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:DATA:Units RAW', None)],
) as inst:
inst.acq_units = 'RAW'
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:DATA:Units?', b'VOLTS')],
'VOLTS'),
([(b'ACQ:DATA:Units?', b'RAW')],
'RAW'),
))
def test_acq_units_getter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
assert inst.acq_units == value
def test_ain1_gain_setter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:SOUR1:GAIN LV', None)],
) as inst:
inst.ain1.gain = 'LV'
def test_ain1_gain_getter():
with expected_protocol(
RedPitayaScpi,
[(b'ACQ:SOUR1:GAIN?', b'LV')],
) as inst:
assert inst.ain1.gain == 'LV'
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:AVG OFF', None)],
False),
([(b'ACQ:AVG ON', None)],
True),
))
def test_average_skipped_samples_setter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
inst.average_skipped_samples = value
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:AVG?', b'OFF')],
False),
([(b'ACQ:AVG?', b'ON')],
True),
))
def test_average_skipped_samples_getter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
assert inst.average_skipped_samples == value
def test_board_name_getter():
with expected_protocol(
RedPitayaScpi,
[(b'SYST:BRD:Name?', b'STEMlab 125-10')],
) as inst:
assert inst.board_name == 'STEMlab 125-10'
def test_date_setter():
with expected_protocol(
RedPitayaScpi,
[(b'SYST:DATE 2023,12,22', None)],
) as inst:
inst.date = datetime.date(2023, 12, 22)
def test_date_getter():
with expected_protocol(
RedPitayaScpi,
[(b'SYST:DATE?', b'2023,12,22')],
) as inst:
assert inst.date == datetime.date(2023, 12, 22)
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:DEC 1', None)],
1),
([(b'ACQ:DEC 2', None)],
2),
([(b'ACQ:DEC 4', None)],
4),
([(b'ACQ:DEC 8', None)],
8),
([(b'ACQ:DEC 16', None)],
16),
([(b'ACQ:DEC 32', None)],
32),
([(b'ACQ:DEC 64', None)],
64),
([(b'ACQ:DEC 128', None)],
128),
([(b'ACQ:DEC 256', None)],
256),
([(b'ACQ:DEC 512', None)],
512),
([(b'ACQ:DEC 1024', None)],
1024),
([(b'ACQ:DEC 2048', None)],
2048),
([(b'ACQ:DEC 4096', None)],
4096),
([(b'ACQ:DEC 8192', None)],
8192),
([(b'ACQ:DEC 16384', None)],
16384),
([(b'ACQ:DEC 32768', None)],
32768),
([(b'ACQ:DEC 65536', None)],
65536),
))
def test_decimation_setter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
inst.decimation = value
@pytest.mark.parametrize("comm_pairs, value", (
([(b'ACQ:DEC?', b'1')],
1.0),
([(b'ACQ:DEC?', b'2')],
2.0),
([(b'ACQ:DEC?', b'4')],
4.0),
([(b'ACQ:DEC?', b'8')],
8.0),
([(b'ACQ:DEC?', b'16')],
16.0),
([(b'ACQ:DEC?', b'32')],
32.0),
([(b'ACQ:DEC?', b'64')],
64.0),
([(b'ACQ:DEC?', b'128')],
128.0),
([(b'ACQ:DEC?', b'256')],
256.0),
([(b'ACQ:DEC?', b'512')],
512.0),
([(b'ACQ:DEC?', b'1024')],
1024.0),
([(b'ACQ:DEC?', b'2048')],
2048.0),
([(b'ACQ:DEC?', b'4096')],
4096.0),
([(b'ACQ:DEC?', b'8192')],
8192.0),
([(b'ACQ:DEC?', b'16384')],
16384.0),
([(b'ACQ:DEC?', b'32768')],
32768.0),
([(b'ACQ:DEC?', b'65536')],
65536.0),
))
def test_decimation_getter(comm_pairs, value):
with expected_protocol(
RedPitayaScpi,
comm_pairs,
) as inst:
assert inst.decimation == value
def test_led_getter():
with expected_protocol(
RedPitayaScpi,
[(b'DIG:PIN? LED7', 1)],
) as inst:
assert inst.led7.enabled
def test_time_setter():
with expected_protocol(
RedPitayaScpi,
[(b'SYST:TIME 13,07,20', None)],
) as inst:
inst.time = datetime.time(13, 7, 20)
def test_time_getter():
with expected_protocol(
RedPitayaScpi,
[(b'SYST:TIME?', '13,07,20')],
) as inst:
assert inst.time == datetime.time(13, 7, 20)
def test_analog_reset():
with expected_protocol(
RedPitayaScpi,
[(b'ANALOG:RST', None)],
) as inst:
assert inst.analog_reset() is None
def test_digital_reset():
with expected_protocol(
RedPitayaScpi,
[(b'DIG:RST', None)],
) as inst:
assert inst.digital_reset() is None
|