| 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 |
| 26 |
from pymeasure.instruments.anritsu import AnritsuMS9710C |
| 27 |
from pymeasure.instruments.validators import ( |
| 28 |
strict_discrete_set, |
| 29 |
truncated_discrete_set, |
| 30 |
truncated_range, |
| 31 |
) |
| 32 |
|
| 33 |
log = logging.getLogger(__name__) |
| 34 |
log.addHandler(logging.NullHandler()) |
| 35 |
|
| 36 |
|
| 37 |
class AnritsuMS9740A(AnritsuMS9710C): |
| 38 |
"""Anritsu MS9740A Optical Spectrum Analyzer.""" |
| 39 |
|
| 40 |
def __init__(self, adapter, name="Anritsu MS9740A Optical Spectrum Analyzer", **kwargs): |
| 41 |
"""Constructor.""" |
| 42 |
self.analysis_mode = None |
| 43 |
super().__init__( |
| 44 |
adapter, name, **kwargs) |
| 45 |
|
| 46 |
#################################### |
| 47 |
# Spectrum Parameters - Wavelength # |
| 48 |
#################################### |
| 49 |
|
| 50 |
resolution = Instrument.control( |
| 51 |
"RES?", "RES %s", "Control Resolution (nm)", |
| 52 |
validator=truncated_discrete_set, |
| 53 |
values=[0.03, 0.05, 0.07, 0.1, 0.2, 0.5, 1.0], |
| 54 |
) |
| 55 |
|
| 56 |
resolution_vbw = Instrument.control( |
| 57 |
"VBW?", "VBW %s", "Control Video Bandwidth Resolution", |
| 58 |
validator=strict_discrete_set, |
| 59 |
values=["1MHz", "100kHz", "10kHz", "2kHz", "1kHz", "200Hz", "100Hz", "10Hz"] |
| 60 |
) |
| 61 |
|
| 62 |
average_sweep = Instrument.control( |
| 63 |
"AVS?", "AVS %d", |
| 64 |
"""Control number of averages to make on a sweep (1-1000), |
| 65 |
with 1 being a single (non-averaged) sweep""", |
| 66 |
validator=truncated_range, values=[1, 1000] |
| 67 |
) |
| 68 |
|
| 69 |
sampling_points = Instrument.control( |
| 70 |
"MPT?", "MPT %d", "Control number of sampling points", |
| 71 |
validator=truncated_discrete_set, |
| 72 |
values=[51, 101, 251, 501, 1001, 2001, 5001, 10001, 20001, 50001], |
| 73 |
get_process=lambda v: int(v) |
| 74 |
) |
| 75 |
|
| 76 |
########################## |
| 77 |
# Data Memory Commands # |
| 78 |
########################## |
| 79 |
|
| 80 |
data_memory_select = Instrument.control( |
| 81 |
"TTP?", "TTP %s", |
| 82 |
"Control Memory Data Select.", |
| 83 |
validator=strict_discrete_set, |
| 84 |
values=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] |
| 85 |
) |
| 86 |
|
| 87 |
def repeat_sweep(self, n=20, delay=0.5): |
| 88 |
"""Perform a single sweep and wait for completion.""" |
| 89 |
log.debug("Performing a repeat Spectrum Sweep") |
| 90 |
self.clear() |
| 91 |
self.write('SRT') |
| 92 |
self.wait_for_sweep(n=n, delay=delay) |