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
2 changes: 1 addition & 1 deletion src/ephys_link/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.0b0"
__version__ = "2.1.0b1"
30 changes: 13 additions & 17 deletions src/ephys_link/bindings/ump_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,9 @@ def __init__(self) -> None:
UMP.set_library_path(RESOURCES_DIRECTORY)
self._ump: UMP = UMP.get_ump() # pyright: ignore [reportUnknownMemberType]

# Exit if no manipulators are connected.
device_ids: list[str] = list(map(str, self._ump.list_devices()))
if len(device_ids) == 0:
msg = "No manipulators connected."
raise RuntimeError(msg)

# Currently only supports using uMp-4 XOR uMp-3. Exit if both are connected.

# Use the first device as the reference for the number of axes.
self.num_axes: int = self._get_device(device_ids[0]).n_axes()

if any(self._get_device(device_id).n_axes() != self.num_axes for device_id in device_ids): # pyright: ignore [reportUnknownArgumentType, reportUnknownMemberType]
msg = "uMp-4 and uMp-3 cannot be used at the same time."
raise RuntimeError(msg)
# Compute axis count, assumed as the first device. 0 if no devices are connected.
device_ids = list(map(str, self._ump.list_devices()))
self.axis_count: int = 0 if len(device_ids) == 0 else self._get_device(device_ids[0]).n_axes()

@staticmethod
@override
Expand All @@ -61,11 +50,18 @@ def get_cli_name() -> str:

@override
async def get_manipulators(self) -> list[str]:
return list(map(str, self._ump.list_devices()))
device_ids = list(map(str, self._ump.list_devices()))

# Currently only supports using uMp-4 XOR uMp-3. Throw error if both are connected.
if any(self._get_device(device_id).n_axes() != self.axis_count for device_id in device_ids): # pyright: ignore [reportUnknownArgumentType]
msg = "uMp-4 and uMp-3 cannot be used at the same time."
raise RuntimeError(msg)

return device_ids

@override
async def get_axes_count(self) -> int:
return self.num_axes
return self.axis_count

@override
def get_dimensions(self) -> Vector4:
Expand Down Expand Up @@ -236,4 +232,4 @@ def _is_ump_3(self) -> bool:
Returns:
True if the device is uMp-3, False otherwise.
"""
return self.num_axes == self.UMP_3_NUM_AXES
return self.axis_count == self.UMP_3_NUM_AXES