Debian Codegraph @

pymeasure/instruments/fluke/fluke7341.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
26 from pymeasure.instruments.validators import strict_discrete_set, strict_range
27
28
29 class Fluke7341(Instrument):
30 """ Represents the compact constant temperature bath from Fluke.
31 """
32
33 def __init__(self, adapter, name="Fluke 7341", **kwargs):
34 kwargs.setdefault('timeout', 2000)
35 kwargs.setdefault('write_termination', '\r\n')
36 super().__init__(
37 adapter,
38 name,
39 includeSCPI=False,
40 asrl={'baud_rate': 2400},
41 **kwargs
42 )
43
44 def read(self):
45 """Read up to (excluding) `read_termination` or the whole read buffer.
46
47 Extract the value from the response string.
48
49 Responses are in the format "`type`: `value` `optional information`".
50 Optional information is for example the unit (degree centigrade or Fahrenheit).
51 """
52 return super().read().split(":")[-1]
53
54 set_point = Instrument.control("s", "s=%g",
55 """Control the temperature setpoint (float from -40 to 150 °C)
56 The unit is as defined in property :attr:`~.unit`.""",
57 validator=strict_range,
58 values=(-40, 150),
59 preprocess_reply=lambda x: x.split()[0],
60 )
61
62 unit = Instrument.control(
63 "u", "u=%s",
64 """Control the temperature unit: `c` for Celsius and `f` for Fahrenheit`.""",
65 validator=strict_discrete_set,
66 values=('c', 'f'),
67 )
68
69 temperature = Instrument.measurement("t",
70 """Measure the current bath temperature.
71 The unit is as defined in property :attr:`unit`.""",
72 preprocess_reply=lambda x: x.split()[0],
73 )
74
75 id = Instrument.measurement("*ver",
76 """Get the instrument model.""",
77 cast=str,
78 get_process=lambda x: f"Fluke,{x[0][4:]},NA,{x[1]}",
79 )