Skip to content
Snippets Groups Projects
pydeviceCRL.cmd 2.85 KiB
Newer Older
mwyman's avatar
mwyman committed
################################################################################
# PyDevice Support for Transfocator
################################################################################

mwyman's avatar
mwyman committed
# Setting some variables that are needed in multiple locations
epicsEnvSet('_STACK_THICK',0.050)
epicsEnvSet('_D_MIN',0.00003)
epicsEnvSet('_STACKS',10)
epicsEnvSet('_ENERGY',12)

# Setting some variables beamline-dependent PVs
epicsEnvSet('_SLITH',"")	# Horizontal size of slit before CRL
epicsEnvSet('_SLITV',"")	# Vertical size of slit before CRL
epicsEnvSet("BLE","")	# Beam energy at CRL

mwyman's avatar
mwyman committed
# Next two lines set up some testing tools for energy -- can be commented out 
epicsEnvSet("MONOE","testMonoE")
dbLoadRecords("${TOP}/db/energyTestTools.db","P=$(PREFIX), MONOE=$(MONOE), IDENERGY=testIDE")

mwyman's avatar
mwyman committed
# CRL DBs and defining substitution file to get stack properties
mwyman's avatar
mwyman committed
dbLoadTemplate("substitutions/pyDeviceTfor.substitutions","P=$(PREFIX)")
mwyman's avatar
mwyman committed
pydev("stack_subFile = 'substitutions/pyDeviceTfor.substitutions'")
mwyman's avatar
mwyman committed

mwyman's avatar
mwyman committed
# Import Transfocator class
mwyman's avatar
mwyman committed
pydev("from pyTransfocator_single import singleTF")

mwyman's avatar
mwyman committed
# Set up beam properties -- these may only need to be set up at creation of IOC
mwyman's avatar
mwyman committed
# however energy can be changed after boot-time
# energy	 - energy in keV 
mwyman's avatar
mwyman committed
# L_und      - Undulator length in m
# sigmaH_e   - Sigma electron source size in H direction in m
# sigmaV_e   - Sigma electron source size in V direction in m
# sigmaHp_e  - Sigma electron divergence in H direction in rad
# sigmaVp_e  - Sigma electron divergence in V direction in rad
mwyman's avatar
mwyman committed
pydev("b_properties = {'energy': $(_ENERGY), 'L_und':4.7, 'sigmaH_e':14.8e-6, 'sigmaV_e':3.7e-6, 'sigmaHp_e':2.8e-6, 'sigmaVp_e':1.5e-6})
mwyman's avatar
mwyman committed

mwyman's avatar
mwyman committed
# Set up beamline properties -- these may only need to be set up at creation of IOC
mwyman's avatar
mwyman committed
# d_StoL	- Source-to-CRL1 distance, in m
# d_Stof	- Source-to-focus distance, in m
pydev("bl_properties = {'d_StoL': 51.9,'d_Stof':,'66.2':}
mwyman's avatar
mwyman committed

# Set up crl properties -- these are properties common to the stacks
mwyman's avatar
mwyman committed
# stack_d	- Stack thickness in mMinimum thickness at the apex in m
# d_min 	- Minimum thickness at the apex in m
pydev("crl_properties = {'stack_d': $(_STACK_THICK),'d_min': $(_D_MIN)}
mwyman's avatar
mwyman committed

# Create Transfocator object
pydev("CRL1 = singleTF(beam = b_properties, bl = bl_properties, crl = crl_properties)")
mwyman's avatar
mwyman committed

mwyman's avatar
mwyman committed
# DB for Transfocator system
mwyman's avatar
mwyman committed
dbLoadRecords(""${TOP}/db/pyDevCRLsingle.db","P=$(PREFIX), N=1, OBJ=CRL1, KEV=$(BLE), STACK_THICK=$(_STACK_THICK), MIN_THICK=$(_D_MIN), SLITH = $(_SLITH), SLITV = $(_SLITV)")
mwyman's avatar
mwyman committed

# After iocInit, need to setup attenuation lookup table
mwyman's avatar
mwyman committed
# 	stack_subFile - string holding name/rel. location of substitutions file loaded
mwyman's avatar
mwyman committed
#                     loaded in  dbLoadTemplate
mwyman's avatar
mwyman committed
#   $(_STACKS)  - number of stacks of lenses
# 	energy		- beam energy in keV used for the initial lookup table setup -- can be updated
mwyman's avatar
mwyman committed
#          after startup
mwyman's avatar
mwyman committed
doAfterIocInit("pydev('CRL1.setupLookupTable(stack_subFile, $(_STACKS), energy = $(_ENERGY))')")