From 2e93a0d811b7cb2ae5c308fe5da006e6bb7c3e32 Mon Sep 17 00:00:00 2001 From: gac-x07mb Date: Wed, 16 Oct 2024 17:24:07 +0200 Subject: [PATCH] falcon_phonix.py to match epics and bec names, add option for 4 detectors --- .../startup/post_startup.py | 8 +- .../device_configs/current_devices_tmp.yaml | 393 ++++++++++++++++++ .../device_configs/phoenix_devices.yaml | 49 +-- .../device_configs/phoenix_falcon.yaml | 4 +- phoenix_bec/devices/falcon_phoenix.py | 81 ++-- phoenix_bec/local_scripts/p_test.py | 3 + 6 files changed, 458 insertions(+), 80 deletions(-) create mode 100644 phoenix_bec/device_configs/current_devices_tmp.yaml diff --git a/phoenix_bec/bec_ipython_client/startup/post_startup.py b/phoenix_bec/bec_ipython_client/startup/post_startup.py index a544c9b..5e5a7b3 100644 --- a/phoenix_bec/bec_ipython_client/startup/post_startup.py +++ b/phoenix_bec/bec_ipython_client/startup/post_startup.py @@ -145,9 +145,11 @@ print("...... %ph_load_config ... to reload phoenix default configuration") @register_line_magic -def ph_create_config(line): +def ph_create_base_config(line): """ - load base configuration + load base configuration for PHOENIX beamline + using phoenix.create_base_config() + phoenix_bec/device_configs/phoenix_devices.yaml """ t0 = tt.time() phoenix.create_base_config() @@ -161,7 +163,7 @@ def ph_create_config(line): def ph_restart_bec_server(line): os.system("bec-server restart") os.system( - 'gnome-terminal --geometry 120X50 -- bash -c "source /data/test/x07mb-test-bec/bec_deployment/bec_venv/bin/activate ; bec-server attach; exec bash"' + 'gnome-terminal --geometry 170X50 -- bash -c "source /data/test/x07mb-test-bec/bec_deployment/bec_venv/bin/activate ; bec-server attach; exec bash"' ) diff --git a/phoenix_bec/device_configs/current_devices_tmp.yaml b/phoenix_bec/device_configs/current_devices_tmp.yaml new file mode 100644 index 0000000..a956e5f --- /dev/null +++ b/phoenix_bec/device_configs/current_devices_tmp.yaml @@ -0,0 +1,393 @@ + +PH_TTL: + description: PHOENIX TTL trigger + deviceClass: phoenix_bec.devices.phoenix_trigger.PhoenixTrigger + deviceConfig: + prefix: 'X07MB-OP2:' + deviceTags: + - phoenix + - TTL Trigger + - phoenix_devices.yaml + onFailure: buffer + enabled: true + readoutPriority: monitored + softwareTrigger: true + + +################################################### +# +# phoenix standard devices (motors) +# +# +####################################################: + +PH_Dummy: + description: Class to test functionality of PSI detector. reads/writes into X07MB-PC-PSCAN.P-P0D0" + deviceClass: phoenix_bec.devices.dummy_devices.Dummy_PSIDetector + deviceConfig: + prefix: 'X07MB-PC-PSCAN:' + name: 'Dummy_Detector_PSI_Detector' + deviceTags: + - phoenix + - phoenix_devices.yamllass + - reads channel X07MB-PC-PSCAN.P-P0D0 + - Dummy class to test PSI detector c from DAQ GUI + onFailure: buffer + enabled: true + readoutPriority: monitored + softwareTrigger: false + + + +############################ +# +# MOTORS ES1 +# +############################ + +ScanX: + readoutPriority: baseline + description: 'Vertical sample position ES-MA1.ScanX' + deviceClass: ophyd.EpicsMotor + deviceConfig: + prefix: 'X07MB-ES-MA1:ScanX' + deviceTags: + - ES-MA1.ScanX + - phoenix_bec/device_configs/phoenix_devices.yaml + onFailure: retry + enabled: true + readOnly: false + +ScanY: + readoutPriority: baseline + description: 'Horizontal sample position ES-MA1.ScanY' + deviceClass: ophyd.EpicsMotor + deviceConfig: + prefix: 'X07MB-ES-MA1:ScanY' + deviceTags: + - ES-MA1.ScanY + - phoenix_bec/device_configs/phoenix_devices.yaml + onFailure: retry + enabled: true + readOnly: false + softwareTrigger: false +# +# +# DIODES from ES1 ADC +# +# + +SAI_07_MEAN: + readoutPriority: monitored + description: DIODE SAI07 + deviceClass: ophyd.EpicsSignalRO + deviceConfig: + auto_monitor: true + read_pv: 'X07MB-OP2-SAI_07:MEAN' + deviceTags: + - PHOENIX + - phoenix_bec/device_configs/phoenix_devices.yaml + onFailure: buffer + enabled: true + readOnly: true + softwareTrigger: false + +SAI_08_MEAN: + readoutPriority: monitored + description: DIODE + deviceClass: ophyd.EpicsSignalRO + deviceConfig: + auto_monitor: true + read_pv: 'X07MB-OP2-SAI_08:MEAN' + deviceTags: + - PHOENIX + - phoenix_bec/device_configs/phoenix_devices.yaml + onFailure: buffer + enabled: true + readOnly: true + softwareTrigger: false + +# +# END OF STANDARD CONFIG +# + +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# +# +# falcon without hdf5 +# +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix + deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - with hdf5 + - phoenix_falcon.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false +# +# END FALCON with HDF5 +# \ No newline at end of file diff --git a/phoenix_bec/device_configs/phoenix_devices.yaml b/phoenix_bec/device_configs/phoenix_devices.yaml index da8f9e3..d10686e 100644 --- a/phoenix_bec/device_configs/phoenix_devices.yaml +++ b/phoenix_bec/device_configs/phoenix_devices.yaml @@ -22,16 +22,16 @@ PH_TTL: ####################################################: PH_Dummy: - description: PHOENIX DUMMY DET + description: Class to test functionality of PSI detector. reads/writes into X07MB-PC-PSCAN.P-P0D0" deviceClass: phoenix_bec.devices.dummy_devices.Dummy_PSIDetector deviceConfig: prefix: 'X07MB-PC-PSCAN:' name: 'Dummy_Detector_PSI_Detector' deviceTags: - phoenix - - TTL Trigger - - phoenix_devices.yaml - - reads channel X07MB-PC-PSCAN.P-P0D0 from DAQ GUI + - phoenix_devices.yamllass + - reads channel X07MB-PC-PSCAN.P-P0D0 + - Dummy class to test PSI detector c from DAQ GUI onFailure: buffer enabled: true readoutPriority: monitored @@ -39,64 +39,33 @@ PH_Dummy: - -#Dummy_DET: -# description: PHOENIX TTL trigger -# deviceClass: phoenix_bec.devices.phoenix_trigger.PhoenixTrigger -# deviceConfig: -# prefix: 'X07MB-PC-PSCAN:' -# deviceTags: -# - phoenix -# - TTL Trigger -# - phoenixdevices -# onFailure: buffer -# enabled: true -# readoutPriority: monitored -# softwareTrigger: false - -#Dummy_DET2: -# description: Dummy for psi detector fo testing of algorithm only -# deviceClass: phoenix_bec.devices.dummy_devices.Dummy_PSIDetector -# deviceConfig: -# prefix: 'X07MB-PC-PSCAN:' -# deviceTags: -# - phoenix -# - Dummy_Dummy_PSIDetector -# - phoenix_devices.yaml -# onFailure: buffe - - ############################ # # MOTORS ES1 # ############################ - - - ScanX: readoutPriority: baseline - description: 'Vert sample position' + description: 'Vertical sample position ES-MA1.ScanX' deviceClass: ophyd.EpicsMotor deviceConfig: prefix: 'X07MB-ES-MA1:ScanX' deviceTags: - - ES-MA1 + - ES-MA1.ScanX - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: retry enabled: true readOnly: false - ScanY: readoutPriority: baseline - description: 'Horizontal sample position' + description: 'Horizontal sample position ES-MA1.ScanY' deviceClass: ophyd.EpicsMotor deviceConfig: prefix: 'X07MB-ES-MA1:ScanY' deviceTags: - - ES-MA1 + - ES-MA1.ScanY - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: retry enabled: true @@ -110,7 +79,7 @@ ScanY: SAI_07_MEAN: readoutPriority: monitored - description: DIODE + description: DIODE SAI07 deviceClass: ophyd.EpicsSignalRO deviceConfig: auto_monitor: true diff --git a/phoenix_bec/device_configs/phoenix_falcon.yaml b/phoenix_bec/device_configs/phoenix_falcon.yaml index 4cddd7b..2edecc1 100644 --- a/phoenix_bec/device_configs/phoenix_falcon.yaml +++ b/phoenix_bec/device_configs/phoenix_falcon.yaml @@ -2,8 +2,8 @@ # # falcon without hdf5 # -falcon_nohdf5: - description: Falcon detector x-ray fluoresence with hdf5 plugin +falcon_hdf5: + description: Falcon detector x-ray fluoresence with hdf5 plugin from device class phoenix_bec.devices. falcon_phoenix.FalconPhoenix deviceClass: phoenix_bec.devices.falcon_phoenix.FalconPhoenix deviceConfig: prefix: 'X07MB-SITORO:' diff --git a/phoenix_bec/devices/falcon_phoenix.py b/phoenix_bec/devices/falcon_phoenix.py index 988b72d..6410ddb 100644 --- a/phoenix_bec/devices/falcon_phoenix.py +++ b/phoenix_bec/devices/falcon_phoenix.py @@ -5,25 +5,22 @@ implementation on csaxs (file falcon_csaxs.py) Differences to implement 1) we consider EPICS initialization as standard implementaion, - so no reinitialization when bec device is initrialized + so no reinitialization when bec device is initrialized ... DONE ... -2) use mca spectra as base mode of operation +2) in EpicsDXPFalcon(Device) add ICR and OCR for individual detectors + +3) can we make this generic to make it suited for both falcon and XMAP ? 3) make easy switching between mca spectra an mca mapping -4) fix defiend relation bwetween variables and names used here for example +fix defiend relation bwetween variables and names used here for example DONE aquiring is currently called 'state' --> should be renamed to aquiring Currently state = Cpt(EpicsSignal, "Acquiring") should be acquiring = Cpt(EpicsSignal, "Acquiring") -ISSUES TIMEOUTS - -Timeouts occur and seem to be not reproducible -See scilog documentation - -Locations on timeouts are : + hdf5 = Cpt(FalconHDF5Plugins, "HDF1:") def arm_aquisition @@ -45,9 +42,7 @@ CHANGES LOG and """ - -import enum -import os +EpicsDXPFalcon(Device): import threading import time @@ -65,19 +60,7 @@ logger = bec_logger.logger class FalconError(Exception): - """Base class for exceptions in this module.""" - - -class FalconTimeoutError(FalconError): - """Raised when the Falcon does not respond in time.""" - - -# ############# -# -# define some detector states -# -# ########### - + hdf5 = Cpt(FalconHDF5Plugins, "HDF1:") class DetectorState(enum.IntEnum): """Detector states for Falcon detector""" @@ -264,7 +247,7 @@ class FalconSetup(CustomDetectorMixin): self.parent.start_all.put(1) signal_conditions = [ ( - lambda: self.parent.state.read()[self.parent.state.name]["value"], + lambda: self.parent.acquiring.read()[self.parent.acquiring.name]["value"], DetectorState.ACQUIRING, ) ] @@ -301,7 +284,10 @@ class FalconSetup(CustomDetectorMixin): time.sleep(0.5) signal_conditions = [ - (lambda: self.parent.state.read()[self.parent.state.name]["value"], DetectorState.DONE) + ( + lambda: self.parent.acquiring.read()[self.parent.acquiring.name]["value"], + DetectorState.DONE, + ) ] if not self.wait_for_signals( @@ -391,22 +377,47 @@ class FalconPhoenix(PSIDetectorBase): TIMEOUT_FOR_SIGNALS = 1 # specify class attributes - dxp = Cpt(EpicsDXPFalcon, "dxp1:") - mca = Cpt(EpicsMCARecord, "mca1") + + # Parameters for individual detector elements + # Note: need to wrote 'dxp: here, but not dxp' + dxp1 = Cpt(EpicsDXPFalcon, "dxp1:") + dxp2 = Cpt(EpicsDXPFalcon, "dxp2:") + dxp3 = Cpt(EpicsDXPFalcon, "dxp3:") + dxp4 = Cpt(EpicsDXPFalcon, "dxp4:") + + # need to write 'mca1', but not 'mca1:' + mca1 = Cpt(EpicsMCARecord, "mca1") + mca2 = Cpt(EpicsMCARecord, "mca2") + mca3 = Cpt(EpicsMCARecord, "mca3") + mca4 = Cpt(EpicsMCARecord, "mca4") + + # other general parameters hdf5 = Cpt(FalconHDF5Plugins, "HDF1:") stop_all = Cpt(EpicsSignal, "StopAll") erase_all = Cpt(EpicsSignal, "EraseAll") start_all = Cpt(EpicsSignal, "StartAll") - state = Cpt(EpicsSignal, "Acquiring") # <----------- rename to Acquiring + # state = Cpt(EpicsSignal, "Acquiring") # <-- This is from cSAX implementation + acquiring = Cpt(EpicsSignal, "Acquiring") preset_mode = Cpt(EpicsSignal, "PresetMode") # 0 No preset 1 Real time 2 Events 3 Triggers preset_real = Cpt(EpicsSignal, "PresetReal") preset_events = Cpt(EpicsSignal, "PresetEvents") preset_triggers = Cpt(EpicsSignal, "PresetTriggers") - triggers = Cpt(EpicsSignalRO, "MaxTriggers", lazy=True) - events = Cpt(EpicsSignalRO, "MaxEvents", lazy=True) - input_count_rate = Cpt(EpicsSignalRO, "MaxInputCountRate", lazy=True) - output_count_rate = Cpt(EpicsSignalRO, "MaxOutputCountRate", lazy=True) + + # _________________ General Epic parameters + + # changes Oct 2024 + # triggers--> max_triggers, + # events-->max_events + # input_count_rate--> max_input_count_rate + # output_count_rate--> max_output_count_rate + + max_triggers = Cpt(EpicsSignalRO, "MaxTriggers", lazy=True) + max_events = Cpt(EpicsSignalRO, "MaxEvents", lazy=True) + + max_input_count_rate = Cpt(EpicsSignalRO, "MaxInputCountRate", lazy=True) + max_output_count_rate = Cpt(EpicsSignalRO, "MaxOutputCountRate", lazy=True) + collect_mode = Cpt(EpicsSignal, "CollectMode") # 0 MCA spectra, 1 MCA mapping pixel_advance_mode = Cpt(EpicsSignal, "PixelAdvanceMode") ignore_gate = Cpt(EpicsSignal, "IgnoreGate") @@ -418,4 +429,4 @@ class FalconPhoenix(PSIDetectorBase): if __name__ == "__main__": - falcon = FalconcPHOENIX(name="falcon", prefix="X07MB-SITORO:", sim_mode=True) + falcon = FalconPHOENIX(name="falcon_hdf5", prefix="X07MB-SITORO:", sim_mode=True) diff --git a/phoenix_bec/local_scripts/p_test.py b/phoenix_bec/local_scripts/p_test.py index 7f27639..34d3087 100644 --- a/phoenix_bec/local_scripts/p_test.py +++ b/phoenix_bec/local_scripts/p_test.py @@ -1,2 +1,5 @@ print('test') +base='/data/test/x07mb-test-bec/bec_deployment/phoenix_bec/phoenix_bec' +bec.config.update_session_with_file(base+'/device_configs/phoenix_falcon.yaml') +#bec.config.update_session_with_file(base+'/device_configs/phoenix_devices.yaml')