Skip to content

Commit

Permalink
Throw error if finish movement and can't write (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjy5 authored Oct 24, 2023
1 parent 05664c4 commit 0b2deea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ephys_link/platforms/new_scale_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ async def goto_pos(
"""
# Check if able to write
if not self._can_write:
print(f"[ERROR]\t\t Manipulator {self._id} movement " f"canceled")
return com.PositionalOutputData([], "Manipulator " "movement canceled")
print(f"[ERROR]\t\t Manipulator {self._id} movement canceled")
return com.PositionalOutputData([], "Manipulator movement canceled")

# Stop current movement
if self._is_moving:
Expand Down Expand Up @@ -147,6 +147,10 @@ async def goto_pos(
# Mark movement as finished
self._is_moving = False

# Return success unless write was disabled during movement (meaning a stop occurred)
if not self._can_write:
return com.PositionalOutputData([], "Manipulator movement canceled")

com.dprint(
f"[SUCCESS]\t Moved manipulator {self._id} to position"
f" {manipulator_final_position}\n"
Expand Down Expand Up @@ -207,6 +211,10 @@ async def drive_to_depth(
# Mark movement as finished
self._is_moving = False

# Return success unless write was disabled during movement (meaning a stop occurred)
if not self._can_write:
return com.DriveToDepthOutputData(0, "Manipulator movement canceled")

com.dprint(
f"[SUCCESS]\t Moved manipulator {self._id} to position"
f" {manipulator_final_position}\n"
Expand Down
4 changes: 4 additions & 0 deletions src/ephys_link/platforms/sensapex_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ async def goto_pos(
# Mark movement as finished
self._is_moving = False

# Return success unless write was disabled during movement (meaning a stop occurred)
if not self._can_write:
return com.PositionalOutputData([], "Manipulator movement canceled")

com.dprint(
f"[SUCCESS]\t Moved manipulator {self._id} to position"
f" {manipulator_final_position}\n"
Expand Down

0 comments on commit 0b2deea

Please sign in to comment.