From 7ed718cbaeb1f5172566d331c3c29099ec4e2805 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Fri, 13 Feb 2026 17:05:24 +0000 Subject: [PATCH] Estimate move duraction added to each stage class --- src/openflexure_microscope_server/things/stage/__init__.py | 5 +++-- src/openflexure_microscope_server/things/stage/dummy.py | 6 ++++++ .../things/stage/sangaboard.py | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/stage/__init__.py b/src/openflexure_microscope_server/things/stage/__init__.py index b2587678..d48722f5 100644 --- a/src/openflexure_microscope_server/things/stage/__init__.py +++ b/src/openflexure_microscope_server/things/stage/__init__.py @@ -249,8 +249,9 @@ class BaseStage(lt.Thing): def _estimate_move_duration(self, displacement: Sequence[int]) -> float: """Calculate the expected duration of a move with the given displacement.""" - max_displacement = max(abs(d) for d in displacement) - return max_displacement * 0.001 # This does not yet check the board's speed. + raise NotImplementedError( + "StageThings must define their own _estimate_move_duration" + ) @lt.action def jog(self, stop: bool = False, **kwargs: int) -> None: diff --git a/src/openflexure_microscope_server/things/stage/dummy.py b/src/openflexure_microscope_server/things/stage/dummy.py index 51af444e..5b3ba463 100644 --- a/src/openflexure_microscope_server/things/stage/dummy.py +++ b/src/openflexure_microscope_server/things/stage/dummy.py @@ -131,6 +131,12 @@ class DummyStage(BaseStage): self.moving = moving return moving + def _estimate_move_duration(self, displacement: Sequence[int]) -> float: + """Calculate the expected duration of a move with the given displacement.""" + max_displacement = max(abs(d) for d in displacement) + # This does not yet check the board's speed. + return max_displacement * self.step_time + def _hardware_move_relative( self, block_cancellation: bool = False, diff --git a/src/openflexure_microscope_server/things/stage/sangaboard.py b/src/openflexure_microscope_server/things/stage/sangaboard.py index e17df882..7107fed5 100644 --- a/src/openflexure_microscope_server/things/stage/sangaboard.py +++ b/src/openflexure_microscope_server/things/stage/sangaboard.py @@ -137,6 +137,12 @@ class SangaboardThing(BaseStage): self.moving = moving return moving + def _estimate_move_duration(self, displacement: Sequence[int]) -> float: + """Calculate the expected duration of a move with the given displacement.""" + max_displacement = max(abs(d) for d in displacement) + # This does not yet check the board's speed. + return max_displacement * 0.001 + def _hardware_move_relative( self, block_cancellation: bool = False,