cosmetic changes to startup

This commit is contained in:
gac-x07mb
2024-08-16 14:50:04 +02:00
parent c2d97144bc
commit 9b63d4af18
5 changed files with 38 additions and 64 deletions

View File

@ -1,4 +1,7 @@
""" """
FILE
phoenix_bec.bec_iphyton_client
Post startup script for the BEC client. This script is executed after the Post startup script for the BEC client. This script is executed after the
IPython shell is started. It is used to load the beamline specific IPython shell is started. It is used to load the beamline specific
information and to setup the prompts. information and to setup the prompts.
@ -10,6 +13,11 @@ While command-line arguments have to be set in the pre-startup script, the
post-startup script can be used to load beamline specific information and post-startup script can be used to load beamline specific information and
to setup the prompts. to setup the prompts.
#################################################################
# OLD CODE FROM CSAXS ONLY AS EXAMPLE NEXT LINES CAN BE IGNORED
################################################################
from bec_lib.logger import bec_logger from bec_lib.logger import bec_logger
logger = bec_logger.logger logger = bec_logger.logger
@ -24,13 +32,14 @@ to setup the prompts.
_session_name = "LamNI" _session_name = "LamNI"
lamni = LamNI(bec) lamni = LamNI(bec)
logger.success("LamNI session loaded.") logger.succ#ess("LamNI session loaded.")
elif _args.session.lower() == "csaxs": elif _args.session.lower() == "csaxs":
print("Loading cSAXS session") print("Loading cSAXS session")
from csaxs_bec.bec_ipython_client.plugins.cSAXS import * from csaxs_bec.bec_ipython_client.plugins.cSAXS import *
logger.success("cSAXS session loaded.") logger.success("cSAXS session loaded.")
#####################################################################
""" """
@ -42,23 +51,24 @@ from IPython.core.magic import register_line_magic
from bec_lib.logger import bec_logger from bec_lib.logger import bec_logger
logger = bec_logger.logger logger = bec_logger.logger
logger = bec_logger.LOGLEVEL.TRACE #logger = bec_logger.LOGLEVEL.TRACE
#pylint: disable=invald-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module #pylint: disable=invald-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module
_session_name = "session_phoenix"
# SETUP PROMPTS # SETUP PROMPTS
bec._ip.prompts.username = "PHOENIX" bec._ip.prompts.username = "PHOENIX"
bec._ip.prompts.status = 1 bec._ip.prompts.status = 1
# make sure that edited modules are reloaded when changed # make sure that edited modules are reloaded when changed
print('post_startup.py : set autoreload of modules') print('phoenix_bec/bec_iphyon_client/startup/post_startup.py')
print('... set autoreload of modules')
bec._ip.run_line_magic("reload_ext","autoreload") bec._ip.run_line_magic("reload_ext","autoreload")
bec._ip.run_line_magic("autoreload", "2") bec._ip.run_line_magic("autoreload", "2")
print('autoreload loaded ') print('autoreload loaded ')
########### ################################################################
# #
# next lines are not ideal and likely need to be removed they are a temporary fix as # next lines are not ideal and likely need to be removed they are a temporary fix as
# we had trouble finding certain paths. # we had trouble finding certain paths.
@ -67,7 +77,7 @@ print('autoreload loaded ')
# path to ophyd devices is only way to find default ophyd devices # path to ophyd devices is only way to find default ophyd devices
# path to python packages not ideal but only way to add pyp5 and pandas packages # path to python packages not ideal but only way to add pyp5 and pandas packages
# #
########## ##############################################################
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 ')
@ -92,17 +102,7 @@ if p_path not in sys.path:
#... register BL specific magic commands #... register BL specific magic commands
# #
############################################################################## ##############################################################################
# not clear, error messages. Here we know what we do.
@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
# 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.
# #
######################################################################## ########################################################################
@ -118,8 +118,9 @@ def ph_reload(line):
#ph_config=PH.PhoenixConfighelper() #ph_config=PH.PhoenixConfighelper()
#enddef #enddef
print('##################################################################')
print('register magic') print('register magic')
print('...... %ph_load_xmap') print('...... %ph_load_xmap ... to reload xmap configuration')
@register_line_magic @register_line_magic
def ph_load_xmap(line): def ph_load_xmap(line):
@ -132,7 +133,7 @@ def ph_load_xmap(line):
print('elapsed time:', tt.time()-t0) print('elapsed time:', tt.time()-t0)
#enddef #enddef
print('...... %ph_load_falcon') print('...... %ph_load_falcon ... to reload falcon configuration')
@register_line_magic @register_line_magic
def ph_load_falcon(line): def ph_load_falcon(line):
@ -143,7 +144,7 @@ def ph_load_falcon(line):
print('elapsed time:', tt.time()-t0) print('elapsed time:', tt.time()-t0)
#enddef #enddef
print('...... %ph_load_config') print('...... %ph_load_config ... to reload phoenix default configuration')
@register_line_magic @register_line_magic
def ph_load_config(line): def ph_load_config(line):
t0=tt.time() t0=tt.time()
@ -164,9 +165,10 @@ def ph_load_config(line):
# .................. phoenix_server=PhoenixBL() # .................. phoenix_server=PhoenixBL()
# and in ipython shell only as # and in ipython shell only as
# .............. phoenix = Ph.Pheonix(BL() # .............. phoenix = Ph.Pheonix(BL()
# ##
##################################################################################### #####################################################################################
print('###############################################################')
print('init phoenix_bec/scripts/phoenix.py in two different ways') print('init phoenix_bec/scripts/phoenix.py in two different ways')
print(' 1) phoenix_server = PhoenixBL() ... takes code from server version ') print(' 1) phoenix_server = PhoenixBL() ... takes code from server version ')
phoenix_server=PhoenixBL() phoenix_server=PhoenixBL()

