Debian Codegraph @

tests/instruments/racal/test_racal1992.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2022 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
25 from pymeasure.test import expected_protocol
26 from pymeasure.instruments.racal import Racal1992
27
28 # ============================================================
29 # TESTS
30 # ============================================================
31
32
33 def test_self_check():
34 with expected_protocol(
35 Racal1992,
36 [
37 (' CK', 'CK+010.00000000E+06'),
38 ],
39 ) as instr:
40 instr.operating_mode = 'self_check'
41 assert instr.measured_value == 10000000.0
42
43
44 def test_frequency_a():
45 with expected_protocol(
46 Racal1992,
47 [
48 (' FA', 'FA+010.00000000E+06'),
49 ],
50 ) as instr:
51 instr.operating_mode = 'frequency_a'
52 assert instr.measured_value == 10000000.0
53
54
55 def test_period_a():
56 with expected_protocol(
57 Racal1992,
58 [
59 (' PA', 'PA+000100.00000E-09'),
60 ],
61 ) as instr:
62 instr.operating_mode = 'period_a'
63 assert instr.measured_value == 100e-9
64
65
66 def test_interval_a_to_b():
67 with expected_protocol(
68 Racal1992,
69 [
70 (' TI', 'TI+00000000046.E-09'),
71 ],
72 ) as instr:
73 instr.operating_mode = 'interval_a_to_b'
74 assert instr.measured_value == 46e-9
75
76
77 def test_total_a_by_b():
78 with expected_protocol(
79 Racal1992,
80 [
81 (' TA', 'TA+00000000001.E+00'),
82 ],
83 ) as instr:
84 instr.operating_mode = 'total_a_by_b'
85 assert instr.measured_value == 1
86
87
88 def test_phase_a_rel_b():
89 with expected_protocol(
90 Racal1992,
91 [
92 (' PH', 'PH+00000000164.E+00'),
93 ],
94 ) as instr:
95 instr.operating_mode = 'phase_a_rel_b'
96 assert instr.measured_value == 164
97
98
99 def test_ratio_a_to_b():
100 with expected_protocol(
101 Racal1992,
102 [
103 (' RA', 'RA+00001.000000E+00'),
104 ],
105 ) as instr:
106 instr.operating_mode = 'ratio_a_to_b'
107 assert instr.measured_value == 1.0
108
109
110 def test_ratio_c_to_b():
111 with expected_protocol(
112 Racal1992,
113 [
114 (' RC', 'RC+00001.000000E+00'),
115 ],
116 ) as instr:
117 instr.operating_mode = 'ratio_c_to_b'
118 assert instr.measured_value == 1.0
119
120
121 def test_frequency_c():
122 with expected_protocol(
123 Racal1992,
124 [
125 (' FC', 'FC+010.00000000E+06'),
126 ],
127 ) as instr:
128 instr.operating_mode = 'frequency_c'
129 assert instr.measured_value == 10000000.0
130
131
132 def test_resolution():
133 with expected_protocol(
134 Racal1992,
135 [
136 (' SRS 10', None),
137 (' RRS', 'RS+00000000010.E+00')
138 ],
139 ) as instr:
140 instr.resolution = 10
141 assert instr.resolution == 10
142
143
144 def test_channel_a_settings():
145 with expected_protocol(
146 Racal1992,
147 [
148 (' AAC AAD AAU ALI APS AFE SLA 1.5', None),
149 (' ADC AAE AMN AHI ANS AFD', None),
150 ],
151 ) as instr:
152 instr.channel_settings(
153 'A',
154 coupling='AC',
155 attenuation='X1',
156 trigger='auto',
157 impedance='50',
158 slope='pos',
159 filtering=True,
160 trigger_level=1.5
161 )
162 instr.channel_settings(
163 'A',
164 coupling='DC',
165 attenuation='X10',
166 trigger='manual',
167 impedance='1M',
168 slope='neg',
169 filtering=False,
170 )
171
172
173 def test_channel_b_settings():
174 with expected_protocol(
175 Racal1992,
176 [
177 (' BAC BAD BAU BLI BPS BCS SLB 1.5', None),
178 (' BDC BAE BMN BHI BNS BCC', None),
179 ],
180 ) as instr:
181 instr.channel_settings(
182 'B',
183 coupling='AC',
184 attenuation='X1',
185 trigger='auto',
186 impedance='50',
187 slope='pos',
188 input_select='separate',
189 trigger_level=1.5
190 )
191 instr.channel_settings(
192 'B',
193 coupling='DC',
194 attenuation='X10',
195 trigger='manual',
196 impedance='1M',
197 slope='neg',
198 input_select='common',
199 )
200
201
202 def test_preset():
203 with expected_protocol(
204 Racal1992,
205 [
206 (' IP', 'FA+0010.0000000E+06'),
207 ],
208 ) as instr:
209 instr.preset()
210 assert instr.measured_value == 10000000.0
211
212
213 def test_reset_measurement():
214 with expected_protocol(
215 Racal1992,
216 [
217 (' RE', 'FA+0010.0000000E+06'),
218 ],
219 ) as instr:
220 instr.reset_measurement()
221 assert instr.measured_value == 10000000.0
222
223
224 def test_software_version():
225 with expected_protocol(
226 Racal1992,
227 [
228 (' RMS', 'MS+00085720404.E+00'),
229 ],
230 ) as instr:
231 assert instr.software_version == 85720404
232
233
234 def test_gpib_software_version():
235 with expected_protocol(
236 Racal1992,
237 [
238 (' RGS', 'GS+0000000003.1E+00'),
239 ],
240 ) as instr:
241 assert instr.gpib_software_version == 3.1
242
243
244 def test_math_x():
245 with expected_protocol(
246 Racal1992,
247 [
248 (' SMX 1.000000', None),
249 (' RMX', 'MX+001.00000000E+00')
250 ],
251 ) as instr:
252 instr.math_x = 1.0
253 assert instr.math_x == 1.0
254
255
256 def test_math_z():
257 with expected_protocol(
258 Racal1992,
259 [
260 (' SMZ 1.000000', None),
261 (' RMZ', 'MZ+001.00000000E+00')
262 ],
263 ) as instr:
264 instr.math_z = 1.0
265 assert instr.math_z == 1.0
266
267
268 def test_math_mode():
269 with expected_protocol(
270 Racal1992,
271 [
272 (' ME', None),
273 (' MD', None),
274 ],
275 ) as instr:
276 instr.math_mode = True
277 instr.math_mode = False
278
279
280 def test_device_type():
281 with expected_protocol(
282 Racal1992,
283 [
284 (' RUT', 'UT+00000001992.E+00')
285 ],
286 ) as instr:
287 assert instr.device_type == 1992
288
289
290 def test_trigger_level():
291 with expected_protocol(
292 Racal1992,
293 [
294 (' SLA 1.500000', None),
295 (' SLB 1.500000', None),
296 (' RLA', 'LA+000000001.50E+00'),
297 (' RLB', 'LB+000000001.50E+00'),
298 ],
299 ) as instr:
300 instr.trigger_level_a = 1.5
301 instr.trigger_level_b = 1.5
302 assert instr.trigger_level_a == 1.5
303 assert instr.trigger_level_b == 1.5
304
305
306 def test_delay_enable():
307 with expected_protocol(
308 Racal1992,
309 [
310 (' DE', None),
311 (' DD', None),
312 ],
313 ) as instr:
314 instr.delay_enable = True
315 instr.delay_enable = False
316
317
318 def test_delay_time():
319 with expected_protocol(
320 Racal1992,
321 [
322 (' SDT 1.500000', None),
323 (' RDT', 'DT+000000001.50E+00'),
324 ],
325 ) as instr:
326 instr.delay_time = 1.5
327 assert instr.delay_time == 1.5
328
329
330 def test_special_function_enable():
331 with expected_protocol(
332 Racal1992,
333 [
334 (' SFE', None),
335 (' SFD', None),
336 ],
337 ) as instr:
338 instr.special_function_enable = True
339 instr.special_function_enable = False