65 lines
2.7 KiB
Python
Executable File
65 lines
2.7 KiB
Python
Executable File
dry_run = False
|
|
do_elog = True
|
|
|
|
if get_exec_pars().source == CommandSource.ui:
|
|
las_offset_deg = 0.0
|
|
plt = None
|
|
else:
|
|
las_offset_deg = args[0]
|
|
plt = args[1]
|
|
Bunch = caget("SLG-LGEN:WHICH_LASER")
|
|
B1las = caget("SIN-TIMAST-TMA:Bunch-1-Las-Sel")
|
|
B2las = caget("SIN-TIMAST-TMA:Bunch-2-Las-Sel")
|
|
cur_las_delay = 0.0
|
|
if Bunch == "Bunch 1":
|
|
if B1las == "Alcor":
|
|
Laser = "Alcor"
|
|
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
|
|
elif B1las == "Mizar":
|
|
Laser = "Mizar"
|
|
cur_las_delay = caget("SLGOS01-TSPL-MIZ:CURR_DELTA_T")
|
|
elif B1las == "Jaguar":
|
|
Laser = "Jaguar"
|
|
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
|
|
elif Bunch == "Bunch 2":
|
|
if B2las == "Alcor":
|
|
Laser = "Alcor"
|
|
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
|
|
elif B2las == "Mizar":
|
|
Laser = "Mizar"
|
|
cur_las_delay = caget("SLGOS01-TSPL-MIZ:CURR_DELTA_T")
|
|
elif B2las == "Jaguar":
|
|
Laser = "Jaguar"
|
|
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
|
|
elif Laser == "Both":
|
|
Laser = None
|
|
cur_las_delay = None
|
|
new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0 # s-band: 1 / (142.8 MHz * 21) = 333.467 ps
|
|
if not dry_run:
|
|
if Laser == "Alcor":
|
|
caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay )
|
|
caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 )
|
|
elif Laser == "Mizar":
|
|
caput("SLGOS01-TSPL-MIZ:NEW_DELTA_T" , new_las_delay )
|
|
caput("SLGOS01-TSPL-MIZ:SET_NEW_PHASE.PROC" , 1 )
|
|
elif Laser == "Jaguar":
|
|
caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay )
|
|
caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 )
|
|
if do_elog:
|
|
title = "Set laser delay"
|
|
log_msg = ""
|
|
if Laser == "Alcor":
|
|
log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
|
|
elif Laser == "Mizar":
|
|
log_msg = "SLGOS01-TSPL-MIZ:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
|
|
elif Laser == "Jaguar":
|
|
log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
|
|
attachments = []
|
|
if plt is not None:
|
|
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
|
|
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanLasSet.png")
|
|
plt.saveSnapshot(file_name , "png")
|
|
attachments = [file_name]
|
|
elog(title, log_msg, attachments)
|
|
show_message("Success setting laser delay")
|