diff --git a/src/aare/daq/devices.py b/src/aare/daq/devices.py index 1560286b..df22843f 100644 --- a/src/aare/daq/devices.py +++ b/src/aare/daq/devices.py @@ -14,6 +14,7 @@ from epics import PV # - setter with option to do sync/async move # - property setter, which assumes that sync move is done (excl. zoom, which is async by default) from aare.beamline_dispatch.protocols import BeamlineDispatch +from aare.daq.samcam import BecSamCam from aare.devices import aerotech, smargon from aare.devices.area_detector import AutoEnum, epicsAD from aare.devices.bec_worker import BECClientWorker @@ -46,6 +47,7 @@ class BeamlineDevices: self.dtz_mod = cfg_get("daq.detector_distance_limit_modifier", 1.0) # TODO convert epics pvs to BEC self._sample_cam = epicsAD(f"{BEAMLINE}-ES-MS:") + self._samcam = BecSamCam(self.bec_worker) self._front_light = PredefinedPV( name="front_light", @@ -275,7 +277,7 @@ class BeamlineDevices: # Detector Z @property def dtz(self) -> float: - return self._dtz.user_setpoint.get() + return self._dtz.user_setpoint.get(cached=True) @property def dty(self) -> float: diff --git a/src/aare/daq/samcam.py b/src/aare/daq/samcam.py new file mode 100644 index 00000000..96935166 --- /dev/null +++ b/src/aare/daq/samcam.py @@ -0,0 +1,41 @@ +from __future__ import annotations + +from enum import Enum +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from aare.devices.bec_worker import BECClientWorker + + +class AutoEnum(Enum): + MANUAL = 0 + ONCE = 1 + AUTO = 2 + + +class BecSamCam: + def __init__(self, bec: BECClientWorker) -> None: + self.acquire = bec.dev.TODO + self.exposure = bec.dev.samcam_exp + self.gain = bec.dev.samcam_gain + self.gain_rbv = bec.dev.TODO + self.gain_rbv = bec.dev.TODO + self.gain_mode = bec.dev.TODO + self.expo_mode = bec.dev.TODO + self.uid = bec.dev.TODO + self.zoom = bec.dev.scam_zoom + + def setup(self, gain: float = 15, expo: float = 0.025): + self.acquire.put(0, wait=True) + self.gain_mode.put(0, wait=True) # manual gain control + self.gain.put(gain, wait=True) + self.expo_mode.put(0, wait=True) # manual exposure control + self.exposure.put(expo, wait=True) + self.acquire.put(1, wait=True) + + def set_auto(self, state: AutoEnum): + """Uses AutoEnum 0 is Manual, 1 is Once, 2 is Auto""" + self.acquire.put(0, wait=True) + self.gain_mode.put(state.value) # automatic gain control + self.expo_mode.put(state.value) # automatic exposure control + self.acquire.put(1)