View File

@ -364,6 +364,3 @@ class XMAPphoenix(PSIDetectorBase):
pixels_per_run = Cpt(EpicsSignal, "PixelsPerRun") pixels_per_run = Cpt(EpicsSignal, "PixelsPerRun")
#nd_array_mode = Cpt(EpicsSignal, "NDArrayMode") #nd_array_mode = Cpt(EpicsSignal, "NDArrayMode")
print('DONE connecton chanels in XMAPphoenix') print('DONE connecton chanels in XMAPphoenix')
if __name__ == "__main__":
xmap = XMAPphoenix(name="xmap", prefix="X07MB-XMAP:", sim_mode=True)

View File

@ -1,40 +0,0 @@
from ophyd import Device, EpicsMotor, EpicsSignal, EpicsSignalRO
from ophyd import Component as Cpt
#option I via direct acces to classes
ScanX = EpicsMotor(name='ScanX',prefix='X07MB-ES-MA1:ScanX')
ScanY = EpicsMotor(name='ScanY',prefix='X07MB-ES-MA1:ScanY')
DIODE = EpicsSignal(name='SI',read_pv='X07MB-OP2-SAI_07:MEAN')
SMPL = EpicsSignal(name='SMPL',read_pv='X07MB-OP2:SMPL')
CYCLES = EpicsSignal(name='SMPL',read_pv='X07MB-OP2:TOTAL-CYCLES',write_pv='X07MB-OP2:TOTAL-CYCLES')
# Option 2 using component
class StageXY(Device):
x = Cpt(EpicsMotor, 'ScanX')
y = Cpt(EpicsMotor, 'ScanY')
xy_stage = StageXY('X07MB-ES-MA1:', name='stage')
#############################################
# This is basic bluesky
# Epics motor def seems to use init params in device, whcih are
# __init__(
# self,
# prefix="",
# *,
# name,
# kind=None,
# read_attrs=None,
# configuration_attrs=None,
# parent=None,
# **kwargs,
# ):
#
#########################################################
# to move motor use
# stage.x.move(0)
# to see all dict
# stage.x.__dict__

View File

@ -0,0 +1,13 @@
print('#######################################')
print('bec.show_global_vars()')
bec.show_global_vars()
print('#######################################')
print('bec.show_all_commands()')
bec.show_all_commands()
print('#######################################')
print('bec.list_user_scripts()')
bec.list_user_scripts()

View File

@ -0,0 +1,2 @@
print('Work with unix shell comands :')
print('use %ls %mkdir etc ')