29_logger = logging.getLogger(__name__)
39 The cobolt lasers are diode pumped lasers and only supports
40 `TriggerMode.SOFTWARE` (this
is probably
not completely true, some
41 cobolt lasers are probably
not diode pumped
and those should be
42 able to support other trigger modes, but we only got access to the
47 def __init__(self, com=None, baud=115200, timeout=0.1, **kwargs):
48 super().__init__(**kwargs)
53 stopbits=serial.STOPBITS_ONE,
54 bytesize=serial.EIGHTBITS,
55 parity=serial.PARITY_NONE,
58 response = self.
send(b
"sn?")
59 _logger.info(
"Cobolt laser serial number: [%s]", response.decode())
62 response = self.
send(b
"@cobas 0")
63 _logger.info(
"Response to @cobas 0 [%s]", response.decode())
70 """Send command and retrieve response."""
76 if not command.endswith(b
"?"):
78 elif len(response) > 0:
82 @microscope.abc.SerialDeviceMixin.lock_comms
87 @microscope.abc.SerialDeviceMixin.lock_comms
91 (b
"l?",
"Emission on?"),
92 (b
"p?",
"Target power:"),
93 (b
"pa?",
"Measured power:"),
95 (b
"hrs?",
"Head operating hours:"),
97 response = self.
send(cmd)
98 result.append(stat +
" " + response.decode())
101 @microscope.abc.SerialDeviceMixin.lock_comms
102 def _do_shutdown(self) -> None:
109 @microscope.abc.SerialDeviceMixin.lock_comms
110 def initialize(self):
113 self.
send(b
"@cobasdr 0")
118 @microscope.abc.SerialDeviceMixin.lock_comms
119 def _do_enable(self):
120 _logger.info(
"Turning laser ON.")
122 response = self.
send(b
"l1")
123 _logger.info(
"l1: [%s]", response.decode())
127 _logger.error(
"Failed to turn on. Current status:\r\n")
133 @microscope.abc.SerialDeviceMixin.lock_comms
135 _logger.info(
"Turning laser OFF.")
136 return self.
send(b
"l0").decode()
139 @microscope.abc.SerialDeviceMixin.lock_comms
141 response = self.
send(b
"l?")
142 return response == b
"1"
144 @microscope.abc.SerialDeviceMixin.lock_comms
145 def _get_power_mw(self) -> float:
151 response = self.
send(b
"pa?")
154 return 1000 * float(response)
156 @microscope.abc.SerialDeviceMixin.lock_comms
157 def _set_power_mw(self, mW: float) ->
None:
160 W_str =
"%.4f" % (mW / 1000.0)
161 _logger.info(
"Setting laser power to %s W.", W_str)
162 return self.
send(b
"@cobasp " + W_str.encode())
164 def _do_set_power(self, power: float) ->
None:
167 def _do_get_power(self) -> float:
typing.List[str] get_status(self)
int _write(self, bytes command)
float _get_power_mw(self)
None _set_power_mw(self, float mW)