35 """Omicron DeepStar laser.
37 Omicron LDM lasers can be bought with and without the LDM.APC
38 power monitoring option (light pick-off). If this option is not
39 available, the `power` attribute will return the set power value
40 instead of the actual power value.
44 def __init__(self, com, baud=9600, timeout=2.0, **kwargs):
45 super().__init__(**kwargs)
50 stopbits=serial.STOPBITS_ONE,
51 bytesize=serial.EIGHTBITS,
52 parity=serial.PARITY_NONE,
58 _logger.info(
"Current laser state: [%s]", response.decode())
62 if not option_codes.startswith(b
"OC "):
64 "Failed to get option codes '%s'" % option_codes.decode()
66 if option_codes[9:12] == b
"AP1":
70 "Laser is missing APC option. Will return set"
71 " power instead of actual power"
80 command = command.ljust(14) + b
"\r\n"
86 @microscope.abc.SerialDeviceMixin.lock_comms
95 @microscope.abc.SerialDeviceMixin.lock_comms
97 _logger.info(
"Turning laser ON.")
103 (b
"LON",
"Enable response: [%s]"),
104 (b
"L2",
"L2 response: [%s]"),
105 (b
"IPO",
"Enable-internal peak power response: [%s]"),
106 (b
"MF",
"MF response [%s]"),
107 (b
"A2DF",
"A2DF response [%s]"),
111 _logger.debug(msg, response.decode())
118 "Failed to turn on. Current status: [%s]", response.decode()
127 @microscope.abc.SerialDeviceMixin.lock_comms
129 _logger.info(
"Turning laser OFF.")
135 @microscope.abc.SerialDeviceMixin.lock_comms
139 _logger.debug(
"Are we on? [%s]", response.decode())
140 return response == b
"S2"
142 @microscope.abc.SerialDeviceMixin.lock_comms
144 _logger.debug(
"level=%d", power)
145 power_int = int(power * 0xFFF)
146 _logger.debug(
"power=%d", power_int)
147 strPower =
"PP%03X" % power_int
148 _logger.debug(
"power level=%s", strPower)
151 _logger.debug(
"Power response [%s]", response.decode())
165 if not answer.startswith(query):
167 "failed to read power from '%s'" % answer.decode()
170 level = int(answer[len(query) :], 16)
171 return float(level) / float(scale)
174 def trigger_type(self) -> microscope.TriggerType:
175 return microscope.TriggerType.HIGH
178 def trigger_mode(self) -> microscope.TriggerMode:
179 return microscope.TriggerMode.BULB
184 if ttype
is not microscope.TriggerType.HIGH:
186 "the only trigger type supported is 'high'"
188 if tmode
is not microscope.TriggerMode.BULB:
190 "the only trigger mode supported is 'bulb'"
195 "trigger does not make sense in trigger mode bulb, only enable"