DAQ: attempt at camera auto exposure, however there are issues when the backlight is not in. The front light may not be bright enough or set values may need to be used

This commit is contained in:
2026-01-29 16:43:55 +01:00
parent 4a552c0dcd
commit a9a6f71005
+43 -13
View File
@@ -14,7 +14,7 @@ import aare.common.face_detection as fd
from aare.daq import workflows
from aare.daq.aaredb import AareWrapper
from aare.common.autofocus_tools import focus_measure_edges
from aare.daq.config import BeamlineConfig
from aare.daq.config import BeamlineConfig, ABR_POS_MOUNT, ABR_OMEGA_MOUNT
from aare.daq.config import BeamlineStateEnum
from aare.daq.devices import BeamlineDevices
from aare.daq.mlbox import MlBox
@@ -32,6 +32,7 @@ from aare.common.models import (
from aare.common.raster_grid import RasterGridRequest, CompletedRasterGrid, CompletedRasterGridElem
from aare.common.rotation_scan import RotationScanRequest, CompletedRotationScan
from aare.common.sample_geometry import SampleGeometryModel
from aare.devices.area_detector import AutoEnum
from aare.devices.jfjoch import JFJochWrapper
logger = setup_logger("aareDAQ")
@@ -229,17 +230,10 @@ class AareDAQ:
@zoom.setter
def zoom(self, val: float):
self.__saved_box = None
self.__devs.samcam_auto(AutoEnum.AUTO)
self.__devs.zoom = val
if self.__cfg.state == BeamlineStateEnum.BeamLocation:
self.__cfg.zoom_mode = ZoomModeEnum.BeamLocation
else:
self.__cfg.zoom_mode = ZoomModeEnum.User
zoom_settings = self.__cfg.zoom_settings.get_camera_settings(val)
print(f"Setting zoom {val} {zoom_settings}")
self.samcam_settings = zoom_settings
time.sleep(0.2)
self.__devs.samcam_auto(AutoEnum.ONCE)
@property
def front_light(self) -> float:
@@ -301,14 +295,18 @@ class AareDAQ:
def save_abr_meas_pos(self):
self.__cfg.set_busy(BeamlineStateEnum.SampleAlignment)
print('Set busy in save_abr_meas_pos')
try:
print('Set abr measure pos in save_abr_meas_pos')
self.__cfg.abr_meas_pos = self.__devs.aerotech_pos
print('busy should be set to false now')
self.__cfg.state_busy = False
except:
self.__cfg.state_busy = False
raise
def goto_abr_meas_pos(self):
print('why are we here')
self.__cfg.set_busy(BeamlineStateEnum.SampleAlignment)
try:
self.__devs.aerotech_pos = self.__cfg.abr_meas_pos
@@ -338,11 +336,43 @@ class AareDAQ:
pass
def __mount(self, target: SampleShortInfo | None):
pass
self.__devs.smargon_move_home()
self.__devs.aerotech_pos = ABR_POS_MOUNT
self.__devs.aerotech_omega = ABR_OMEGA_MOUNT
#collimator should be down!!!
self.__devs.tell.check_enable_motion()
self.__devs.tell.wait_mount_complete()
#self.__devs.tell.set_in_mount_position(True)
if target is None:
self.__devs.tell.unmount(wait=True, timeout=60.0)
else:
value = self.__devs.tell.mount(address=target.tell_address(), force=True, auto_unmount=True, read_dm=False,
wait=True, timeout=360.0)
logger.info(f"Mount result: {value}")
self.__cfg.current_sample = target
#self.__mount_failure_handler(value)
@sample.setter
def sample(self, target: SampleShortInfo | None):
pass
self.__cfg.try_set_busy(timeout=360)
curr_sample_is_manual=False
try:
curr_sample = self.__cfg.current_sample
workflows.common_2rse(devs=self.__devs, cfg=self.__cfg)
#if curr_sample is not None and curr_sample.location is None:
# self.__cfg.current_sample = None
# curr_sample_is_manual = True
#if target is not None or not curr_sample_is_manual:
logger.debug(target)
self.__mount(target)
logger.info(f"Sample mounted: {target}")
self.__aare.sample_mounted(target)
except Exception as e:
self.__cfg.state_busy = False
logger.debug(f"Failed to mount sample: {e}")
raise e
workflows.rse2sa(devs=self.__devs, cfg=self.__cfg)
self.__cfg.state_busy = False
@property
def camera_image(self) -> np.ndarray | None: