Debian Codegraph @

pymeasure/instruments/novanta/fpu60.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 import logging
26 import re
27
28 from pymeasure.instruments import Instrument
29
30 log = logging.getLogger(__name__)
31 log.addHandler(logging.NullHandler())
32
33
34 class Fpu60(Instrument):
35 """Represents a fpu60 power supply unit for the finesse laser series by Laserquantum,
36 a Novanta company.
37
38 The instrument responds to every command sent.
39 """
40
41 def __init__(self, adapter, name="Laserquantum fpu60 power supply unit", **kwargs):
42 super().__init__(adapter,
43 name=name,
44 includeSCPI=False,
45 asrl={'baud_rate': 19200},
46 write_termination="\r",
47 read_termination="\r\n",
48 **kwargs)
49
50 interlock_enabled = Instrument.measurement(
51 "INTERLOCK?",
52 """Get the interlock enabled status (bool).""",
53 values={True: "ENABLED", False: "DISABLED"},
54 map_values=True,
55 )
56
57 emission_enabled = Instrument.measurement(
58 "STATUS?",
59 """Measure the emission status (bool).""",
60 values={True: "ENABLED", False: "DISABLED"},
61 map_values=True,
62 )
63
64 power = Instrument.measurement(
65 "POWER?",
66 """Measure current output power in Watts (float).""",
67 # Response is in form:" ##.###W"
68 preprocess_reply=lambda r: r.replace("W", ""),
69 )
70
71 power_setpoint = Instrument.control(
72 "SETPOWER?", "POWER=%.3f",
73 """Control the output power setpoint in Watts (float).""",
74 # Getter response is in form:" ##.###W"
75 preprocess_reply=lambda r: r.replace("W", ""),
76 check_set_errors=True,
77 )
78
79 shutter_open = Instrument.control(
80 "SHUTTER?", "SHUTTER %s",
81 """Control whether the shutter is open (bool).""",
82 # set values: OPEN, CLOSE
83 # get response: "SHUTTER OPEN", "SHUTTER CLOSED"
84 values={True: "OPEN", False: "CLOSE"},
85 map_values=True,
86 preprocess_reply=lambda r: r.replace("SHUTTER ", "").replace("D", ""),
87 check_set_errors=True,
88 )
89
90 current = Instrument.measurement(
91 "CURRENT?",
92 """Measure the diode current in percent (float).""",
93 # Response: " ###.#%"
94 preprocess_reply=lambda r: r.replace("%", ""),
95 )
96
97 psu_temperature = Instrument.measurement(
98 "PSUTEMP?",
99 """Measure the power supply unit temperature in °C (float).""",
100 # Response: " ##.###C"
101 preprocess_reply=lambda r: r.replace("C", ""),
102 )
103
104 head_temperature = Instrument.measurement(
105 "HTEMP?",
106 """Measure the laser head temperature in °C (float).""",
107 # Response: " ##.###C"
108 preprocess_reply=lambda r: r.replace("C", ""),
109 )
110
111 serial_number = Instrument.measurement("SERIAL?", """Get the serial number (str).""", cast=str)
112
113 software_version = Instrument.measurement("SOFTVER?", """Get the software version (str).""",
114 cast=str)
115
116 def get_operation_times(self):
117 """Get the operation times in minutes as a dictionary."""
118 self.write("TIMERS?")
119 timers = {}
120 timers['psu'] = int(re.search(r"\d+", self.read()).group())
121 timers['laser'] = int(re.search(r"\d+", self.read()).group())
122 timers['laser_above_1A'] = int(re.search(r"\d+", self.read()).group())
123 self.read() # an empty line is at the end.
124 return timers
125
126 def disable_emission(self):
127 """Disable emission and unlock the button afterwards.
128
129 You have to press the physical button to enable emission again.
130 """
131 self.ask("LASER=OFF")
132 self.ask("LASER=ON") # unlocks emission button, does NOT start emission!
133
134 def check_set_errors(self):
135 """Check for errors after having set a property and log them.
136
137 Called if :code:`check_set_errors=True` is set for that property.
138
139 :return: List of error entries.
140 """
141 response = self.read()
142 return [] if response == "" else [response]