add magic for configuration load to post_startup.py

This commit is contained in:
gac-x07mb
2024-08-08 17:51:16 +02:00
parent 68050cb8cf
commit b36c19e224
3 changed files with 44 additions and 30 deletions

View File

@ -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,7 +61,7 @@ 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'
@ -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()

View File

@ -9,7 +9,7 @@
# MOTORS ES1
#
ScanXX:
ScanX:
readoutPriority: baseline
description: 'Horizontal sample position'
deviceClass: ophyd.EpicsMotor

View File

@ -36,8 +36,6 @@ 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)
#