BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
microscope.lights.obis.ObisLaser Class Reference
Inheritance diagram for microscope.lights.obis.ObisLaser:
microscope.abc.SerialDeviceMixin microscope.abc.LightSource microscope.abc.TriggerTargetMixin microscope.abc.Device

Public Member Functions

None __init__ (self, com, baud=115200, timeout=0.5, **kwargs)
 
 get_status (self)
 
 initialize (self)
 
 get_is_on (self)
 
microscope.TriggerType trigger_type (self)
 
microscope.TriggerMode trigger_mode (self)
 
None set_trigger (self, microscope.TriggerType ttype, microscope.TriggerMode tmode)
 
- Public Member Functions inherited from microscope.abc.SerialDeviceMixin
- Public Member Functions inherited from microscope.abc.LightSource
float power (self)
 
None power (self, float power)
 
float get_set_power (self)
 
- Public Member Functions inherited from microscope.abc.TriggerTargetMixin
None trigger (self)
 
- Public Member Functions inherited from microscope.abc.Device
None __del__ (self)
 
bool get_is_enabled (self)
 
None disable (self)
 
None enable (self)
 
None shutdown (self)
 
None add_setting (self, name, dtype, get_func, set_func, values, typing.Optional[typing.Callable[[], bool]] readonly=None)
 
 get_setting (self, str name)
 
 get_all_settings (self)
 
None set_setting (self, str name, value)
 
 describe_setting (self, str name)
 
 describe_settings (self)
 
 update_settings (self, incoming, bool init=False)
 

Public Attributes

 connection
 
- Public Attributes inherited from microscope.abc.SerialDeviceMixin
 connection = None
 
- Public Attributes inherited from microscope.abc.Device
bool enabled = False
 

Protected Member Functions

 _write (self, command)
 
 _readline (self)
 
 _flush_handshake (self)
 
 _do_enable (self)
 
None _do_shutdown (self)
 
 _do_disable (self)
 
 _get_power_mw (self)
 
 _set_power_mw (self, mw)
 
None _do_set_power (self, float power)
 
float _do_get_power (self)
 
None _do_trigger (self)
 
- Protected Member Functions inherited from microscope.abc.SerialDeviceMixin
- Protected Member Functions inherited from microscope.abc.LightSource
- Protected Member Functions inherited from microscope.abc.TriggerTargetMixin
- Protected Member Functions inherited from microscope.abc.Device

Protected Attributes

float _max_power_mw = float(response) * 1000.0
 
- Protected Attributes inherited from microscope.abc.SerialDeviceMixin
 _comms_lock = threading.RLock()
 
- Protected Attributes inherited from microscope.abc.LightSource
float _set_point = 0.0
 
- Protected Attributes inherited from microscope.abc.Device
dict _settings = {}
 

Additional Inherited Members

- Static Public Member Functions inherited from microscope.abc.SerialDeviceMixin
 lock_comms (func)
 

Detailed Description

Definition at line 33 of file obis.py.

Constructor & Destructor Documentation

◆ __init__()

None microscope.lights.obis.ObisLaser.__init__ ( self,
com,
baud = 115200,
timeout = 0.5,
** kwargs )

Reimplemented from microscope.abc.SerialDeviceMixin.

Definition at line 34 of file obis.py.

34 def __init__(self, com, baud=115200, timeout=0.5, **kwargs) -> None:
35 super().__init__(**kwargs)
36 self.connection = serial.Serial(
37 port=com,
38 baudrate=baud,
39 timeout=timeout,
40 stopbits=serial.STOPBITS_ONE,
41 bytesize=serial.EIGHTBITS,
42 parity=serial.PARITY_NONE,
43 )
44 # Start a logger.
45 self._write(b"SYSTem:INFormation:MODel?")
46 response = self._readline()
47 _logger.info("OBIS laser model: [%s]", response.decode())
48 self._write(b"SYSTem:INFormation:SNUMber?")
49 response = self._readline()
50 _logger.info("OBIS laser serial number: [%s]", response.decode())
51 self._write(b"SYSTem:CDRH?")
52 response = self._readline()
53 _logger.info("CDRH safety: [%s]", response.decode())
54 self._write(b"SOURce:TEMPerature:APRobe?")
55 response = self._readline()
56 _logger.info("TEC temperature control: [%s]", response.decode())
57 self._write(b"*TST?")
58 response = self._readline()
59 _logger.info("Self test procedure: [%s]", response.decode())
60
61 # We need to ensure that autostart is disabled so that we can
62 # switch emission on/off remotely.
63 self._write(b"SYSTem:AUTostart?")
64 response = self._readline()
65 _logger.info("Response to Autostart: [%s]", response.decode())
66
67 self._write(b"SOURce:POWer:LIMit:HIGH?")
68 response = self._readline()
69 _logger.info("Max intensity in watts: [%s]", response.decode())
70 self._max_power_mw = float(response) * 1000.0
71
72 self.initialize()
73

