20"""Adds support for Aurox devices
22Requires package hidapi."""
25from threading
import Lock
35_Clarity__VENDORID = 0x1F0A
36_Clarity__PRODUCTID = 0x0088
41_Clarity__DOOROPEN = 0x01
42_Clarity__DOORCLOSED = 0x02
44_Clarity__SLDPOS0 = 0x00
45_Clarity__SLDPOS1 = 0x01
46_Clarity__SLDPOS2 = 0x02
47_Clarity__SLDPOS3 = 0x03
48_Clarity__SLDERR = 0xFF
49_Clarity__SLDMID = 0x10
51_Clarity__FLTPOS1 = 0x01
52_Clarity__FLTPOS2 = 0x02
53_Clarity__FLTPOS3 = 0x03
54_Clarity__FLTPOS4 = 0x04
55_Clarity__FLTERR = 0xFF
56_Clarity__FLTMID = 0x10
59_Clarity__CALOFF = 0x02
61_Clarity__CMDERROR = 0xFF
63_Clarity__GETVERSION = 0x00
65_Clarity__GETONOFF = 0x12
66_Clarity__GETDOOR = 0x13
67_Clarity__GETSLIDE = 0x14
68_Clarity__GETFILT = 0x15
69_Clarity__GETCAL = 0x16
70_Clarity__GETSERIAL = (
73_Clarity__FULLSTAT = 0x1F
75_Clarity__SETONOFF = 0x21
76_Clarity__SETSLIDE = 0x23
77_Clarity__SETFILT = 0x24
78_Clarity__SETCAL = 0x25
80_Clarity__SETSVCMODE1 = 0xE0
83class Clarity(microscope.devices.FilterWheelBase):
84 _slide_to_sectioning = {
101 def __init__(self, **kwargs):
102 super().__init__(positions=Clarity._positions, **kwargs)
113 def _send_command(self, command, param=0, max_length=16, timeout_ms=100):
114 """Send a command to the Clarity and return its response"""
119 buffer = [0x00] * max_length
122 result = self.
_hid.write(buffer)
125 err = self.
_hid.error()
134 response = self.
_hid.read(result - 1, timeout_ms)
138 elif response[0] == command:
149 def is_connected(self):
150 return self.
_hid is not None
154 h.open(vendor_id=__VENDORID, product_id=__PRODUCTID)
155 h.set_nonblocking(
False)
166 def _do_enable(self):
172 def _do_disable(self):
175 def set_calibration(self, state):
183 """Get the current slide position"""
190 """Set the slide position"""
194 while blocking
and self.
moving():
198 def get_slides(self):
201 def get_status(self):
211 status[
"on"] = result[3] == __RUN
217 door = result[4] == __DOORCLOSED
218 status[
"door open"] = door
222 if slide == __SLDMID:
224 status[
"slide"] = (
None,
"moving")
233 if filter == __FLTMID:
235 status[
"filter"] = (
None,
"moving")
238 status[
"filter"] = result[6]
240 status[
"calibration"] = result[7] == __CALON
242 status[
"busy"] = any(busy)
250 """Report whether or not the device is between positions."""
258 moving = moving
or any(
261 self.get_position() == __FLTMID,
267 def _do_get_position(self):
268 """Return the current filter position"""
270 if result == __FLTERR:
274 def _do_set_position(self, pos, blocking=True):
275 """Set the filter position"""
279 while blocking
and self.
moving():
283 def _do_shutdown(self) -> None:
def set_slide_position(self, position, blocking=True)
def get_slide_position(self)
dictionary _slide_to_sectioning
def _send_command(self, command, param=0, max_length=16, timeout_ms=100)