Debian Codegraph @

pymeasure/instruments/anritsu/anritsuMS2090A.py

raw
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 import logging
25 from pymeasure.instruments import Instrument, SCPIUnknownMixin
26 from pymeasure.instruments.validators import (
27 strict_discrete_set,
28 truncated_range,
29 strict_range,
30 )
31
32 log = logging.getLogger(__name__)
33 log.addHandler(logging.NullHandler())
34
35
36 class AnritsuMS2090A(SCPIUnknownMixin, Instrument):
37 """Anritsu MS2090A Handheld Spectrum Analyzer."""
38
39 def __init__(self, adapter, name="Anritsu MS2090A Handheld Spectrum Analyzer", **kwargs):
40 self.analysis_mode = None
41 super().__init__(
42 adapter, name, **kwargs)
43
44 #############
45 # Mappings #
46 #############
47
48 ONOFF = {True: 'ON', False: 'OFF'}
49 OFFFIRSTREPEAT = ['OFF', 'FIRSt', 'REPeat']
50 SPAMODES = ["SPECtrum", "NRADio", "RTSA", "LTE", "EMFMeter", "PANalyzer"]
51
52 ####################################
53 # GPS #
54 ####################################
55
56 gps_full = Instrument.measurement(
57 "FETCh:GPS:FULL?",
58 """
59 Returns the timestamp, latitude, longitude, altitude, and satellite count of the device.
60 """
61 )
62
63 gps_all = Instrument.measurement(
64 "FETCh:GPS:ALL?",
65 """Returns the fix timestamp, latitude, longitude, altitude and information on the sat used.
66 """
67
68 )
69
70 gps = Instrument.measurement(
71 ":FETCh:GPS?",
72 """
73 Returns the timestamp, latitude, and longitude of the device.
74 """
75 )
76
77 gps_last = Instrument.measurement(
78 ":FETCh:GPS:LAST?",
79 """
80 Returns the timestamp, latitude, longitude, and altitude of the last fixed GPS result.
81 """
82 )
83
84 external_current = Instrument.measurement(
85 "BIAS:EXT:CURR?",
86 """
87 This command queries the actual bias current in A
88 """
89 )
90
91 ####################################
92 # Spectrum Parameters - Wavelength #
93 ####################################
94
95 frequency_center = Instrument.control(
96 "FREQuency:CENTer?", "FREQuency:CENTer %g",
97 "Sets the center frequency in Hz",
98 validator=strict_range,
99 values=[9E3, 54E9]
100 )
101
102 frequency_offset = Instrument.control(
103 "FREQuency:OFFSet?", "FREQuency:OFFSet %g",
104 "Sets the frequency offset in Hz",
105 validator=strict_range,
106 values=[-10E9, 10E9],
107 )
108
109 frequency_span = Instrument.control(
110 "FREQuency:SPAN?", "FREQuency:SPAN %g",
111 "Sets the frequency span in Hz",
112 validator=strict_range,
113 values=[10, 400000000000],
114 )
115
116 frequency_span_full = Instrument.setting(
117 "FREQuency:SPAN:FULL",
118 "Sets the frequency span to full span"
119 )
120
121 frequency_span_last = Instrument.setting(
122 "FREQuency:SPAN:LAST",
123 "Sets the frequency span to the previous span value."
124 )
125
126 frequency_start = Instrument.control(
127 "FREQuency:STARt?", "FREQuency:STARt %g",
128 "Sets the start frequency in Hz",
129 validator=strict_range,
130 values=[9E3, 54E9],
131 )
132
133 frequency_step = Instrument.control(
134 ":FREQuency:STEP?", ":FREQuency:STEP %g",
135 "Set or query the step size to gradually increase or decrease frequency values in Hz",
136 validator=strict_range,
137 values=[1E3, 1E9],
138 )
139
140 frequency_stop = Instrument.control(
141 "FREQuency:STOP?", "FREQuency:STOP %g",
142 "Sets the start frequency in Hz",
143 validator=strict_range,
144 values=[9E3, 54E9],
145 )
146
147 fetch_power = Instrument.measurement(
148 "FET:CHP:CHP?",
149 """
150 Returns the most recent channel power measurement.
151 """
152 )
153
154 fetch_density = Instrument.measurement(
155 "FET:CHP:DEN?",
156 """
157 Returns the most recent channel density measurement
158 """
159 )
160
161 fetch_pbch_constellation = Instrument.measurement(
162 "FET:CONS:PBCH",
163 """
164 Get the latest Physical Broadcast Channel constellation hitmap
165 """
166 )
167
168 fetch_pdsch_constellation = Instrument.measurement(
169 "FET:CONS:PDSC?",
170 """
171 Get the latest Physical Downlink Shared Channel constellation
172 """
173 )
174
175 fetch_control = Instrument.measurement(
176 "FET:CONT?",
177 """
178 Returns the Control Channel measurement in json format.
179 """
180 )
181
182 fetch_eirpower = Instrument.measurement(
183 "FET:EIRP?",
184 """
185 Returns the current EIRP, Max EIRP, Horizontal EIRP, Vertical and Sum EIRP results in dBm.
186 """
187 )
188
189 fetch_eirpower_data = Instrument.measurement(
190 "FET:EIRP:DAT?",
191 """
192 This command returns the current EIRP measurement result in dBm.
193 """
194 )
195
196 fetch_eirpower_max = Instrument.measurement(
197 "FET:EIRP:MAX?",
198 """
199 This command returns the Max EIRP measurement result in dBm.
200 """
201 )
202
203 fetch_emf = Instrument.measurement(
204 "FET:EMF?",
205 """
206 Return the current EMF measurement data. JSON format.
207 """
208 )
209
210 fetch_emf_meter = Instrument.measurement(
211 "FET:EMF:MET?",
212 """
213 Return the live EMF measurement data. JSON format.
214 """
215 )
216
217 fetch_emf_meter_sample = Instrument.measurement(
218 "FET:EMF:MET:SAM%g?",
219 """
220 Return the EMF measurement data for a specified sample number. JSON format.
221 """,
222 values=[1, 16],
223 )
224
225 fetch_interference_power = Instrument.measurement(
226 "FET:INT:POW?",
227 """
228 Fetch Interference Finder Integrated Power.
229 """
230 )
231
232 fetch_mimo_antenas = Instrument.measurement(
233 "FET:MIMO:ANT?",
234 """
235 Returns the sync power measurement in json format.
236 """
237 )
238
239 fetch_ocupied_bw = Instrument.measurement(
240 "FET:OBW%g?",
241 """
242 Returns the different set of measurement information depending on the suffix.
243 """,
244 values=[1, 2]
245 )
246
247 fetch_ota_mapping = Instrument.measurement(
248 "FET:OTA:MAPP?",
249 """
250 Returns the most recent Coverage Mapping measurement result.
251 """
252 )
253
254 fetch_pan = Instrument.measurement(
255 "FET:PAN?",
256 """
257 Return the current Pulse Analyzer measurement data. JSON format
258 """
259 )
260
261 fetch_pci = Instrument.measurement(
262 "FET:PCI?",
263 """
264 Returns PCI measurements
265 """
266 )
267
268 fetch_pdsch = Instrument.measurement(
269 "FET:PDSC?",
270 """
271 Returns the Data Channel Measurements in JSON format.
272 """
273 )
274
275 fetch_peak = Instrument.measurement(
276 "FET:PEAK?",
277 """
278 Returns a pair of peak amplitude in current sweep.
279 """
280 )
281
282 fetch_rrm = Instrument.measurement(
283 "FET:RRM?",
284 """
285 Returns the Radio Resource Management in JSON format.
286 """
287 )
288
289 fetch_scan = Instrument.measurement(
290 "FET:SCAN?",
291 """
292 Returns the cell scanner measurements in JSON format
293 """
294 )
295
296 fetch_semask = Instrument.measurement(
297 "FET:SEM?",
298 """
299 This command returns the current Spectral Emission Mask measurement result.
300 """
301 )
302
303 fetch_ssb = Instrument.measurement(
304 "FET:SSB?",
305 """
306 Returns the SSB measurement
307 """
308 )
309
310 fetch_sync_evm = Instrument.measurement(
311 "FET:SYNC:EVM?",
312 """
313 Returns the Sync EVM measurement in JSON format.
314 """
315 )
316
317 fetch_sync_power = Instrument.measurement(
318 "FET:SYNC:POW?",
319 """
320 Returns the sync power measurements in JSON format
321 """
322 )
323
324 fetch_tae = Instrument.measurement(
325 "FET:TAE?",
326 """
327 Returns the Time Alignment Error in JSON format.
328 """
329 )
330
331 init_continuous = Instrument.control(
332 "INIT:CONT?", "INIT:CONT %g",
333 "Specified whether the sweep/measurement is triggered continuously",
334 values=ONOFF,
335 map_values=True,
336 validator=strict_discrete_set
337 )
338
339 init_spa_self = Instrument.measurement(
340 "INIT:SPA:SELF?",
341 docs="""
342 Perform a self-test and return the results.
343 """
344 )
345
346 active_state = Instrument.control(
347 "INST:ACT:STAT?", "INST:ACT:STAT %g",
348 docs="""
349 The "set" state indicates that the instrument is used by someone.
350 """,
351 values=ONOFF,
352 map_values=True,
353 validator=strict_discrete_set
354 )
355
356 meas_acpower = Instrument.measurement(
357 "MEAS:ACP?",
358 """
359 Sets the active measurement to adjacent channel power ratio, sets the default
360 measurement parameters, triggers a new measurement and returns the main channel
361 power, lower adjacent, upper adjacent, lower alternate and upper alternate channel
362 power results.
363 """
364 )
365
366 meas_power_all = Instrument.measurement(
367 "MEAS:CHP?",
368 """
369 Sets the active measurement to channel power, sets the default measurement
370 parameters, triggers a new measurement and returns the channel power and channel
371 power density results. It is a combination of the commands :CONFigure:CHPower;
372 :READ:CHPower?
373 """
374 )
375
376 meas_power = Instrument.measurement(
377 "MEASure:CHPower:CHPower?",
378 """
379 Sets the active measurement to channel power, sets the default measurement
380 parameters, triggers a new measurement and returns channel power as the result. It is a
381 combination of the commands :CONFigure:CHPower; :READ:CHPower:CHPower?
382 """
383 )
384
385 power_density = Instrument.measurement(
386 "MEASure:CHPower:DENSity?",
387 """
388 Sets the active measurement to channel power, sets the default measurement
389 parameters, triggers a new measurement and returns channel power density as the
390 result. It is a combination of the commands :CONFigure:CHPower;
391 :READ:CHPower:DENSity?
392 """
393 )
394
395 meas_emf_meter_clear_all = Instrument.setting(
396 "MEASure:EMF:METer:CLEar:ALL",
397 """
398 Clear the EMF measurement data of all samples.
399 Sampling state will be turned off if it was on.
400 """
401 )
402
403 meas_emf_meter_clear_sample = Instrument.setting(
404 "MEASure:EMF:METer:CLEar:SAMPle%g",
405 """
406 Clear the EMF measurement data for a specified sample number.
407 Sampling state will be turned off if the specified sample is currently active.
408 """,
409 validator=truncated_range,
410 values=[1, 16],
411 )
412
413 meas_emf_meter_sample = Instrument.control(
414 "MEASure:EMF:METer:SAMPle:STATe?", "MEASure:EMF:METer:SAMPle:STATe%g",
415 docs="""
416 Start or Stop applying the measurement results to the currently selected sample
417 """,
418 values=ONOFF,
419 map_values=True,
420 validator=strict_discrete_set
421 )
422
423 meas_int_power = Instrument.measurement(
424 "MEASure:INTerference:POWer?",
425 """
426 Sets the active measurement to interference finder, sets the default measurement
427 parameters, triggers a new measurement and returns integrated power as the result. It
428 is a combination of the commands :CONFigure:INTerference;
429 :READ:INTerference:POWer?
430 """
431 )
432
433 meas_iq_capture = Instrument.setting(
434 "MEASure:IQ:CAPTure",
435 """
436 This set command is used to start the IQ capture measurement.
437 """
438 )
439
440 meas_iq_capture_fail = Instrument.control(
441 "MEASure:IQ:CAPTure:FAIL?", "MEASure:IQ:CAPTure:FAIL %g",
442 """
443 Sets or queries whether the instrument will automatically save an IQ capture when
444 losing sync
445 """,
446 values=OFFFIRSTREPEAT
447 )
448
449 meas_ota_mapp = Instrument.measurement(
450 "MEASure:OTA:MAPPing?",
451 """
452 Sets the active measurement to OTA Coverage Mapping, sets the default measurement
453 parameters, triggers a new measurement, and returns the measured values.
454 """
455 )
456
457 meas_ota_run = Instrument.control(
458 "MEASure:OTA:MAPPing:RUN?", "MEASure:OTA:MAPPing:RUN %g",
459 """
460 Turn on/off OTA Coverage Mapping Data Collection. The instrument must be in
461 Coverage Mapping measurement for the command to be effective
462 """,
463 values=ONOFF,
464 map_values=True,
465 validator=strict_discrete_set
466 )
467
468 view_sense_modes = Instrument.measurement(
469 "MODE:CATalog?",
470 """
471 Returns a list of available modes for the Spa application. The response is a
472 comma-separated list of mode names. See command [:SENSe]:MODE for the mode name
473 specification.
474 """
475 )
476
477 sense_mode = Instrument.control(
478 "MODE?", ":MODE %g",
479 """
480 Set the operational mode of the Spa app.
481 """,
482 values=SPAMODES,
483 )
484
485 preamp = Instrument.control(
486 "POWer:RF:GAIN:STATe?", "POWer:RF:GAIN:STATe %s",
487 """
488 Sets the state of the preamp. Note that this may cause a change in the reference level
489 and/or attenuation.
490 """,
491 values=ONOFF,
492 map_values=True,
493 validator=strict_discrete_set
494 )
495
496 def init_sweep(self):
497 """
498 Initiate a sweep/measurement.
499 """
500 self.write("INIT")
501
502 def init_all_sweep(self):
503 """
504 Initiate all sweep/measurement.
505 """
506 self.write('INIT:ALL')
507
508 def abort(self):
509 """
510 Initiate a sweep/measurement.
511 """
512 self.write("ABOR")