32 """Implements FilterServer wheel interface for Thorlabs FW102C.
34 Note that the FW102C also has manual controls on the device, so clients
35 should periodically query the current wheel position."""
37 def __init__(self, com, baud=115200, timeout=2.0, **kwargs):
38 """Create ThorlabsFilterWheel
41 :param baud: baud rate
42 :param timeout: serial timeout
45 rawSerial = serial.Serial(
49 stopbits=serial.STOPBITS_ONE,
50 bytesize=serial.EIGHTBITS,
51 parity=serial.PARITY_NONE,
71 self.
_lock = threading.RLock()
73 super().
__init__(positions=position_count, **kwargs)
75 def _do_shutdown(self) -> None:
78 def _do_set_position(self, new_position: int) ->
None:
80 self._send_command(
"pos=%d" % (new_position + 1))
82 def _do_get_position(self):
85 return int(self._send_command(
"pos?")) - 1
88 "Unable to get position of %s", self.__class__.__name__
92 """Custom _readline to overcome limitations of the serial implementation."""
95 while not result
or result[-1]
not in (
"\n",
""):
96 char = self.connection.read()
98 if result
or (char
not in string.whitespace):
100 return "".join(result)
102 def _send_command(self, command):
103 """Send a command and return any result."""
105 self.connection.write(command + self.eol)
107 while command
not in response
and ">" not in response:
109 response = self._readline().strip()
110 if command.endswith(
"?"):
112 return self._readline().strip()
117 """Deprecated, use ThorlabsFilterWheel.
120 found its own number of positions
and there was a separate
class
121 for each thorlabs filterwheel model.
126 "Use ThorlabsFilterWheel instead of ThorlabsFW102C",
133 "Does not look like a FW102C, it has %d positions instead of 6"
138 """Deprecated, use ThorlabsFilterWheel.
141 found its own number of positions
and there was a separate
class
142 for each thorlabs filterwheel model.
147 "Use ThorlabsFilterWheel instead of ThorlabsFW212C",
154 "Does not look like a FW212C, it has %d positions instead of 12"
def __init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs)
def __init__(self, com, baud=115200, timeout=2.0, **kwargs)
def _send_command(self, command)