Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

266 support pathfinder 4 shank probe #270

Merged
merged 3 commits into from
Dec 11, 2023
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 .idea/ruff.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/ephys_link/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ def __init__(self, angles: list, error: str) -> None:
super(AngularOutputData, self).__init__(angles=angles, error=error)


class ShankCountOutputData(dict):
"""Output format for (num_shanks, error)

:param shank_count: Number of shanks on the probe
:type shank_count: int
:param error: Error message
:type error: str
"""

def __init__(self, shank_count: int, error: str) -> None:
"""Constructor"""
super(ShankCountOutputData, self).__init__(shank_count=shank_count, error=error)


class DriveToDepthOutputData(dict):
"""Output format for depth driving (depth, error)

Expand Down
22 changes: 20 additions & 2 deletions src/ephys_link/platform_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def get_angles(self, manipulator_id: str) -> com.AngularOutputData:

:param manipulator_id: The ID of the manipulator to get the position of.
:type manipulator_id: str
:return: Callback parameters (manipulator ID, angles in (yaw, pitch, roll) (or an
empty array on error) in degrees, error message)
:return: Callback parameters (angles in (yaw, pitch, roll) or an
empty array on error in degrees, error message)
:rtype: :class:`ephys_link.common.AngularOutputData`
"""
try:
Expand All @@ -197,6 +197,15 @@ def get_angles(self, manipulator_id: str) -> com.AngularOutputData:
print(f"[ERROR]\t\t Manipulator not registered: {manipulator_id}")
return com.AngularOutputData([], "Manipulator not registered")

def get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
"""Get the number of shanks on the probe

:param manipulator_id: The ID of the manipulator to get the number of shanks of.
:type manipulator_id: str
:return: Callback parameters (number of shanks or -1 on error, error message)
"""
return self._get_shank_count(manipulator_id)

async def goto_pos(
self, manipulator_id: str, position: list[float], speed: int
) -> com.PositionalOutputData:
Expand Down Expand Up @@ -453,6 +462,15 @@ def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
:rtype: :class:`ephys_link.common.AngularOutputData`
"""

@abstractmethod
def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
"""Get the number of shanks on the probe

:param manipulator_id: The ID of the manipulator to get the number of shanks of.
:type manipulator_id: str
:return: Callback parameters (number of shanks or -1 on error, error message)
"""

@abstractmethod
async def _goto_pos(
self, manipulator_id: str, position: list[float], speed: int
Expand Down
3 changes: 3 additions & 0 deletions src/ephys_link/platforms/new_scale_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def _get_pos(self, manipulator_id: str) -> com.PositionalOutputData:
def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
raise NotImplementedError

def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
raise NotImplementedError

async def _goto_pos(
self, manipulator_id: str, position: list[float], speed: int
) -> com.PositionalOutputData:
Expand Down
12 changes: 12 additions & 0 deletions src/ephys_link/platforms/new_scale_pathfinder_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
"",
)

def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
"""Get the number of shanks on the probe

:param manipulator_id: manipulator ID
:return: Callback parameters (number of shanks (or -1 on error), error message)
"""
for probe in self.query_data()["ProbeArray"]:
if probe["Id"] == manipulator_id:
return com.ShankCountOutputData(probe["ShankCount"], "")

return com.ShankCountOutputData(-1, "Unable to find manipulator")

async def _goto_pos(
self, manipulator_id: str, position: list[float], speed: int
) -> com.PositionalOutputData:
Expand Down
3 changes: 3 additions & 0 deletions src/ephys_link/platforms/sensapex_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def _get_pos(self, manipulator_id: str) -> com.PositionalOutputData:
def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
raise NotImplementedError

def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
raise NotImplementedError

async def _goto_pos(
self, manipulator_id: str, position: list[float], speed: int
) -> com.PositionalOutputData:
Expand Down
3 changes: 3 additions & 0 deletions src/ephys_link/platforms/ump3_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def _get_pos(self, manipulator_id: str) -> com.PositionalOutputData:
def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
raise NotImplementedError

def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
raise NotImplementedError

async def _goto_pos(
self, manipulator_id: str, position: list[float], speed: int
) -> com.PositionalOutputData:
Expand Down
16 changes: 16 additions & 0 deletions src/ephys_link/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ async def get_angles(_, manipulator_id: str) -> com.AngularOutputData:
return platform.get_angles(manipulator_id)


@sio.event
async def get_shank_count(_, manipulator_id: str) -> com.ShankCountOutputData:
"""Number of shanks of manipulator request

:param _: Socket session ID (unused)
:type _: str
:param manipulator_id: ID of manipulator to pull number of shanks from
:type manipulator_id: str
:return: Callback parameters (manipulator ID, number of shanks (or -1 on error), error
message)
:rtype: :class:`ephys_link.common.ShankCountOutputData`
"""

return platform.get_shank_count(manipulator_id)


@sio.event
async def goto_pos(
_, data: com.GotoPositionInputDataFormat
Expand Down