31_logger = logging.getLogger(__name__)
39 """Coherent Sapphire laser.
41 The Sapphire is a diode-pumped solid-state laser
and only supports
42 `TriggerMode.SOFTWARE`.
55 def __init__(self, com=None, baud=19200, timeout=0.5, **kwargs):
59 super().__init__(**kwargs)
64 stopbits=serial.STOPBITS_ONE,
65 bytesize=serial.EIGHTBITS,
66 parity=serial.PARITY_NONE,
77 headID = int(float(self.
send(b
"?hid")))
78 _logger.info(
"Sapphire laser serial number: [%s]", headID)
85 def _write(self, command):
86 count = super()._write(command)
94 """Send command and retrieve response."""
98 @microscope.abc.SerialDeviceMixin.lock_comms
103 def flush_buffer(self):
108 @microscope.abc.SerialDeviceMixin.lock_comms
112 status_code = self.
send(b
"?sta")
121 (b
"?l",
"Ligh Emission on?"),
122 (b
"?t",
"TEC Servo on?"),
123 (b
"?k",
"Key Switch on?"),
124 (b
"?sp",
"Target power:"),
125 (b
"?p",
"Measured power:"),
126 (b
"?hh",
"Head operating hours:"),
128 result.append(stat +
" " + self.
send(cmd).decode())
134 faults += b
" " + response
137 result.append(faults.decode())
140 @microscope.abc.SerialDeviceMixin.lock_comms
141 def _do_shutdown(self) -> None:
147 @microscope.abc.SerialDeviceMixin.lock_comms
148 def initialize(self):
152 @microscope.abc.SerialDeviceMixin.lock_comms
153 def _do_enable(self):
154 _logger.info(
"Turning laser ON.")
156 response = self.
send(b
"l=1")
157 _logger.info(
"l=1: [%s]", response.decode())
167 _logger.error(
"Failed to turn on. Current status:\r\n")
172 @microscope.abc.SerialDeviceMixin.lock_comms
174 _logger.info(
"Turning laser OFF.")
178 @microscope.abc.SerialDeviceMixin.lock_comms
180 return self.
send(b
"?l") == b
"1"
182 @microscope.abc.SerialDeviceMixin.lock_comms
183 def _get_power_mw(self):
184 return float(self.
send(b
"?p"))
186 @microscope.abc.SerialDeviceMixin.lock_comms
187 def _set_power_mw(self, mW):
189 _logger.info(
"Setting laser power to %s mW.", mW_str)
192 return self.
send(b
"p=%s" % mW_str.encode())
194 def _do_set_power(self, power: float) ->
None:
201 def _do_get_power(self) -> float:
typing.List[str] get_status(self)
int _write(self, bytes command)
def _set_power_mw(self, mW)
def _write(self, command)