diff --git a/src/dodal/beamlines/i22.py b/src/dodal/beamlines/i22.py index e9aef4bdfd..2695742e95 100644 --- a/src/dodal/beamlines/i22.py +++ b/src/dodal/beamlines/i22.py @@ -10,7 +10,11 @@ ) from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline from dodal.common.beamlines.device_helpers import numbered_slits -from dodal.common.visit import DirectoryServiceClient, StaticVisitDirectoryProvider +from dodal.common.visit import ( + DirectoryServiceClient, + LocalDirectoryServiceClient, + StaticVisitDirectoryProvider, +) from dodal.devices.focusing_mirror import FocusingMirror from dodal.devices.i22.dcm import CrystalMetadata, DoubleCrystalMonochromator from dodal.devices.i22.fswitch import FSwitch @@ -34,25 +38,34 @@ # Communication with GDA is also WIP so for now we determine an arbitrary scan number # locally and write the commissioning directory. The scan number is not guaranteed to # be unique and the data is at risk - this configuration is for testing only. -set_directory_provider( +directory_provider = ( StaticVisitDirectoryProvider( + BL, + Path("/dls/p38/data/2024/cm37282-2/bluesky"), + client=LocalDirectoryServiceClient(), + ) + if IS_LAB + else StaticVisitDirectoryProvider( BL, Path("/dls/i22/data/2024/cm37271-2/bluesky"), client=DirectoryServiceClient("http://i22-control:8088/api"), ) ) +set_directory_provider(directory_provider) + +# d11 at p38, but disconnected def saxs( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> PilatusDetector: return device_instantiation( - NXSasPilatus, - "saxs", - "-EA-PILAT-01:", + AravisDetector if IS_LAB else NXSasPilatus, + "d11" if IS_LAB else "saxs", + "-DI-DCAM-03:" if IS_LAB else "-EA-PILAT-01:", wait_for_connection, fake_with_ophyd_sim, - drv_suffix="CAM:", + drv_suffix="DET:" if IS_LAB else "CAM:", hdf_suffix="HDF5:", metadata_holder=NXSasMetadataHolder( x_pixel_size=(1.72e-1, "mm"), @@ -67,6 +80,7 @@ def saxs( ) +# todo this is not available at p38 def synchrotron( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> Synchrotron: @@ -79,16 +93,17 @@ def synchrotron( ) +# d12 at p38 def waxs( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> PilatusDetector: return device_instantiation( - NXSasPilatus, - "waxs", - "-EA-PILAT-03:", + AravisDetector if IS_LAB else NXSasPilatus, + "d12" if IS_LAB else "waxs", + "-DI-DCAM-04:" if IS_LAB else "-EA-PILAT-03:", wait_for_connection, fake_with_ophyd_sim, - drv_suffix="CAM:", + drv_suffix="DET:" if IS_LAB else "CAM:", hdf_suffix="HDF5:", metadata_holder=NXSasMetadataHolder( x_pixel_size=(1.72e-1, "mm"), @@ -203,6 +218,13 @@ def undulator( ) +# +# The following devices are fake by default since P38 has no optics, +# but having mock devices here means they will be reflected in downstream data +# processing, where they may be required. +# + + def slits_1( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False, @@ -286,6 +308,7 @@ def fswitch( ) +# Must find which PandA IOC(s) are compatible # Must document what PandAs are physically connected to # See: https://github.com/bluesky/ophyd-async/issues/284 def panda1( @@ -337,6 +360,9 @@ def panda4( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False, ) -> HDFPanda: + # todo skip if at p38 + if IS_LAB: + raise SystemError("no panda4 at the p38 lab") return device_instantiation( HDFPanda, "panda4", @@ -347,13 +373,14 @@ def panda4( ) +# d3 at p38 def oav( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> AravisDetector: return device_instantiation( - NXSasOAV, - "oav", - "-DI-OAV-01:", + AravisDetector if IS_LAB else NXSasOAV, + "d3" if IS_LAB else "oav", + f"-DI-{'DCAM' if IS_LAB else 'OAV'}-01:", wait_for_connection, fake_with_ophyd_sim, drv_suffix="DET:", @@ -376,6 +403,7 @@ def linkam( Linkam3, "linkam", "-EA-TEMPC-05" if IS_LAB else "-EA-TEMPC-05", + # note alternatively -EA-LINKM-02: wait_for_connection, fake_with_ophyd_sim, ) diff --git a/src/dodal/beamlines/p38.py b/src/dodal/beamlines/p38.py deleted file mode 100644 index 17ad9c9dd0..0000000000 --- a/src/dodal/beamlines/p38.py +++ /dev/null @@ -1,320 +0,0 @@ -from pathlib import Path - -from ophyd_async.epics.areadetector import AravisDetector -from ophyd_async.panda import HDFPanda - -from dodal.common.beamlines.beamline_utils import ( - device_instantiation, - get_directory_provider, - set_directory_provider, -) -from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline -from dodal.common.beamlines.device_helpers import numbered_slits -from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitDirectoryProvider -from dodal.devices.focusing_mirror import FocusingMirror -from dodal.devices.i22.dcm import CrystalMetadata, DoubleCrystalMonochromator -from dodal.devices.i22.fswitch import FSwitch -from dodal.devices.linkam3 import Linkam3 -from dodal.devices.slits import Slits -from dodal.devices.tetramm import TetrammDetector -from dodal.devices.undulator import Undulator -from dodal.log import set_beamline as set_log_beamline -from dodal.utils import BeamlinePrefix, get_beamline_name, skip_device - -BL = get_beamline_name("p38") -set_log_beamline(BL) -set_utils_beamline(BL) - -# Currently we must hard-code the visit, determining the visit at runtime requires -# infrastructure that is still WIP. -# Communication with GDA is also WIP so for now we determine an arbitrary scan number -# locally and write the commissioning directory. The scan number is not guaranteed to -# be unique and the data is at risk - this configuration is for testing only. -set_directory_provider( - StaticVisitDirectoryProvider( - BL, - Path("/dls/p38/data/2024/cm37282-2/bluesky"), - client=LocalDirectoryServiceClient(), - ) -) - - -def d3( - wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False -) -> AravisDetector: - return device_instantiation( - AravisDetector, - "d3", - "-DI-DCAM-01:", - wait_for_connection, - fake_with_ophyd_sim, - drv_suffix="DET:", - hdf_suffix="HDF5:", - directory_provider=get_directory_provider(), - ) - - -# Disconnected -@skip_device -def d11( - wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False -) -> AravisDetector: - return device_instantiation( - AravisDetector, - "d11", - "-DI-DCAM-03:", - wait_for_connection, - fake_with_ophyd_sim, - drv_suffix="DET:", - hdf_suffix="HDF5:", - directory_provider=get_directory_provider(), - ) - - -def d12( - wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False -) -> AravisDetector: - return device_instantiation( - AravisDetector, - "d12", - "-DI-DCAM-04:", - wait_for_connection, - fake_with_ophyd_sim, - drv_suffix="DET:", - hdf_suffix="HDF5:", - directory_provider=get_directory_provider(), - ) - - -def i0( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = False, -) -> TetrammDetector: - return device_instantiation( - TetrammDetector, - "i0", - "-EA-XBPM-01:", - wait_for_connection, - fake_with_ophyd_sim, - directory_provider=get_directory_provider(), - ) - - -# -# The following devices are created as fake by default since P38 has no optics, -# but having mock devices here means they will be reflected in downstream data -# processing, where they may be required. -# - - -def slits_1( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 1, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def slits_2( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 2, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def slits_3( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 3, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def slits_4( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 4, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def slits_5( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 5, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def slits_6( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Slits: - return numbered_slits( - 6, - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def fswitch( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> FSwitch: - return device_instantiation( - FSwitch, - "fswitch", - "-MO-FSWT-01:", - wait_for_connection, - fake_with_ophyd_sim, - lens_geometry="paraboloid", - cylindrical=True, - lens_material="Beryllium", - ) - - -def vfm( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> FocusingMirror: - return device_instantiation( - FocusingMirror, - "vfm", - "-OP-KBM-01:VFM:", - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def hfm( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> FocusingMirror: - return device_instantiation( - FocusingMirror, - "hfm", - "-OP-KBM-01:HFM:", - wait_for_connection, - fake_with_ophyd_sim, - ) - - -def dcm( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> DoubleCrystalMonochromator: - return device_instantiation( - DoubleCrystalMonochromator, - "dcm", - "", - wait_for_connection, - fake_with_ophyd_sim, - bl_prefix=False, - motion_prefix=f"{BeamlinePrefix(BL).beamline_prefix}-MO-DCM-01:", - temperature_prefix=f"{BeamlinePrefix(BL).beamline_prefix}-DI-DCM-01:", - crystal_1_metadata=CrystalMetadata( - usage="Bragg", - type="silicon", - reflection=(1, 1, 1), - d_spacing=3.13475, - ), - crystal_2_metadata=CrystalMetadata( - usage="Bragg", - type="silicon", - reflection=(1, 1, 1), - d_spacing=3.13475, - ), - ) - - -def undulator( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = True, -) -> Undulator: - return device_instantiation( - Undulator, - "undulator", - f"{BeamlinePrefix(BL).insertion_prefix}-MO-SERVC-01:", - wait_for_connection, - fake_with_ophyd_sim, - bl_prefix=False, - poles=80, - length=2.0, - ) - - -# Must find which PandA IOC(s) are compatible -# Must document what PandAs are physically connected to -# See: https://github.com/bluesky/ophyd-async/issues/284 -@skip_device -def panda1( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = False, -) -> HDFPanda: - return device_instantiation( - HDFPanda, - "panda1", - "-EA-PANDA-01:", - wait_for_connection, - fake_with_ophyd_sim, - directory_provider=get_directory_provider(), - ) - - -@skip_device -def panda2( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = False, -) -> HDFPanda: - return device_instantiation( - HDFPanda, - "panda2", - "-EA-PANDA-02:", - wait_for_connection, - fake_with_ophyd_sim, - directory_provider=get_directory_provider(), - ) - - -@skip_device -def panda3( - wait_for_connection: bool = True, - fake_with_ophyd_sim: bool = False, -) -> HDFPanda: - return device_instantiation( - HDFPanda, - "panda3", - "-EA-PANDA-03:", - wait_for_connection, - fake_with_ophyd_sim, - directory_provider=get_directory_provider(), - ) - - -@skip_device -def linkam( - wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False -) -> Linkam3: - return device_instantiation( - Linkam3, - "linkam", - "-EA-LINKM-02:", - wait_for_connection, - fake_with_ophyd_sim, - )