From 48f20434e60ccd628c201d3e6c9104e53565c0c6 Mon Sep 17 00:00:00 2001 From: gac-x07mb Date: Thu, 8 Aug 2024 17:11:31 +0200 Subject: [PATCH] PHOENIX Version 1 8.8.2024 --- .../startup/post_startup.py | 91 +++++++++++++------ .../bec_ipython_client/startup/pre_startup.py | 3 + .../device_configs/phoenix_devices.yaml | 52 +++-------- .../device_configs/phoenix_devices.yaml_XXX | 88 ++++++++++++++++++ .../device_configs/phoenix_falcon.yaml | 14 +++ phoenix_bec/device_configs/phoenix_xmap.yaml | 14 +++ phoenix_bec/devices/xmap_phoenix_no_hdf5.py | 2 + .../Current_setup.txt | 3 + phoenix_bec/scripts/phoenix.py | 31 +++---- 9 files changed, 214 insertions(+), 84 deletions(-) create mode 100644 phoenix_bec/device_configs/phoenix_devices.yaml_XXX create mode 100644 phoenix_bec/device_configs/phoenix_falcon.yaml create mode 100644 phoenix_bec/device_configs/phoenix_xmap.yaml rename phoenix_bec/{local_scripts/Documentation => scripts}/Current_setup.txt (87%) diff --git a/phoenix_bec/bec_ipython_client/startup/post_startup.py b/phoenix_bec/bec_ipython_client/startup/post_startup.py index cf4d82d..a5ab5fe 100644 --- a/phoenix_bec/bec_ipython_client/startup/post_startup.py +++ b/phoenix_bec/bec_ipython_client/startup/post_startup.py @@ -33,24 +33,36 @@ to setup the prompts. logger.success("cSAXS session loaded.") """ +from IPython.core.magic import register_line_magic + # pylint: disable=invalid-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module import sys # SETUP PROMPTS bec._ip.prompts.username = "PHOENIX" bec._ip.prompts.status = 1 +""" # make sure that edited modules are reloaded when changed print('post_startup.py : set autoreload of modules') -bec._ip.run_line_magic("load_ext","autoreload") + +#def load_autoreload(): +# bec._ip.run_line_magic("reload_ext","autoreload") + +#try: +# #load_autoreload() +# bec._ip.run_line_magic("reload_ext","autoreload") +# print('1xn_line_magic("reload_ext","autoreload") bec._ip.run_line_magic("autoreload", "2") +print('autoreload loaded ') + +# define some adional magic for PHOENIX ########### # -# -# next lines are not ideal and likely need to be removed they are a temporaty fix as we had trouble finding certain paths. +# next lines are not ideal and likely need to be removed they are a temporary fix as we had trouble finding certain paths. # # we need to work in server_env, otherwise no server is found # path to ophyd devices is only way to find default ophyd devices @@ -72,32 +84,57 @@ if ophyd_devices_path not in sys.path: if p_path not in sys.path: sys.path.insert(1, os.path.expandvars(p_path)) -#endif -print('init phoenix=PhoenixBL()') +#endif -phoenix=PhoenixBL() -#... provide info about currently uses paths and directories -phoenix.show_phoenix_setup() -""" -print('') -print('Current setup for bec --- to be professionanlized ') -print('use ') -print('/phoenix_bec/phoenix_bec/bec_ipython_client/startup/post_startup.py') -print('..................... for commands to start/init bec iphython shell') -print('......................here we init phoenix=PhoenixBL()') -print('') -print('/bec_deployment/phoenix_bec/phoenix_bec/scripts ') -print(' --- autoloaded scripts directory ') -print(' ... file PhoenixBL in phoenix.py defines BL core functions ') -print('') -print('/bec_deployment/phoenix_bec/phoenix_bec/devices') -print(' .... yamal files for device ') -print('/bec_deployment/phoenix_bec/phoenix_bec/local_scripts') -print(' .... collection of local scripts for testing purposes') -print('re run this file by ') -print('phoenix_bec/bec_ipython_client/startup/post_startup.py') -""" +############################################################################# +# +#... register BL specific magic comands +# +############################################################################## + +@register_line_magic +def ph_reload(line): + ########################################################################## + # + # this reloads certain phoenix related script to the iphython shell. + # useful for debugging/development to be revised for production + # aiom of this magic is to quickl reload BL related stuff for debugginf + # + # ####################################################################### + print('reload phoenix_bec.scripts.phoenix to iphyhton console') + print('to update version server restart server ') + global PH,phoenix + print('from phoenix_bec.scripts import phoenix as PH') + from phoenix_bec.scripts import phoenix as PH + print('phoenix = PH.PhoenixBL()') + phoenix = PH.PhoenixBL() +#enddef + + +##@register_line_magic +#def ph_post_startup(line): +# print('import phoenix_bec.bec_ipython_client.startup.post_startup does not work caused loop ') +# #import phoenix_bec.bec_ipython_client.startup.post_startup +# does not work seems to build a infinite stack... + +#################################################################################### +# +# init phoenix.py from server version as +# .................. phoenix_server=PhoenixBL() +# and in ipython shell only as +# .............. phoenix = Ph.Pheonix(BL() +# +##################################################################################### + +print('init phoenix_server = PhoenixBL() ... from server version ') +phoenix_server=PhoenixBL() + +print('init phoenix=PH.PhoenixBL() ... on inpython shell onlz (for debugging)') +from phoenix_bec.scripts import phoenix as PH +phoenix = PH.PhoenixBL() + #from phoenix_bec.bec_ipython_client.plugins.phoenix import Phoenix #from phoenix_bec.devices.falcon_phoenix_no_hdf5 import FalconHDF5Plugins +""" \ No newline at end of file diff --git a/phoenix_bec/bec_ipython_client/startup/pre_startup.py b/phoenix_bec/bec_ipython_client/startup/pre_startup.py index e22e554..e441b89 100644 --- a/phoenix_bec/bec_ipython_client/startup/pre_startup.py +++ b/phoenix_bec/bec_ipython_client/startup/pre_startup.py @@ -21,3 +21,6 @@ def extend_command_line_args(parser): # Create and return the service configuration. # """ # return ServiceConfig(redis={"host": "localhost", "port": 6379}) + + + diff --git a/phoenix_bec/device_configs/phoenix_devices.yaml b/phoenix_bec/device_configs/phoenix_devices.yaml index 104b08f..82eaec4 100644 --- a/phoenix_bec/device_configs/phoenix_devices.yaml +++ b/phoenix_bec/device_configs/phoenix_devices.yaml @@ -1,47 +1,23 @@ -#falcon_nohdf5: -# description: Falcon detector x-ray fluoresence II -# deviceClass: phoenix_bec.devices.falcon_phoenix_no_hdf5.FalconcSAXS -# deviceConfig: -# prefix: 'X07MB-SITORO:' -# deviceTags: -# - phoenix -# - falcon -# - no hdf5 -# - phoenix_devices.yaml -# onFailure: buffer -# enabled: true -# readoutPriority: async -# softwareTrigger: false - - -xmap_nohdf5: - description: Falcon detector x-ray fluoresence II - deviceClass: phoenix_bec.devices.xmap_phoenix_no_hdf5.XMAPphoenix - deviceConfig: - prefix: 'X07MB-XMAP:' - deviceTags: - - phoenix - - xmap - - no hdf5 - - phoenix_devices.yaml - onFailure: buffer - enabled: true - readoutPriority: async - softwareTrigger: false +################################################### +# +# phoenix standard devices (motors) +# +# +##################################################### # # MOTORS ES1 # -ScanX: +ScanXX: readoutPriority: baseline description: 'Horizontal sample position' deviceClass: ophyd.EpicsMotor - deviceConfig: - prefix: 'X07MB-ES-MA1:ScanX' + deviceConfig: + prefix: 'X07MB-ES-MA1:ScanX' deviceTags: - ES-MA1 - - phoenix_devices.yaml + - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: retry enabled: true readOnly: false @@ -55,7 +31,7 @@ ScanY: prefix: 'X07MB-ES-MA1:ScanY' deviceTags: - ES-MA1 - - phoenix_devices.yaml + - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: retry enabled: true readOnly: false @@ -72,10 +48,10 @@ SAI_07_MEAN: deviceClass: ophyd.EpicsSignalRO deviceConfig: auto_monitor: true - read_pv: 'X07MB-OP2-SAI_07:MEAN' + read_pv: 'X07MB-OP2-SAI_07:MEAN' deviceTags: - PHOENIX - - phoenix_devices.yaml + - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: buffer enabled: true readOnly: true @@ -90,7 +66,7 @@ SAI_08_MEAN: read_pv: 'X07MB-OP2-SAI_08:MEAN' deviceTags: - PHOENIX - - phoenix_devices.yaml + - phoenix_bec/device_configs/phoenix_devices.yaml onFailure: buffer enabled: true readOnly: true diff --git a/phoenix_bec/device_configs/phoenix_devices.yaml_XXX b/phoenix_bec/device_configs/phoenix_devices.yaml_XXX new file mode 100644 index 0000000..7c277a8 --- /dev/null +++ b/phoenix_bec/device_configs/phoenix_devices.yaml_XXX @@ -0,0 +1,88 @@ +falcon_nohdf5: + description: Falcon detector x-ray fluoresence II + deviceClass: phoenix_bec.devices.falcon_phoenix_no_hdf5.FalconcSAXS + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - no hdf5 + - phoenix_devices.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false + +xmap_nohdf5: + description: Falcon detector x-ray fluoresence II + deviceClass: phoenix_bec.devices.xmap_phoenix_no_hdf5.XMAPphoenix + deviceConfig: + prefix: 'X07MB-XMAP:' + deviceTags: + - phoenix + - xmap + - no hdf5 + - phoenix_bec/device_configs/phoenix_devices.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false + +# +# MOTORS ES1 +# + +ScanXX: + readoutPriority: baseline + description: 'Horizontal sample position' + deviceClass: ophyd.EpicsMotor + deviceConfig: + +ScanY: + readoutPriority: baseline + description: 'Horizontal sample position' + deviceClass: ophyd.EpicsMotor + deviceConfig: + prefix: 'X07MB-ES-MA1:ScanY' + deviceTags: + - ES-MA1 + - 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 + deviceClass: ophyd.EpicsSignalRO + deviceConfig: + auto_monitor: true + read_pv: 'X07MB-OP2-SAI_07:MEAN' a + 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 \ No newline at end of file diff --git a/phoenix_bec/device_configs/phoenix_falcon.yaml b/phoenix_bec/device_configs/phoenix_falcon.yaml new file mode 100644 index 0000000..e0c92d5 --- /dev/null +++ b/phoenix_bec/device_configs/phoenix_falcon.yaml @@ -0,0 +1,14 @@ +falcon_nohdf5: + description: Falcon detector x-ray fluoresence II + deviceClass: phoenix_bec.devices.falcon_phoenix_no_hdf5.FalconcSAXS + deviceConfig: + prefix: 'X07MB-SITORO:' + deviceTags: + - phoenix + - falcon + - no hdf5 + - phoenix_devices.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false diff --git a/phoenix_bec/device_configs/phoenix_xmap.yaml b/phoenix_bec/device_configs/phoenix_xmap.yaml new file mode 100644 index 0000000..38e0396 --- /dev/null +++ b/phoenix_bec/device_configs/phoenix_xmap.yaml @@ -0,0 +1,14 @@ +xmap_nohdf5: + description: Falcon detector x-ray fluoresence II + deviceClass: phoenix_bec.devices.xmap_phoenix_no_hdf5.XMAPphoenix + deviceConfig: + prefix: 'X07MB-XMAP:' + deviceTags: + - phoenix + - xmap + - no hdf5 + - phoenix_bec/device_configs/phoenix_xmap.yaml + onFailure: buffer + enabled: true + readoutPriority: async + softwareTrigger: false diff --git a/phoenix_bec/devices/xmap_phoenix_no_hdf5.py b/phoenix_bec/devices/xmap_phoenix_no_hdf5.py index 5fb9240..bcbe008 100644 --- a/phoenix_bec/devices/xmap_phoenix_no_hdf5.py +++ b/phoenix_bec/devices/xmap_phoenix_no_hdf5.py @@ -334,10 +334,12 @@ class XMAPphoenix(PSIDetectorBase): # specify class attributes dxp = Cpt(EpicsDXPXMAP, "dxp1:") + mca1 = Cpt(EpicsMCARecord, "mca1") mca2 = Cpt(EpicsMCARecord, "mca2") mca3 = Cpt(EpicsMCARecord, "mca3") mca4 = Cpt(EpicsMCARecord, "mca4") + hdf5 = Cpt(XMAPHDF5Plugins, "HDF1:") stop_all = Cpt(EpicsSignal, "StopAll") diff --git a/phoenix_bec/local_scripts/Documentation/Current_setup.txt b/phoenix_bec/scripts/Current_setup.txt similarity index 87% rename from phoenix_bec/local_scripts/Documentation/Current_setup.txt rename to phoenix_bec/scripts/Current_setup.txt index 04344b3..f6f27a2 100644 --- a/phoenix_bec/local_scripts/Documentation/Current_setup.txt +++ b/phoenix_bec/scripts/Current_setup.txt @@ -28,3 +28,6 @@ to run startup file: phoenix_bec/bec_ipython_client/startup/post_startup.py +Magic commands defiend in post_startup.py (should all start with ph_) + +%ph_reload : reloads module phoenix.py to ipython shell BUT not to server \ No newline at end of file diff --git a/phoenix_bec/scripts/phoenix.py b/phoenix_bec/scripts/phoenix.py index 26eeb81..836a757 100644 --- a/phoenix_bec/scripts/phoenix.py +++ b/phoenix_bec/scripts/phoenix.py @@ -64,30 +64,23 @@ class PhoenixBL(): self.path_scripts_local = '/data/test/x07mb-test-bec/bec_deployment/phoenix_bec/phoenix_bec/local_scripts/' self.path_config_local = self.path_scripts_local + 'TEST_ConfigPhoenix/' # base dir for local configurations self.path_devices_local = self.path_config_local + 'Local_device_config/' # local yamal file - self.file_device_file_local = self.path_devices_local + 'phoenix_devices.yaml' + self.file_devices_file_local = self.path_devices_local + 'phoenix_devices.yaml' - self.path_phoenix_bec = '/data/test/x07mb-test-bec/bec_deployment/phoenix_bec/' - self.file_phoenix_devices_file = self.path_phoenix_bec+'phoenix_bec/device_configs/phoenix_devices.yaml' - #bec.config.update_session_with_file(self.file_device_conf) - # last command created yaml backup, for now just move it away - #os.system('mv *.yaml '+Devices_local+'/recovery_configs') - #os.system('mv *.yaml tmp') + self.path_phoenix_bec ='/data/test/x07mb-test-bec/bec_deployment/phoenix_bec/' + self.path_devices = self.path_phoenix_bec + 'phoenix_bec/device_configs/' # local yamal file + self.file_devices_file = self.path_phoenix_bec + 'phoenix_bec/device_configs/phoenix_devices.yaml' # local yamal file + + def read_local_phoenix_config(self): + print('read file ') + print(self.file_phoenix_devices_file) + bec.config.update_session_with_file(self.file_devices_file_local) - - def read_def_config(self): - bec.config.update_session_with_file(self.file_device_conf) - def read_phoenix_config(self): print('read file ') print(self.file_phoenix_devices_file) - bec.config.update_session_with_file(self.file_phoenix_devices_file) - - - + bec.config.update_session_with_file(self.file_devices_file) + def show_phoenix_setup(self): print(self.path_phoenix_bec) - os.system('cat '+self.path_phoenix_bec+'phoenix_bec/local_scripts/Documentation/Current_setup.txt') - -def test_func(): - print('ttpsssyt') \ No newline at end of file + os.system('cat '+self.path_phoenix_bec+'phoenix_bec/scripts/Current_setup.txt')