Skip to content

Commit 593acb5

Browse files
Merge pull request #993 from TheDeanLab/tiger-update
Update asi_tiger_controller.py
2 parents 98d7967 + 6f3f279 commit 593acb5

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/navigate/model/devices/APIs/asi/asi_tiger_controller.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,13 @@ def connect_to_serial(
176176
#: list[str]: Default axes sequence of the Tiger Controller
177177
self.default_axes_sequence = self.get_default_motor_axis_sequence()
178178

179-
def get_default_motor_axis_sequence(self) -> None:
179+
def get_default_motor_axis_sequence(self) -> list[str]:
180180
"""Get the default motor axis sequence from the ASI device
181181
182+
Only returns stage types XYMotor, ZMotor, Theta. Avoids problems associated
183+
with other tiger controller cards, which could include piezos, filter wheels,
184+
logic cards, etc.
185+
182186
Returns
183187
-------
184188
list[str]
@@ -187,15 +191,23 @@ def get_default_motor_axis_sequence(self) -> None:
187191
self.send_command("BU X")
188192
response = self.read_response()
189193
lines = response.split("\r")
194+
motor_axes, axis_types = [], []
190195
for line in lines:
191196
if line.startswith("Motor Axes:"):
192-
default_axes_sequence = line[line.index(":") + 2 :].split(" ")[:-2]
193-
self.report_to_console(
194-
"Get the default axes sequence from the ASI device " "successfully!"
195-
)
196-
break
197+
motor_axes = line.split("Motor Axes:")[1].split()
198+
if line.startswith("Axis Types:"):
199+
axis_types = line.split("Axis Types:")[1].split()
197200

198-
return default_axes_sequence
201+
if len(motor_axes) == 0 or len(axis_types) == 0:
202+
raise TigerException(":N-5")
203+
204+
if len(motor_axes) != len(axis_types):
205+
raise TigerException(":N-5")
206+
207+
for i in range(len(axis_types) - 1, -1, -1):
208+
if axis_types[i] not in ["x", "z", "t"]:
209+
motor_axes.pop(i)
210+
return motor_axes
199211

200212
##### TODO: Modify these to accept dictionaries and send a
201213
# single command for all axes
@@ -326,12 +338,12 @@ def report_to_console(self, message: str) -> None:
326338
if self.verbose:
327339
print(message)
328340

329-
def send_command(self, cmd: bytes) -> None:
341+
def send_command(self, cmd: str) -> None:
330342
"""Send a serial command to the device.
331343
332344
Parameters
333345
----------
334-
cmd : bytes
346+
cmd : str
335347
Serial command to send to the device
336348
"""
337349
# always reset the buffers before a new command is sent

test/model/devices/stages/test_asi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def build_device_connection(self):
148148
port = self.stage_configuration["stage"]["hardware"]["port"]
149149
baudrate = self.stage_configuration["stage"]["hardware"]["baudrate"]
150150

151+
# Patch TigerController.get_default_motor_axis_sequence
152+
TigerController.get_default_motor_axis_sequence = lambda self: [
153+
"X",
154+
"Y",
155+
"Z",
156+
"M",
157+
"N",
158+
]
151159
asi_stage = TigerController(port, baudrate)
152160
asi_stage.serial_port = self.asi_serial_device
153161
asi_stage.connect_to_serial()

0 commit comments

Comments
 (0)