Debian Codegraph @

pymeasure/instruments/teledyne/teledyneMAUI.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.instruments import Instrument
26 from pymeasure.instruments.teledyne.teledyne_oscilloscope import TeledyneOscilloscope, \
27 TeledyneOscilloscopeChannel, _results_list_to_dict
28
29
30 class TeledyneMAUIChannel(TeledyneOscilloscopeChannel):
31 """Base class for channels on a :class:`TeledyneMAUI` device."""
32
33 # Probably for historic reasons, "20MHZ" is registered as "ON"
34 BANDWIDTH_LIMITS = ["OFF", "ON", "200MHZ"]
35
36 TRIGGER_SLOPES = {"negative": "NEG", "positive": "POS"}
37
38 # Reset listed values for existing commands:
39 bwlimit_values = BANDWIDTH_LIMITS
40
41 def autoscale(self):
42 """Perform auto-setup command for channel."""
43 self.write("AUTO_SETUP FIND")
44
45 # noinspection PyIncorrectDocstring
46 def setup(self, **kwargs):
47 """Setup channel. Unspecified settings are not modified.
48
49 Modifying values such as probe attenuation will modify offset, range, etc. Refer to
50 oscilloscope documentation and make multiple consecutive calls to setup() if needed.
51 See property descriptions for more information.
52
53 :param bwlimit:
54 :param coupling:
55 :param display:
56 :param offset:
57 :param probe_attenuation:
58 :param scale:
59 :param trigger_coupling:
60 :param trigger_level:
61 :param trigger_slope:
62 """
63 super().setup(**kwargs)
64
65 @property
66 def current_configuration(self):
67 """Get channel configuration as a dict containing the following keys:
68
69 - "channel": channel number (int)
70 - "attenuation": probe attenuation (float)
71 - "bandwidth_limit": bandwidth limiting, parsed for this channel (str)
72 - "coupling": "ac 1M", "dc 1M", "ground" coupling (str)
73 - "offset": vertical offset (float)
74 - "display": currently displayed (bool)
75 - "volts_div": vertical divisions (float)
76 - "trigger_coupling": trigger coupling can be "dc" "ac" "highpass" "lowpass" (str)
77 - "trigger_level": trigger level (float)
78 - "trigger_slope": trigger slope can be "negative" "positive" "window" (str)
79 """
80 ch_setup = {
81 "channel": self.id,
82 "attenuation": self.probe_attenuation,
83 "bandwidth_limit": self.bwlimit[f"C{self.id}"],
84 "coupling": self.coupling,
85 "offset": self.offset,
86 "display": self.display,
87 "volts_div": self.scale,
88 "trigger_coupling": self.trigger_coupling,
89 "trigger_level": self.trigger_level,
90 "trigger_slope": self.trigger_slope
91 }
92 return ch_setup
93
94
95 class TeledyneMAUI(TeledyneOscilloscope):
96 """A base class for the MAUI-type of Teledyne oscilloscopes.
97
98 This base class works out of the box. Some properties, especially the number of channels,
99 might have to be adjusted to the actual device.
100
101 The manual detailing the API is "MAUI Oscilloscopes Remote Control and Automation Manual"
102 (`link`_).
103
104 .. _link: https://cdn.teledynelecroy.com/files/manuals/
105 maui-remote-control-automation_27jul22.pdf
106 """
107
108 ch_1 = Instrument.ChannelCreator(TeledyneMAUIChannel, 1)
109
110 ch_2 = Instrument.ChannelCreator(TeledyneMAUIChannel, 2)
111
112 ch_3 = Instrument.ChannelCreator(TeledyneMAUIChannel, 3)
113
114 ch_4 = Instrument.ChannelCreator(TeledyneMAUIChannel, 4)
115
116 # Change listed values for existing commands:
117 bwlimit_values = TeledyneMAUIChannel.BANDWIDTH_LIMITS
118
119 ###############
120 # Trigger #
121 ###############
122
123 @property
124 def trigger(self):
125 """Get trigger setup as a dict containing the following keys:
126
127 - "mode": trigger sweep mode [auto, normal, single, stop]
128 - "trigger_type": condition that will trigger the acquisition of waveforms
129 [edge,slew,glit,intv,runt,drop]
130 - "source": trigger source [c1,c2,c3,c4]
131 - "hold_type": hold type (refer to page 172 of programing guide)
132 - "hold_value1": hold value1 (refer to page 172 of programing guide)
133 - "hold_value2": hold value2 (refer to page 172 of programing guide)
134 - "coupling": input coupling for the selected trigger sources
135 - "level": trigger level voltage for the active trigger source
136 - "slope": trigger slope of the specified trigger source
137
138 """
139 trigger_select = self.trigger_select
140 ch = self.ch(trigger_select[1])
141 tb_setup = {
142 "mode": self.trigger_mode,
143 "trigger_type": trigger_select[0],
144 "source": trigger_select[1],
145 "hold_type": trigger_select[2],
146 "hold_value1": trigger_select[3] if len(trigger_select) >= 4 else None,
147 "hold_value2": trigger_select[4] if len(trigger_select) >= 5 else None,
148 "coupling": ch.trigger_coupling,
149 "level": ch.trigger_level,
150 "slope": ch.trigger_slope
151 }
152 return tb_setup
153
154 def force_trigger(self):
155 """Make one acquisition if in active trigger mode.
156
157 No action is taken if the device is in 'Stop trigger mode'.
158 """
159 # Method instead of property since no reply is sent
160 self.write("FRTR")
161
162 #################
163 # Download data #
164 #################
165
166 hardcopy_setup_current = Instrument.measurement(
167 "HCSU?",
168 """Get current hardcopy config.""",
169 get_process=_results_list_to_dict,
170 )
171
172 def hardcopy_setup(self, **kwargs):
173 """Specify hardcopy settings.
174
175 Connect a printer or define how to save to file. Set any or all
176 of the following parameters.
177
178 :param device: {BMP, JPEG, PNG, TIFF}
179 :param format: {PORTRAIT, LANDSCAPE}
180 :param background: {Std, Print, BW}
181 :param destination: {PRINTER, CLIPBOARD, EMAIL, FILE, REMOTE}
182 :param area: {GRIDAREAONLY, DSOWINDOW, FULLSCREEN}
183 :param directory: Any legal DOS path, for FILE mode only
184 :param filename: Filename string, no extension, for FILE mode only
185 :param printername: Valid printer name, for PRINTER mode only
186 :param portname: {GPIB, NET}
187 """
188 keys = {
189 "device": "DEV",
190 "format": "FORMAT",
191 "background": "BCKG",
192 "destination": "DEST",
193 "area": "AREA",
194 "directory": "DIR",
195 "filename": "FILE",
196 "printername": "PRINTER",
197 "portname": "PORT",
198 }
199
200 arg_strs = [keys[key] + "," + value for key, value in kwargs.items()]
201
202 self.write("HCSU " + ",".join(arg_strs))
203
204 def download_image(self, **kwargs):
205 """Get a BMP image of oscilloscope screen in bytearray of specified file format.
206
207 The hardcopy destination is set to "REMOTE" by default.
208
209 :param \\**kwargs: Keyword arguments for :meth:`hardcopy_setup`
210 """
211 kwargs.setdefault("destination", "REMOTE")
212 self.hardcopy_setup(**kwargs)
213 return super().download_image()