Member Function Documentation

◆ _do_disable()

microscope.lights.obis.ObisLaser._do_disable ( self)
protected
Turn the laser OFF. Return True if we succeeded, False otherwise.

Reimplemented from microscope.abc.Device.

Definition at line 152 of file obis.py.

152 def _do_disable(self):
153 """Turn the laser OFF. Return True if we succeeded, False otherwise."""
154 _logger.info("Turning laser OFF.")
155 # Turning LASER OFF
156 self._write(b"SOURce:AM:STATe OFF")
157 self._flush_handshake()
158
159 if self.get_is_on():
160 _logger.error("Failed to turn OFF. Current status:\r\n")
161 _logger.error(self.get_status())
162 return False
163 return True
164

◆ _do_enable()

microscope.lights.obis.ObisLaser._do_enable ( self)
protected
Turn the laser ON. Return True if we succeeded, False otherwise.

Reimplemented from microscope.abc.Device.

Definition at line 109 of file obis.py.

109 def _do_enable(self):
110 """Turn the laser ON. Return True if we succeeded, False otherwise."""
111 _logger.info("Turning laser ON.")
112 # Exiting Sleep Mode.
113 self._write(b"SOURce:TEMPerature:APRobe ON")
114 self._flush_handshake()
115 # Turn on emission.
116 self._write(b"SOURce:AM:STATe ON")
117 self._flush_handshake()
118 self._write(b"SOURce:AM:STATe?")
119 response = self._readline()
120 _logger.info("SOURce:AM:STATe? [%s]", response.decode())
121
122 if not self.get_is_on():
123 # Something went wrong.
124 _logger.error("Failed to turn ON. Current status:\r\n")
125 _logger.error(self.get_status())
126 return False
127 return True
128

◆ _do_get_power()

float microscope.lights.obis.ObisLaser._do_get_power ( self)
protected
Internal function that actually returns the light source power.

Reimplemented from microscope.abc.LightSource.

Definition at line 191 of file obis.py.

191 def _do_get_power(self) -> float:
192 return self._get_power_mw() / self._max_power_mw
193

◆ _do_set_power()

None microscope.lights.obis.ObisLaser._do_set_power ( self,
float power )
protected
Internal function that actually sets the light source power.

This function will be called by the `power` attribute setter
after clipping the argument to the [0, 1] interval.

Reimplemented from microscope.abc.LightSource.

Definition at line 188 of file obis.py.

188 def _do_set_power(self, power: float) -> None:
189 self._set_power_mw(power * self._max_power_mw)
190

◆ _do_shutdown()

None microscope.lights.obis.ObisLaser._do_shutdown ( self)
protected
Private method - actual shutdown of the device.

Users should be calling :meth:`shutdown` and not this method.
Concrete implementations should implement this method instead
of `shutdown`.

Reimplemented from microscope.abc.Device.

Definition at line 129 of file obis.py.

129 def _do_shutdown(self) -> None:
130 self.disable()
131 # We set the power to a safe level
132 self._set_power_mw(2)
133 # We want it back into direct control mode.
134 self._write(b"SOURce:AM:INTernal CWP")
135 self._flush_handshake()
136
137 # Going into Sleep mode
138 self._write(b"SOURce:TEMPerature:APRobe OFF")
139 self._flush_handshake()
140

◆ _do_trigger()

None microscope.lights.obis.ObisLaser._do_trigger ( self)
protected
Actual trigger of the device.

Classes implementing this interface should implement this
method instead of `trigger`.

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 214 of file obis.py.

214 def _do_trigger(self) -> None:
216 "trigger does not make sense in trigger mode bulb, only enable"
217 )

◆ _flush_handshake()

microscope.lights.obis.ObisLaser._flush_handshake ( self)
protected

Definition at line 90 of file obis.py.

90 def _flush_handshake(self):
91 self.connection.readline()
92

◆ _get_power_mw()

microscope.lights.obis.ObisLaser._get_power_mw ( self)
protected

Definition at line 174 of file obis.py.

174 def _get_power_mw(self):
175 if not self.get_is_on():
176 return 0.0
177 self._write(b"SOURce:POWer:LEVel?")
178 response = self._readline()
179 return float(response.decode()) * 1000.0
180

◆ _readline()

microscope.lights.obis.ObisLaser._readline ( self)
protected
Read a line from connection without leading and trailing whitespace.
We override from SerialDeviceMixin

Reimplemented from microscope.abc.SerialDeviceMixin.

