Skip to content

Commit

Permalink
(DiamondLightSource/hyperion#779) Initial fluo optimise fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Jul 5, 2023
1 parent 4337a5f commit 1cab3a7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
12 changes: 12 additions & 0 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from dodal.devices.fast_grid_scan import FastGridScan
from dodal.devices.oav.oav_detector import OAV
from dodal.devices.s4_slit_gaps import S4SlitGaps
from dodal.devices.sample_shutter import SampleShutter
from dodal.devices.smargon import Smargon
from dodal.devices.synchrotron import Synchrotron
from dodal.devices.undulator import Undulator
Expand Down Expand Up @@ -252,3 +253,14 @@ def attenuator(
wait_for_connection,
fake_with_ophyd_sim,
)

def sample_shutter(
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
) -> Attenuator:
return device_instantiation(
SampleShutter,
"sample_shutter",
"-EA-SHTR-01:",
wait_for_connection,
fake_with_ophyd_sim,
)
18 changes: 18 additions & 0 deletions src/dodal/devices/sample_shutter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ophyd import Component, Device, EpicsSignal, EpicsSignalRO

from dodal.devices.status import await_value


class SampleShutter(Device):
"""Simple device to trigger the pneumatic in/out"""

CLOSE = 0
OPEN = 1

pos: EpicsSignal = Component(EpicsSignal, "CTRL2")
pos_rbv: EpicsSignal = Component(EpicsSignalRO, "STA")

def set(self, open: int):
sp_status = self.pos.set(open)
rbv_status = await_value(self.pos_rbv, open)
return sp_status & rbv_status
26 changes: 14 additions & 12 deletions src/dodal/devices/xspress3_mini/xspress3_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)
from ophyd.status import Status

from dodal.devices.status import await_value_in_list
from dodal.devices.status import await_value, await_value_in_list
from dodal.devices.xspress3_mini.xspress3_mini_channel import Xspress3MiniChannel
from dodal.log import LOGGER

Expand All @@ -37,13 +37,13 @@ class UpdateRBV(Enum):


class EraseState(Enum):
DONE = "Done"
ERASE = "Erase"
DONE = 0
ERASE = 1


class AcquireState(Enum):
DONE = "Done"
ACQUIRE = "Acquire"
DONE = 0
ACQUIRE = 1


class DetectorState(Enum):
Expand All @@ -70,15 +70,16 @@ def set(self, value, *, timeout=None, settle_time=None, **kwargs):
# Assume only one channel for now
channel_1 = Component(Xspress3MiniChannel, "C1_")

erase: EpicsSignal = Component(EpicsSignal, "ERASE")
erase: EpicsSignal = Component(EpicsSignal, "ERASE", string=True)
get_max_num_channels = Component(EpicsSignalRO, "MAX_NUM_CHANNELS_RBV")
acquire: EpicsSignal = Component(EpicsSignal, "Acquire")
acquire_rbv: EpicsSignalRO = Component(EpicsSignal, "Acquire_RBV")
get_roi_calc_mini: EpicsSignal = Component(EpicsSignal, "MCA1:Enable_RBV")
trigger_mode_mini: EpicsSignalWithRBV = Component(EpicsSignalWithRBV, "TriggerMode")
roi_start_x: EpicsSignal = Component(EpicsSignal, "ROISUM1:MinX")
roi_size_x: EpicsSignal = Component(EpicsSignal, "ROISUM1:SizeX")
acquire_time: EpicsSignal = Component(EpicsSignal, "AcquireTime")
detector_state: EpicsSignalRO = Component(EpicsSignalRO, "DetectorState_RBV")
detector_state: EpicsSignalRO = Component(EpicsSignalRO, "DetectorState_RBV", string=True)
NUMBER_ROIS_DEFAULT = 6
acquire_status: Status = None
dt_corrected_latest_mca: EpicsSignalRO = Component(EpicsSignalRO, "ARR1:ArrayData")
Expand All @@ -95,14 +96,15 @@ def stage(self):

def do_start(self) -> Status:
self.erase.put(EraseState.ERASE.value)
status = self.channel_1.update_arrays.set(AcquireState.DONE.value)
#status = self.channel_1.update_arrays.set(AcquireState.DONE.value)
# GDA code suggests this put does not callback until collection finished, for now just hold on to it
self.acquire_status = self.acquire.set(AcquireState.ACQUIRE.value)
return status
return self.acquire.set(AcquireState.ACQUIRE.value)

def arm(self) -> Status:
LOGGER.info("Arming Xspress3Mini detector...")
self.trigger_mode_mini.put(TriggerMode.BURST.value)
self.do_start().wait(timeout=10)
#self.do_start().wait(timeout=10)
arm_status = await_value_in_list(self.detector_state, self.detector_busy_states)
return arm_status
arm_status &= self.do_start()
arm_status.wait(1)
return await_value(self.acquire_rbv, 0)

0 comments on commit 1cab3a7

Please sign in to comment.