Skip to content

Commit

Permalink
Merge pull request #65 from Alpaca233/prior_abc
Browse files Browse the repository at this point in the history
implement prior stage based on abstract stage class
  • Loading branch information
hongquanli authored Jan 7, 2025
2 parents 6e1cf04 + 33d9064 commit 3ef1624
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 316 deletions.
30 changes: 15 additions & 15 deletions software/control/gui_hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import squid.abc
import squid.logging
import squid.config
import squid.stage.prior
import squid.stage.cephla
import squid.stage.utils
import control.microscope
from control.microscope import LightSourceType, IntensityControlMode, ShutterControlMode
Expand All @@ -29,6 +27,10 @@

import control.filterwheel as filterwheel

if USE_PRIOR_STAGE:
import squid.stage.prior
else:
import squid.stage.cephla

if CAMERA_TYPE == "Toupcam":
try:
Expand Down Expand Up @@ -78,9 +80,6 @@
else:
import control.camera as camera_fc

if USE_PRIOR_STAGE:
from control.stage_prior import PriorStage

import control.core.core as core
import control.microcontroller as microcontroller
import control.serial_peripherals as serial_peripherals
Expand Down Expand Up @@ -199,9 +198,17 @@ def loadObjects(self, is_simulation):
self.liveController = core.LiveController(
self.camera, self.microcontroller, self.configurationManager, self.illuminationController, parent=self
)
self.stage: squid.abc.AbstractStage = squid.stage.cephla.CephlaStage(
microcontroller=self.microcontroller, stage_config=squid.config.get_stage_config()
)

if USE_PRIOR_STAGE:
self.stage: squid.abc.AbstractStage = squid.stage.prior.PriorStage(
sn=PRIOR_STAGE_SN
)

else:
self.stage: squid.abc.AbstractStage = squid.stage.cephla.CephlaStage(
microcontroller=self.microcontroller, stage_config=squid.config.get_stage_config()
)

self.slidePositionController = core.SlidePositionController(
self.stage, self.liveController, is_for_wellplate=True
)
Expand Down Expand Up @@ -409,13 +416,6 @@ def loadHardwareObjects(self):
self.log.error("Error initializing Optospin Emission Filter Wheel")
raise

if USE_PRIOR_STAGE:
try:
self.priorstage = PriorStage(PRIOR_STAGE_SN, parent=self)
except Exception:
self.log.error("Error initializing Prior Stage")
raise

def setupHardware(self):
# Setup hardware components
if USE_ZABER_EMISSION_FILTER_WHEEL:
Expand Down
272 changes: 0 additions & 272 deletions software/control/stage_prior.py

This file was deleted.

6 changes: 3 additions & 3 deletions software/control/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,17 +1541,17 @@ def move_z_backward(self):
self.stage.move_z(-self.entry_dZ.value() / 1000)

def set_deltaX(self, value):
mm_per_ustep = 1.0 / self.stage.get_config().X_AXIS.convert_real_units_to_ustep(1.0)
mm_per_ustep = 1.0 / self.stage.x_mm_to_usteps(1.0)
deltaX = round(value / mm_per_ustep) * mm_per_ustep
self.entry_dX.setValue(deltaX)

def set_deltaY(self, value):
mm_per_ustep = 1.0 / self.stage.get_config().Y_AXIS.convert_real_units_to_ustep(1.0)
mm_per_ustep = 1.0 / self.stage.y_mm_to_usteps(1.0)
deltaY = round(value / mm_per_ustep) * mm_per_ustep
self.entry_dY.setValue(deltaY)

def set_deltaZ(self, value):
mm_per_ustep = 1.0 / self.stage.get_config().Z_AXIS.convert_real_units_to_ustep(1.0)
mm_per_ustep = 1.0 / self.stage.z_mm_to_usteps(1.0)
deltaZ = round(value / 1000 / mm_per_ustep) * mm_per_ustep * 1000
self.entry_dZ.setValue(deltaZ)

Expand Down
9 changes: 9 additions & 0 deletions software/squid/stage/cephla.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def _configure_axis(self, microcontroller_axis_number: int, axis_config: AxisCon
)
self._microcontroller.turn_on_stage_pid(microcontroller_axis_number)

def x_mm_to_usteps(self, mm: float):
return self._config.X_AXIS.convert_real_units_to_ustep(mm)

def y_mm_to_usteps(self, mm: float):
return self._config.Y_AXIS.convert_real_units_to_ustep(mm)

def z_mm_to_usteps(self, mm: float):
return self._config.Z_AXIS.convert_real_units_to_ustep(mm)

def move_x(self, rel_mm: float, blocking: bool = True):
self._microcontroller.move_x_usteps(self._config.X_AXIS.convert_real_units_to_ustep(rel_mm))
if blocking:
Expand Down
Loading

0 comments on commit 3ef1624

Please sign in to comment.