Definition at line 79 of file obis.py.

79 def _readline(self):
80 """Read a line from connection without leading and trailing whitespace.
81 We override from SerialDeviceMixin
82 """
83 response = self.connection.readline().strip()
84 if self.connection.readline().strip() != b"OK":
86 "Did not get a proper answer from the laser serial comm."
87 )
88 return response
89

◆ _set_power_mw()

microscope.lights.obis.ObisLaser._set_power_mw ( self,
mw )
protected

Definition at line 182 of file obis.py.

182 def _set_power_mw(self, mw):
183 power_w = mw / 1000.0
184 _logger.info("Setting laser power to %.7sW", power_w)
185 self._write(b"SOURce:POWer:LEVel:IMMediate:AMPLitude %.5f" % power_w)
186 self._flush_handshake()
187

◆ _write()

microscope.lights.obis.ObisLaser._write ( self,
command )
protected
Send a command.

Reimplemented from microscope.abc.SerialDeviceMixin.

Definition at line 74 of file obis.py.

74 def _write(self, command):
75 """Send a command."""
76 response = self.connection.write(command + b"\r\n")
77 return response
78

◆ get_is_on()

microscope.lights.obis.ObisLaser.get_is_on ( self)
Return True if the laser is currently able to produce light.

Reimplemented from microscope.abc.LightSource.

Definition at line 166 of file obis.py.

166 def get_is_on(self):
167 """Return True if the laser is currently able to produce light."""
168 self._write(b"SOURce:AM:STATe?")
169 response = self._readline()
170 _logger.info("Are we on? [%s]", response.decode())
171 return response == b"ON"
172

◆ get_status()

microscope.lights.obis.ObisLaser.get_status ( self)
Query and return the light source status.

Reimplemented from microscope.abc.LightSource.

Definition at line 94 of file obis.py.

94 def get_status(self):
95 result = []
96 for cmd, stat in [
97 (b"SOURce:AM:STATe?", "Emission on?"),
98 (b"SOURce:POWer:LEVel:IMMediate:AMPLitude?", "Target power:"),
99 (b"SOURce:POWer:LEVel?", "Measured power:"),
100 (b"SYSTem:STATus?", "Status code?"),
101 (b"SYSTem:FAULt?", "Fault code?"),
102 (b"SYSTem:HOURs?", "Head operating hours:"),
103 ]:
104 self._write(cmd)
105 result.append(stat + " " + self._readline().decode())
106 return result
107

◆ initialize()

microscope.lights.obis.ObisLaser.initialize ( self)
Initialize the device.

If devices have this method (not required, and many don't),
then they should call it as part of the initialisation, i.e.,
they should call it on their `__init__` method.

Reimplemented from microscope.abc.Device.

Definition at line 141 of file obis.py.

141 def initialize(self):
142 # self.flush_buffer()
143 # We ensure that handshaking is off.
144 self._write(b"SYSTem:COMMunicate:HANDshaking ON")
145 self._flush_handshake()
146 # We don't want 'direct control' mode.
147 # TODO: Change to MIXED when analogue output is available
148 self._write(b"SOURce:AM:EXTernal DIGital")
149 self._flush_handshake()
150

◆ set_trigger()

None microscope.lights.obis.ObisLaser.set_trigger ( self,
microscope.TriggerType ttype,
microscope.TriggerMode tmode )
Set device for a specific trigger.

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 202 of file obis.py.

204 ) -> None:
205 if ttype is not microscope.TriggerType.HIGH:
207 "the only trigger type supported is 'high'"
208 )
209 if tmode is not microscope.TriggerMode.BULB:
211 "the only trigger mode supported is 'bulb'"
212 )
213

◆ trigger_mode()

microscope.TriggerMode microscope.lights.obis.ObisLaser.trigger_mode ( self)

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 199 of file obis.py.

199 def trigger_mode(self) -> microscope.TriggerMode:
200 return microscope.TriggerMode.BULB
201

◆ trigger_type()

microscope.TriggerType microscope.lights.obis.ObisLaser.trigger_type ( self)

Reimplemented from microscope.abc.TriggerTargetMixin.

Definition at line 195 of file obis.py.

195 def trigger_type(self) -> microscope.TriggerType:
196 return microscope.TriggerType.HIGH
197

Member Data Documentation

◆ _max_power_mw

microscope.lights.obis.ObisLaser._max_power_mw = float(response) * 1000.0
protected

Definition at line 70 of file obis.py.

◆ connection

microscope.lights.obis.ObisLaser.connection
Initial value:
= serial.Serial(
port=com,
baudrate=baud,
timeout=timeout,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
)

Definition at line 36 of file obis.py.


The documentation for this class was generated from the following file: