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
|
#
# This file is part of the PyMeasure package.
#
# Copyright (c) 2013-2022 PyMeasure Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
from pymeasure.test import expected_protocol
from pymeasure.instruments.racal import Racal1992
# ============================================================
# TESTS
# ============================================================
def test_self_check():
with expected_protocol(
Racal1992,
[
(' CK', 'CK+010.00000000E+06'),
],
) as instr:
instr.operating_mode = 'self_check'
assert instr.measured_value == 10000000.0
def test_frequency_a():
with expected_protocol(
Racal1992,
[
(' FA', 'FA+010.00000000E+06'),
],
) as instr:
instr.operating_mode = 'frequency_a'
assert instr.measured_value == 10000000.0
def test_period_a():
with expected_protocol(
Racal1992,
[
(' PA', 'PA+000100.00000E-09'),
],
) as instr:
instr.operating_mode = 'period_a'
assert instr.measured_value == 100e-9
def test_interval_a_to_b():
with expected_protocol(
Racal1992,
[
(' TI', 'TI+00000000046.E-09'),
],
) as instr:
instr.operating_mode = 'interval_a_to_b'
assert instr.measured_value == 46e-9
def test_total_a_by_b():
with expected_protocol(
Racal1992,
[
(' TA', 'TA+00000000001.E+00'),
],
) as instr:
instr.operating_mode = 'total_a_by_b'
assert instr.measured_value == 1
def test_phase_a_rel_b():
with expected_protocol(
Racal1992,
[
(' PH', 'PH+00000000164.E+00'),
],
) as instr:
instr.operating_mode = 'phase_a_rel_b'
assert instr.measured_value == 164
def test_ratio_a_to_b():
with expected_protocol(
Racal1992,
[
(' RA', 'RA+00001.000000E+00'),
],
) as instr:
instr.operating_mode = 'ratio_a_to_b'
assert instr.measured_value == 1.0
def test_ratio_c_to_b():
with expected_protocol(
Racal1992,
[
(' RC', 'RC+00001.000000E+00'),
],
) as instr:
instr.operating_mode = 'ratio_c_to_b'
assert instr.measured_value == 1.0
def test_frequency_c():
with expected_protocol(
Racal1992,
[
(' FC', 'FC+010.00000000E+06'),
],
) as instr:
instr.operating_mode = 'frequency_c'
assert instr.measured_value == 10000000.0
def test_resolution():
with expected_protocol(
Racal1992,
[
(' SRS 10', None),
(' RRS', 'RS+00000000010.E+00')
],
) as instr:
instr.resolution = 10
assert instr.resolution == 10
def test_channel_a_settings():
with expected_protocol(
Racal1992,
[
(' AAC AAD AAU ALI APS AFE SLA 1.5', None),
(' ADC AAE AMN AHI ANS AFD', None),
],
) as instr:
instr.channel_settings(
'A',
coupling='AC',
attenuation='X1',
trigger='auto',
impedance='50',
slope='pos',
filtering=True,
trigger_level=1.5
)
instr.channel_settings(
'A',
coupling='DC',
attenuation='X10',
trigger='manual',
impedance='1M',
slope='neg',
filtering=False,
)
def test_channel_b_settings():
with expected_protocol(
Racal1992,
[
(' BAC BAD BAU BLI BPS BCS SLB 1.5', None),
(' BDC BAE BMN BHI BNS BCC', None),
],
) as instr:
instr.channel_settings(
'B',
coupling='AC',
attenuation='X1',
trigger='auto',
impedance='50',
slope='pos',
input_select='separate',
trigger_level=1.5
)
instr.channel_settings(
'B',
coupling='DC',
attenuation='X10',
trigger='manual',
impedance='1M',
slope='neg',
input_select='common',
)
def test_preset():
with expected_protocol(
Racal1992,
[
(' IP', 'FA+0010.0000000E+06'),
],
) as instr:
instr.preset()
assert instr.measured_value == 10000000.0
def test_reset_measurement():
with expected_protocol(
Racal1992,
[
(' RE', 'FA+0010.0000000E+06'),
],
) as instr:
instr.reset_measurement()
assert instr.measured_value == 10000000.0
def test_software_version():
with expected_protocol(
Racal1992,
[
(' RMS', 'MS+00085720404.E+00'),
],
) as instr:
assert instr.software_version == 85720404
def test_gpib_software_version():
with expected_protocol(
Racal1992,
[
(' RGS', 'GS+0000000003.1E+00'),
],
) as instr:
assert instr.gpib_software_version == 3.1
def test_math_x():
with expected_protocol(
Racal1992,
[
(' SMX 1.000000', None),
(' RMX', 'MX+001.00000000E+00')
],
) as instr:
instr.math_x = 1.0
assert instr.math_x == 1.0
def test_math_z():
with expected_protocol(
Racal1992,
[
(' SMZ 1.000000', None),
(' RMZ', 'MZ+001.00000000E+00')
],
) as instr:
instr.math_z = 1.0
assert instr.math_z == 1.0
def test_math_mode():
with expected_protocol(
Racal1992,
[
(' ME', None),
(' MD', None),
],
) as instr:
instr.math_mode = True
instr.math_mode = False
def test_device_type():
with expected_protocol(
Racal1992,
[
(' RUT', 'UT+00000001992.E+00')
],
) as instr:
assert instr.device_type == 1992
def test_trigger_level():
with expected_protocol(
Racal1992,
[
(' SLA 1.500000', None),
(' SLB 1.500000', None),
(' RLA', 'LA+000000001.50E+00'),
(' RLB', 'LB+000000001.50E+00'),
],
) as instr:
instr.trigger_level_a = 1.5
instr.trigger_level_b = 1.5
assert instr.trigger_level_a == 1.5
assert instr.trigger_level_b == 1.5
def test_delay_enable():
with expected_protocol(
Racal1992,
[
(' DE', None),
(' DD', None),
],
) as instr:
instr.delay_enable = True
instr.delay_enable = False
def test_delay_time():
with expected_protocol(
Racal1992,
[
(' SDT 1.500000', None),
(' RDT', 'DT+000000001.50E+00'),
],
) as instr:
instr.delay_time = 1.5
assert instr.delay_time == 1.5
def test_special_function_enable():
with expected_protocol(
Racal1992,
[
(' SFE', None),
(' SFD', None),
],
) as instr:
instr.special_function_enable = True
instr.special_function_enable = False
|