Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objective switcher init bug fix #99

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions software/control/gui_hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
import control.camera as camera_fc

if USE_XERYON:
from control.objective_changer_2_pos_controller import ObjectiveChanger2PosController
from control.objective_changer_2_pos_controller import ObjectiveChanger2PosController, ObjectiveChanger2PosController_Simulation

import control.core.core as core
import control.microcontroller as microcontroller
Expand Down Expand Up @@ -219,14 +219,6 @@ def loadObjects(self, is_simulation):
self.camera, self.microcontroller, self.configurationManager, self.illuminationController, parent=self
)

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

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 @@ -314,6 +306,13 @@ def loadSimulationObjects(self):
self.microcontroller = microcontroller.Microcontroller(
serial_device=microcontroller.get_microcontroller_serial_device(simulated=True)
)
if USE_PRIOR_STAGE:
self.stage: squid.abc.AbstractStage = squid.stage.prior.PriorStage(sn=PRIOR_STAGE_SN, stage_config=squid.config.get_stage_config())

else:
self.stage: squid.abc.AbstractStage = squid.stage.cephla.CephlaStage(
microcontroller=self.microcontroller, stage_config=squid.config.get_stage_config()
)
# Initialize simulation objects
if ENABLE_SPINNING_DISK_CONFOCAL:
self.xlight = serial_peripherals.XLight_Simulation()
Expand All @@ -340,6 +339,9 @@ def loadSimulationObjects(self):
self.emission_filter_wheel = serial_peripherals.Optospin_Simulation(SN=None)
if USE_SQUID_FILTERWHEEL:
self.squid_filter_wheel = filterwheel.SquidFilterWheelWrapper_Simulation(None)
if USE_XERYON:
self.objective_changer = ObjectiveChanger2PosController_Simulation(sn=XERYON_SERIAL_NUMBER,stage=self.stage)


def loadHardwareObjects(self):
# Initialize hardware objects
Expand All @@ -353,6 +355,14 @@ def loadHardwareObjects(self):
self.log.error(f"Error initializing Microcontroller")
raise

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

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

if ENABLE_SPINNING_DISK_CONFOCAL:
try:
self.xlight = serial_peripherals.XLight(XLIGHT_SERIAL_NUMBER, XLIGHT_SLEEP_TIME_FOR_WHEEL)
Expand Down
43 changes: 41 additions & 2 deletions software/control/objective_changer_2_pos_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import time
import serial

from control.Xeryon import Xeryon
from control.Xeryon import Xeryon, Stage
from control._def import * # to remove once we create ObjectiveChangerConfig
import squid.abc
from typing import Optional

class ObjectiveChanger2PosController:
def __init__(self, sn: str, stage: Optional[squid.abc.AbstractStage] = None):
Expand Down Expand Up @@ -49,4 +50,42 @@ def currentPosition(self) -> int:
return self.current_position

def setSpeed(self, value: float):
self.axisX.setSpeed(value)
self.axisX.setSpeed(value)


class ObjectiveChanger2PosController_Simulation:
def __init__(self, sn: str, stage: Optional[squid.abc.AbstractStage] = None):
super().__init__()

self.stage = stage

self.position1 = -19
self.position2 = 19

self.current_position = None
self.retracted = False # moved down by self.position2_offset for position 2

self.position2_offset = XERYON_OBJECTIVE_SWITCHER_POS_2_OFFSET_MM

def home(self):
pass

def moveToPosition1(self):
if self.stage is not None and self.current_position == 2 and self.retracted:
# revert retracting z by self.position2_offset
self.stage.move_z(self.position2_offset)
self.retracted = False
self.current_position = 1

def moveToPosition2(self):
if self.stage is not None and self.current_position == 1:
# retract z by self.position2_offset
self.stage.move_z(-self.position2_offset)
self.retracted = True
self.current_position = 2

def currentPosition(self) -> int:
return self.current_position

def setSpeed(self, value: float):
pass
Loading