Remove final dependencies

This commit is contained in:
Julian Stirling 2025-12-17 15:50:03 +00:00
parent be5f9630ca
commit 4ad1fff656
3 changed files with 8 additions and 35 deletions

View file

@ -683,10 +683,6 @@ class BaseCamera(lt.Thing):
return {} return {}
CameraDependency = lt.deps.direct_thing_client_dependency(BaseCamera, "camera")
RawCameraDependency = lt.deps.raw_thing_dependency(BaseCamera)
def downsample(factor: int, image: np.ndarray) -> np.ndarray: def downsample(factor: int, image: np.ndarray) -> np.ndarray:
"""Downsample an image by taking the mean of each nxn region. """Downsample an image by taking the mean of each nxn region.

View file

@ -34,18 +34,13 @@ from openflexure_microscope_server import scan_directories, scan_planners, stitc
# Things # Things
from .autofocus import AutofocusThing, StackParams from .autofocus import AutofocusThing, StackParams
from .camera import CameraDependency as CameraClient from .camera import BaseCamera
from .camera_stage_mapping import CameraStageMapper from .camera_stage_mapping import CameraStageMapper
from .stage import StageDependency as StageDep from .stage import BaseStage
T = TypeVar("T") T = TypeVar("T")
P = ParamSpec("P") P = ParamSpec("P")
CSMDep = lt.deps.direct_thing_client_dependency(
CameraStageMapper, "camera_stage_mapping"
)
AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "autofocus")
class ScanListInfo(BaseModel): class ScanListInfo(BaseModel):
"""The information to be sent to the Scan List tab.""" """The information to be sent to the Scan List tab."""
@ -103,6 +98,11 @@ class SmartScanThing(lt.Thing):
past scans. past scans.
""" """
_autofocus: AutofocusThing = lt.thing_slot()
_cam: BaseCamera = lt.thing_slot()
_csm: CameraStageMapper = lt.thing_slot()
_stage: BaseStage = lt.thing_slot()
def __init__( def __init__(
self, thing_server_interface: lt.ThingServerInterface, scans_folder: str self, thing_server_interface: lt.ThingServerInterface, scans_folder: str
) -> None: ) -> None:
@ -119,24 +119,13 @@ class SmartScanThing(lt.Thing):
# Variables set by the scan # Variables set by the scan
self._latest_scan_name: Optional[str] = None self._latest_scan_name: Optional[str] = None
self._autofocus: Optional[AutofocusDep] = None
self._stage: Optional[StageDep] = None
self._cam: Optional[CameraClient] = None
self._csm: Optional[CSMDep] = None
self._stack_params: Optional[StackParams] = None self._stack_params: Optional[StackParams] = None
self._ongoing_scan: Optional[scan_directories.ScanDirectory] = None self._ongoing_scan: Optional[scan_directories.ScanDirectory] = None
self._scan_data: Optional[scan_directories.ScanData] = None self._scan_data: Optional[scan_directories.ScanData] = None
self._preview_stitcher: Optional[stitching.PreviewStitcher] = None self._preview_stitcher: Optional[stitching.PreviewStitcher] = None
@lt.action @lt.action
def sample_scan( def sample_scan(self, scan_name: str = "") -> None:
self,
autofocus: AutofocusDep,
stage: StageDep,
cam: CameraClient,
csm: CSMDep,
scan_name: str = "",
) -> None:
"""Move the stage to cover an area, taking images that can be tiled together. """Move the stage to cover an area, taking images that can be tiled together.
The stage will move in a pattern that grows outwards from the starting point, The stage will move in a pattern that grows outwards from the starting point,
@ -147,11 +136,6 @@ class SmartScanThing(lt.Thing):
if not got_lock: if not got_lock:
raise RuntimeError("Trying to run scan while scan is already running!") raise RuntimeError("Trying to run scan while scan is already running!")
# Set private variables for this scan
self._autofocus = autofocus
self._stage = stage
self._cam = cam
self._csm = csm
# `scan_data` should already be None. This is added as a precaution as # `scan_data` should already be None. This is added as a precaution as
# the presence of `scan_data` is used during error handling to # the presence of `scan_data` is used during error handling to
# determine whether the scan started. # determine whether the scan started.
@ -176,10 +160,6 @@ class SmartScanThing(lt.Thing):
raise e raise e
finally: finally:
# However the scan finishes, unset all variables and release lock # However the scan finishes, unset all variables and release lock
self._autofocus = None
self._stage = None
self._cam = None
self._csm = None
self._ongoing_scan = None self._ongoing_scan = None
self._scan_data = None self._scan_data = None
self._scan_lock.release() self._scan_lock.release()

View file

@ -206,6 +206,3 @@ class BaseStage(lt.Thing):
This method provides the interface expected by the camera_stage_mapping. This method provides the interface expected by the camera_stage_mapping.
""" """
self.move_absolute(x=xyz_pos[0], y=xyz_pos[1], z=xyz_pos[2]) self.move_absolute(x=xyz_pos[0], y=xyz_pos[1], z=xyz_pos[2])
StageDependency = lt.deps.direct_thing_client_dependency(BaseStage, "stage")