diff --git a/src/navigate/model/devices/APIs/asi/asi_tiger_controller.py b/src/navigate/model/devices/APIs/asi/asi_tiger_controller.py index b0172173c..57854114c 100644 --- a/src/navigate/model/devices/APIs/asi/asi_tiger_controller.py +++ b/src/navigate/model/devices/APIs/asi/asi_tiger_controller.py @@ -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] @@ -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 @@ -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 diff --git a/test/model/devices/stages/test_asi.py b/test/model/devices/stages/test_asi.py index 07e1443d8..164699f79 100644 --- a/test/model/devices/stages/test_asi.py +++ b/test/model/devices/stages/test_asi.py @@ -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()