Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/navigate/model/devices/APIs/asi/asi_tiger_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,13 @@ def connect_to_serial(
#: list[str]: Default axes sequence of the Tiger Controller
self.default_axes_sequence = self.get_default_motor_axis_sequence()

def get_default_motor_axis_sequence(self) -> None:
def get_default_motor_axis_sequence(self) -> list[str]:
"""Get the default motor axis sequence from the ASI device

Only returns stage types XYMotor, ZMotor, Theta. Avoids problems associated
with other tiger controller cards, which could include piezos, filter wheels,
logic cards, etc.

Returns
-------
list[str]
Expand All @@ -187,15 +191,23 @@ def get_default_motor_axis_sequence(self) -> None:
self.send_command("BU X")
response = self.read_response()
lines = response.split("\r")
motor_axes, axis_types = [], []
for line in lines:
if line.startswith("Motor Axes:"):
default_axes_sequence = line[line.index(":") + 2 :].split(" ")[:-2]
self.report_to_console(
"Get the default axes sequence from the ASI device " "successfully!"
)
break
motor_axes = line.split("Motor Axes:")[1].split()
if line.startswith("Axis Types:"):
axis_types = line.split("Axis Types:")[1].split()

return default_axes_sequence
if len(motor_axes) == 0 or len(axis_types) == 0:
raise TigerException(":N-5")

if len(motor_axes) != len(axis_types):
raise TigerException(":N-5")

for i in range(len(axis_types) - 1, -1, -1):
if axis_types[i] not in ["x", "z", "t"]:
motor_axes.pop(i)
return motor_axes

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

def send_command(self, cmd: bytes) -> None:
def send_command(self, cmd: str) -> None:
"""Send a serial command to the device.

Parameters
----------
cmd : bytes
cmd : str
Serial command to send to the device
"""
# always reset the buffers before a new command is sent
Expand Down
8 changes: 8 additions & 0 deletions test/model/devices/stages/test_asi.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ def build_device_connection(self):
port = self.stage_configuration["stage"]["hardware"]["port"]
baudrate = self.stage_configuration["stage"]["hardware"]["baudrate"]

# Patch TigerController.get_default_motor_axis_sequence
TigerController.get_default_motor_axis_sequence = lambda self: [
"X",
"Y",
"Z",
"M",
"N",
]
asi_stage = TigerController(port, baudrate)
asi_stage.serial_port = self.asi_serial_device
asi_stage.connect_to_serial()
Expand Down
Loading