Debian Codegraph @

pymeasure/instruments/mksinst/mks974b.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 Channel, Instrument
26 from pymeasure.instruments.validators import strict_discrete_set
27
28 from .mksinst import MKSInstrument, RelayChannel
29
30
31 try:
32 from enum import StrEnum
33 except ImportError:
34 from enum import Enum
35
36 class StrEnum(str, Enum):
37 """Until StrEnum is broadly available from the standard library"""
38 # Python>3.10 remove it.
39
40
41 class Unit(StrEnum):
42 Torr = "TORR"
43 mbar = "MBAR"
44 Pa = "PASCAL"
45
46
47 class Relay(RelayChannel):
48
49 enabled = Channel.control(
50 "EN{ch}?", "EN{ch}!%s",
51 """Control the assigned input channel or disable the setpoint relay.""",
52 validator=strict_discrete_set,
53 map_values=True,
54 values={False: "OFF",
55 True: "ON",
56 "combined": "CMB",
57 "pirani": "PIR",
58 "piezo": "PZ",
59 "cold cathode": "CC",
60 },
61 check_set_errors=True,
62 )
63
64
65 class MKS974B(MKSInstrument):
66 """ MKS 974B vacuum pressure transducer
67
68 Connection to the device is made through an RS232/RS485 serial connection.
69
70 The 974B pressure transducer is a pressure gauge combining a cold cathode
71 ionization current measurement, a Pirani sensor, and a Piezo sensor to
72 cover a large pressure range. It optionally includes up to three mechanical
73 relays which can be energized based on the measured pressure value.
74
75 :param adapter: pyvisa resource name of the instrument or adapter instance
76 :param string name: The name of the instrument.
77 :param address: device address included in every message to the instrument
78 (default=253)
79 :param kwargs: Any valid key-word argument for :class:`Instrument`
80 """
81
82 relay_1 = Instrument.ChannelCreator(Relay, 1)
83
84 relay_2 = Instrument.ChannelCreator(Relay, 2)
85
86 relay_3 = Instrument.ChannelCreator(Relay, 3)
87
88 def __init__(self, adapter, name="MKS 974B vacuum pressure transducer", address=253, **kwargs):
89 super().__init__(
90 adapter,
91 name,
92 address=address,
93 **kwargs
94 )
95
96 def id(self):
97 """ Get the identification of the instrument. """
98 return f"{self.manufacturer}{self.model} {self.device_type} ({self.serial_number})"
99
100 serial_number = Instrument.measurement(
101 "SN?", """Get the serial number of the instrument""",
102 cast=str,
103 )
104
105 hardware_version = Instrument.measurement(
106 "HV?", """Get the hardware version of the instrument""",
107 cast=str,
108 )
109
110 firmware_version = Instrument.measurement(
111 "FV?", """Get the firmware version of the instrument""",
112 cast=str,
113 )
114
115 device_type = Instrument.measurement(
116 "DT?", """Get the device type""",
117 cast=str,
118 )
119
120 manufacturer = Instrument.measurement(
121 "MF?", """Get the manufacturer name""",
122 cast=str,
123 )
124
125 model = Instrument.measurement(
126 "MD?", """Get the transducer model number""",
127 cast=str,
128 )
129
130 part_number = Instrument.measurement(
131 "MD?", """Get the transducer part number""",
132 cast=str,
133 )
134
135 operation_hours = Instrument.measurement(
136 "TIM?", """Get the operation hours of the instrument""",
137 cast=int,
138 )
139
140 temperature = Instrument.measurement(
141 "TEM?", """Get the MicroPirani sensor temperature""",
142 )
143
144 status = Channel.measurement(
145 "T?",
146 """Get transducer status""",
147 map_values=True,
148 values={"Ok": "O",
149 "MicroPirani failure": "M",
150 "Cold Cathode failure": "C",
151 "Piezo sensor failure": "Z",
152 "pressure dose setpoint exceeded": "R",
153 "Cold Cathode On": "G",
154 },
155 )
156
157 pirani_pressure = Instrument.measurement(
158 "PR1?", """Get MicroPirani sensor pressure""",
159 )
160
161 piezo_pressure = Instrument.measurement(
162 "PR2?", """Get Piezo differential sensor pressure""",
163 )
164
165 pressure = Instrument.measurement(
166 "PR4?", """Get combined pressure reading""",
167 )
168
169 coldcathode_pressure = Instrument.measurement(
170 "PR5?", """ Get Cold Cathode sensor pressure""",
171 )
172
173 unit = Instrument.control(
174 "U?", "U!%s",
175 """Control pressure unit used for all pressure readings from the instrument.
176
177 Allowed units are Unit.Torr, Unit.mbar, Unit.Pa.""",
178 validator=strict_discrete_set,
179 map_values=True,
180 values={u: u.value for u in Unit},
181 check_set_errors=True,
182 )
183
184 user_tag = Instrument.control(
185 "UT?", "UT!%s",
186 """Control the user programmable tag""",
187 cast=str,
188 check_set_errors=True,
189 )
190
191 switch_enabled = Instrument.control(
192 "SW?", "SW!%s",
193 """Control the user switch to prevent accidental execution of adjustments""",
194 validator=strict_discrete_set,
195 map_values=True,
196 values={True: "ON",
197 False: "OFF",
198 },
199 check_set_errors=True,
200 )