From b36c19e2244bde56038b299f0ecd815c8464e8a9 Mon Sep 17 00:00:00 2001 From: gac-x07mb Date: Thu, 8 Aug 2024 17:51:16 +0200 Subject: [PATCH] add magic for configuration load to post_startup.py --- .../startup/post_startup.py | 58 ++++++++++++------- .../device_configs/phoenix_devices.yaml | 2 +- phoenix_bec/scripts/phoenix.py | 14 ++--- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/phoenix_bec/bec_ipython_client/startup/post_startup.py b/phoenix_bec/bec_ipython_client/startup/post_startup.py index 101719a..f3332d7 100644 --- a/phoenix_bec/bec_ipython_client/startup/post_startup.py +++ b/phoenix_bec/bec_ipython_client/startup/post_startup.py @@ -34,6 +34,7 @@ to setup the prompts. """ from IPython.core.magic import register_line_magic +import time as tt # pylint: disable=invalid-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module import sys @@ -45,23 +46,11 @@ bec._ip.prompts.status = 1 # make sure that edited modules are reloaded when changed print('post_startup.py : set autoreload of modules') - -#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 temporary fix as we had trouble finding certain paths. @@ -72,13 +61,13 @@ print('autoreload loaded ') # ########## -print('post_startup.py : set some paths as temp fix. this needs to be solved ') +print('post_startup.py : set some paths as temp fix. This needs to be solved ') ophyd_devices_path='/data/test/x07mb-test-bec/bec_deployment/ophyd_devices' p_path='/data/test/x07mb-test-bec/bec_deployment/bec_server_venv/lib/python3.11/site-packages' -print('add',ophyd_devices_path) -print('add',p_path) +print('add ',ophyd_devices_path) +print('add ',p_path) if ophyd_devices_path not in sys.path: sys.path.insert(1, os.path.expandvars(ophyd_devices_path)) @@ -91,7 +80,7 @@ if p_path not in sys.path: ############################################################################# # -#... register BL specific magic comands +#... register BL specific magic commands # ############################################################################## @@ -101,7 +90,9 @@ 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 + # aim of this magic is to quickl reload BL related stuff for debugging + # Most likely there are better ways to do this (possibly bec.reload_user_script() + # but syntax not clear, error messages. Here we know what we do # # ####################################################################### print('reload phoenix_bec.scripts.phoenix to iphyhton console') @@ -114,6 +105,32 @@ def ph_reload(line): #ph_config=PH.PhoenixConfighelper() #enddef +print('register magic') +print('...... %ph_load_xmap') +@register_line_magic +def ph_load_xmap(line): + t0=tt.time() + phoenix_server.add_xmap() + print('elapsed time:', tt.time()-t0) +#enddef + +print('...... %ph_load_falcon') +@register_line_magic +def ph_load_falcon(line): + t0=tt.time() + phoenix_server.add_falcon() + print('elapsed time:', tt.time()-t0) +#enddef + +print('...... %ph_load_config') +@register_line_magic +def ph_load_config(line): + t0=tt.time() + phoenix_server.add_phoenix_config() + print('elapsed time:', tt.time()-t0) +#enddef + + ##@register_line_magic #def ph_post_startup(line): @@ -130,10 +147,11 @@ def ph_reload(line): # ##################################################################################### -print('init phoenix_server = PhoenixBL() ... from server version ') +print('init phoenix_bec/scripts/phoenix.py in two different ways') +print(' 1) phoenix_server = PhoenixBL() ... takes code from server version ') phoenix_server=PhoenixBL() -print('init phoenix=PH.PhoenixBL() ... on inpython shell onlz (for debugging)') +print(' 2) phoenix=PH.PhoenixBL() ... on inpython shell only! (for debugging)') from phoenix_bec.scripts import phoenix as PH phoenix = PH.PhoenixBL() diff --git a/phoenix_bec/device_configs/phoenix_devices.yaml b/phoenix_bec/device_configs/phoenix_devices.yaml index 82eaec4..691c0b0 100644 --- a/phoenix_bec/device_configs/phoenix_devices.yaml +++ b/phoenix_bec/device_configs/phoenix_devices.yaml @@ -9,7 +9,7 @@ # MOTORS ES1 # -ScanXX: +ScanX: readoutPriority: baseline description: 'Horizontal sample position' deviceClass: ophyd.EpicsMotor diff --git a/phoenix_bec/scripts/phoenix.py b/phoenix_bec/scripts/phoenix.py index 6886d4b..b91ec47 100644 --- a/phoenix_bec/scripts/phoenix.py +++ b/phoenix_bec/scripts/phoenix.py @@ -36,9 +36,7 @@ class PhoenixBL(): """ - #define some epics channels - #scan_name = "phoenix_base" - + def __init__(self): @@ -50,7 +48,7 @@ class PhoenixBL(): import os - print('init PhoenixBL from phoenix_bec/scripts/phoenix.py') + print('..... init PhoenixBL from phoenix_bec/scripts/phoenix.py') #from ophyd import Device, EpicsMotor, EpicsSignal, EpicsSignalRO #from ophyd import Component as Cpt @@ -102,8 +100,6 @@ class PhoenixBL(): -#class PhoenixConfigHelper(ConfigHelper):# -# -# def __init__(self): -# super.__init__(PhoenixConfigHelper) -# \ No newline at end of file + + +