From 2e8fc6057af69ebdf576441a8e6aacddf58ad4dc Mon Sep 17 00:00:00 2001 From: sfop Date: Wed, 6 Jul 2016 10:46:20 +0200 Subject: [PATCH] Script execution --- script/Alignment/Gun_solenoid_alignment.py | 43 ++++++++++------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/script/Alignment/Gun_solenoid_alignment.py b/script/Alignment/Gun_solenoid_alignment.py index 005bfbf..7cf4835 100755 --- a/script/Alignment/Gun_solenoid_alignment.py +++ b/script/Alignment/Gun_solenoid_alignment.py @@ -29,6 +29,8 @@ if get_context().source == CommandSource.ui: else: centroid_excursion_plot = False +LASER_SETTLING_TIME = 0.1 + print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') @@ -36,12 +38,11 @@ plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') add_device(CamTool("camtool") , True) camtool.enableBackground (use_background) - -number_images = 1 -use_background = True -multiple_background = True -number_backgrounds = 5 - +if use_background and not multiple_background: + laser_off() + camtool.captureBackground(number_backgrounds) +multiple_background = multiple_background and use_background + com_x =camtool.com_x com_y = camtool.com_y @@ -54,26 +55,16 @@ def ccr(mag): n = caget(mag + ":I-COMP") def laser_on(): - pass + print "Laser On" #caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 0) + time.sleep(LASER_SETTLING_TIME) def laser_off(): - pass + print "Laser Off" #caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 1) + time.sleep(LASER_SETTLING_TIME) -def run_pipeline(): - caput("camtool...:start") - - while !caget("camtool...:done"): - sleep(0.1) - - caget("camtool....:data") - #caget("camtool....:X_stats.com") - #caget("camtool....:X_stats.com") - - - # Switch off magnets mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", "SINEG01-MQUA140", @@ -92,14 +83,20 @@ if zero_solenoids: # add here gun phase setting see wiki page -def br(): +def br(): + if multiple_background: + camtool.captureBackground(number_backgrounds) + laser_on() camtool.update() def ar(): - pass + if multiple_background: + laser_off() + r = None -laser_on() +if not multiple_background: + laser_on() try: sensors = [com_x, com_y, camtool.image] if plot_image else [com_x, com_y] r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = br, after_read = ar)