Startup
This commit is contained in:
@@ -12,6 +12,7 @@ import datetime
|
||||
|
||||
mode = "camtool" # "camtool", "bpm" or "direct"
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
I1 = 95.0
|
||||
@@ -28,6 +29,8 @@ if get_exec_pars().source == CommandSource.ui:
|
||||
else:
|
||||
centroid_excursion_plot = False
|
||||
|
||||
check_camtool()
|
||||
|
||||
laser_was_on = is_laser_on()
|
||||
original_gun_solenoid = gun_solenoid.read()
|
||||
|
||||
@@ -39,12 +42,12 @@ plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S')
|
||||
|
||||
|
||||
if mode == "camtool":
|
||||
if camtool.getCurrentCamera() != camera_name:
|
||||
camtool.start(camera_name, None, use_background, None, None, None)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
camtool.grabBackground(camera_name, 5)
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if mode == "bpm":
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
@@ -57,16 +60,21 @@ else:
|
||||
#switch_off_magnets()
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample():
|
||||
if multiple_background:
|
||||
camtool.grabBackground(camera_name, 5)
|
||||
laser_on()
|
||||
if mode != "camtool":
|
||||
if mode == "camtool":
|
||||
if multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
laser_on()
|
||||
wait_camtool_message(number_images) #Wait filing the averager cache
|
||||
else:
|
||||
image_stats.update()
|
||||
|
||||
def after_sample():
|
||||
if multiple_background:
|
||||
laser_off()
|
||||
laser_off()
|
||||
|
||||
r = None
|
||||
if not multiple_background:
|
||||
@@ -76,21 +84,12 @@ try:
|
||||
if mode != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
else:
|
||||
#sensors = [CamtoolValue("gr_x_fit_mean"), CamtoolValue("gr_y_fit_mean"), CamtoolValue("gr_x_fit_standard_deviation"), CamtoolValue("gr_y_fit_standard_deviation")]
|
||||
sensors = []
|
||||
for ident in ["gr_x_fit_mean", "gr_y_fit_mean", "gr_x_fit_standard_deviation", "gr_y_fit_standard_deviation"]:
|
||||
child = s.getChild(ident)
|
||||
av = create_averager(child, number_images, -1)
|
||||
av.monitored = True
|
||||
sensors.append(av)
|
||||
if plot_image and (mode == "camtool"):
|
||||
sensors.append(camtool.getDataMatrix()) #sensors.append(CamtoolImage())
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
if plot_image:
|
||||
sensors.append(camtool.getDataMatrix())
|
||||
r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = before_sample, after_read = after_sample)
|
||||
finally:
|
||||
#laser_off()
|
||||
pass
|
||||
|
||||
#image_stats.stop()
|
||||
if mode == "camtool": camtool.stop()
|
||||
|
||||
gun_solenoid.write(original_gun_solenoid)
|
||||
if laser_was_on:
|
||||
|
||||
@@ -12,6 +12,7 @@ import datetime
|
||||
|
||||
mode = "camtool" # "camtool", "bpm" or "direct"
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
phi1= 95.0
|
||||
@@ -38,16 +39,16 @@ print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images
|
||||
plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S')
|
||||
|
||||
if mode == "camtool":
|
||||
if camtool.getCurrentCamera() != camera_name:
|
||||
camtool.start(camera_name, None, use_background, None, None, None)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
camtool.grabBackground(camera_name, 5)
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if mode == "bpm":
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
else :
|
||||
else:
|
||||
add_device(ImageStats(PsiCamera("image_stats", camera_name)), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
@@ -58,10 +59,14 @@ else:
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample():
|
||||
if multiple_background:
|
||||
camtool.grabBackground(camera_name, 5)
|
||||
laser_on()
|
||||
if mode != "camtool":
|
||||
if mode == "camtool":
|
||||
if multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
laser_on()
|
||||
wait_camtool_message(number_images) #Wait filing the averager cache
|
||||
else:
|
||||
image_stats.update()
|
||||
|
||||
def after_sample():
|
||||
@@ -76,12 +81,12 @@ try:
|
||||
if mode != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
else:
|
||||
sensors = [CamtoolValue("gr_x_fit_mean"), CamtoolValue("gr_y_fit_mean"), CamtoolValue("gr_x_fit_standard_deviation"), CamtoolValue("gr_y_fit_standard_deviation")]
|
||||
if plot_image and (mode == "camtool"):
|
||||
sensors.append(CamtoolImage())
|
||||
sensors = get_camtool_stats(number_images, good_region=use_good_region)
|
||||
if plot_image:
|
||||
sensors.append(camtool.getDataMatrix())
|
||||
r = lscan(gun_phase, sensors , phi1, phi2, dphi, settling_time, before_read = before_sample, after_read = after_sample)
|
||||
finally:
|
||||
pass
|
||||
if mode == "camtool": camtool.stop()
|
||||
|
||||
gun_phase.write(original_phase)
|
||||
if laser_was_on:
|
||||
|
||||
Reference in New Issue
Block a user