Debian Codegraph @

pymeasure/instruments/tektronix/tds2000.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
25 from pymeasure.instruments import Instrument, SCPIUnknownMixin
26
27
28 class TDS2000(SCPIUnknownMixin, Instrument):
29 """ Represents the Tektronix TDS 2000 Oscilloscope
30 and provides a high-level for interacting with the instrument
31 """
32
33 class Measurement:
34
35 SOURCE_VALUES = ['CH1', 'CH2', 'MATH']
36
37 TYPE_VALUES = [
38 'FREQ', 'MEAN', 'PERI', 'PHA', 'PK2', 'CRM',
39 'MINI', 'MAXI', 'RIS', 'FALL', 'PWI', 'NWI'
40 ]
41
42 UNIT_VALUES = ['V', 's', 'Hz']
43
44 def __init__(self, parent, preamble="MEASU:IMM:"):
45 self.parent = parent
46 self.preamble = preamble
47
48 @property
49 def value(self):
50 return self.parent.values("%sVAL?" % self.preamble)
51
52 @property
53 def source(self):
54 return self.parent.ask("%sSOU?" % self.preamble).strip()
55
56 @source.setter
57 def source(self, value):
58 if value in TDS2000.Measurement.SOURCE_VALUES:
59 self.parent.write(f"{self.preamble}SOU {value}")
60 else:
61 raise ValueError("Invalid source ('{}') provided to {}".format(
62 self.parent, value))
63
64 @property
65 def type(self):
66 return self.parent.ask("%sTYP?" % self.preamble).strip()
67
68 @type.setter
69 def type(self, value):
70 if value in TDS2000.Measurement.TYPE_VALUES:
71 self.parent.write(f"{self.preamble}TYP {value}")
72 else:
73 raise ValueError("Invalid type ('{}') provided to {}".format(
74 self.parent, value))
75
76 @property
77 def unit(self):
78 return self.parent.ask("%sUNI?" % self.preamble).strip()
79
80 @unit.setter
81 def unit(self, value):
82 if value in TDS2000.Measurement.UNIT_VALUES:
83 self.parent.write(f"{self.preamble}UNI {value}")
84 else:
85 raise ValueError("Invalid unit ('{}') provided to {}".format(
86 self.parent, value))
87
88 def __init__(self, adapter, name="Tektronix TDS 2000 Oscilloscope", **kwargs):
89 super().__init__(
90 adapter,
91 name,
92 **kwargs
93 )
94 self.measurement = TDS2000.Measurement(self)