Skip to content

Commit 000b414

Browse files
author
Henri Ervasti
committed
[183-thorlabs-k1-crx-devices-with-different-constants] Trying out having a K10CRX base class and then inheriting K10RC1 and K10RC2 versions with only changing the MAX_VELOCITY and open call.
1 parent d87a6cc commit 000b414

File tree

3 files changed

+1548
-0
lines changed

3 files changed

+1548
-0
lines changed

qmi/instruments/thorlabs/k10cr2.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Instrument driver for the Thorlabs K10CR2/M motorized rotational mount.
2+
3+
This driver communicates with the device via a USB serial port, using the Thorlabs APT protocol. For details,
4+
see the document "Thorlabs APT Controllers Host-Controller Communications Protocol", issue 25 from Thorlabs.
5+
6+
This driver has only been tested under Linux. In principle it should also work under Windows
7+
after creating a virtual COM port for the internal USB serial port in the instrument.
8+
"""
9+
10+
import logging
11+
12+
from qmi.core.context import QMI_Context
13+
from qmi.core.rpc import rpc_method
14+
from qmi.instruments.thorlabs.k10crx import Thorlabs_K10CRxBase
15+
16+
# Global variable holding the logger for this module.
17+
_logger = logging.getLogger(__name__)
18+
19+
20+
class Thorlabs_K10CR2(Thorlabs_K10CRxBase):
21+
"""Instrument driver for the Thorlabs K10CR2/M motorized rotational mount."""
22+
23+
# Maximum velocity in degrees/second
24+
MAX_VELOCITY = 10
25+
26+
def __init__(self, context: QMI_Context, name: str, transport: str) -> None:
27+
"""Initialize driver.
28+
29+
The motorized mount presents itself as a USB serial port.
30+
The transport descriptor should refer to the serial port device,
31+
e.g. "serial:/dev/ttyUSB1"
32+
33+
Parameters:
34+
name: Name for this instrument instance.
35+
transport: Transport descriptor to access the instrument.
36+
"""
37+
super().__init__(context, name, transport)
38+
39+
@rpc_method
40+
def open(self) -> None:
41+
try:
42+
super().open()
43+
# Check that this device is a K10CR2 motor.
44+
# Otherwise we should not talk to it, since we don't want to send
45+
# inappropriate commands to some unsupported device.
46+
self._check_k10crx("2")
47+
48+
except Exception:
49+
# Close the transport if an error occurred during initialization of the instrument.
50+
self._transport.close()
51+
raise
52+
53+
super(Thorlabs_K10CRxBase, self).open()

0 commit comments

Comments
 (0)