Skip to content

Commit

Permalink
New scale patch (#166)
Browse files Browse the repository at this point in the history
* Duplicate Z to D, restrict to Z-axis movement when inside brain

* Pass manipulator type

* Autoformat code

---------

Co-authored-by: kjy5 <[email protected]>
  • Loading branch information
kjy5 and kjy5 authored Jun 24, 2023
1 parent c5429d3 commit c1c45cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ephys_link/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@ class GetManipulatorsOutputData(dict):
:param manipulators: Tuple of manipulator IDs (as strings)
:type manipulators: list
:param type: Type of the output data (temporary solution until #165 is implemented)
:type type: str
:param error: Error message
:type error: str
:example: Example generated dictionary
:code:`{"manipulators": ["1", "2"], "error": ""}`
"""

def __init__(self, manipulators: list, error: str) -> None:
def __init__(self, manipulators: list, type: str, error: str) -> None:
"""Constructor"""
super(GetManipulatorsOutputData, self).__init__(
manipulators=manipulators, error=error
manipulators=manipulators, type=type, error=error
)


Expand Down
3 changes: 2 additions & 1 deletion ephys_link/platform_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self):
# Registered manipulators are stored as a dictionary of IDs (string) to
# manipulator objects
self.manipulators = {}
self.type = "sensapex" # Remove this after #165

# Platform Handler Methods

Expand Down Expand Up @@ -72,7 +73,7 @@ def get_manipulators(self) -> com.GetManipulatorsOutputData:
except Exception as e:
print(f"[ERROR]\t\t Getting manipulators: {type(e)}: {e}\n")
finally:
return com.GetManipulatorsOutputData(devices, error)
return com.GetManipulatorsOutputData(devices, self.type, error)

def register_manipulator(self, manipulator_id: str) -> str:
"""Register a manipulator
Expand Down
3 changes: 3 additions & 0 deletions ephys_link/platforms/new_scale_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self) -> None:
"""Initialize New Scale handler"""
super().__init__()

# FIXME: Remove after #165
self.type = "new_scale"

# Load New Scale API
clr.AddReference("../resources/NstMotorCtrl")
# noinspection PyUnresolvedReferences
Expand Down
4 changes: 2 additions & 2 deletions ephys_link/platforms/new_scale_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_pos(self) -> com.PositionalOutputData:
self._x.CurPosition / 1000,
self._y.CurPosition / 1000,
self._z.CurPosition / 1000,
0,
self._z.CurPosition / 1000,
]
com.dprint(f"[SUCCESS]\t Got position of manipulator {self._id}\n")
return com.PositionalOutputData(position, "")
Expand Down Expand Up @@ -117,7 +117,7 @@ async def goto_pos(
# Alter target position if inside brain
if self._inside_brain:
target_position = self.get_pos()["position"]
target_position[3] = position_um[3]
target_position[2] = position_um[2]

# Send move command
for i in range(3):
Expand Down

0 comments on commit c1c45cd

Please sign in to comment.