Startup
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
|
||||
import datetime
|
||||
|
||||
do_elog = True
|
||||
dry_run = False
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
do_elog = True
|
||||
|
||||
if not is_panel:
|
||||
source = "direct" # "camtool", "bpm" or "direct"
|
||||
source = "server" # "server", "camtool", "bpm" or "direct"
|
||||
I1 = 100.0
|
||||
I2 = 105.0
|
||||
dI = 1.0
|
||||
@@ -46,103 +46,39 @@ centroid_plot.addSeries(scan_series)
|
||||
scan_series.setLinesVisible(False)
|
||||
scan_series.setPointSize(4)
|
||||
|
||||
#Testing
|
||||
"""
|
||||
camera_name = "SLG-LCAM-C041"
|
||||
def laser_on():
|
||||
print "Laser On"
|
||||
def laser_off():
|
||||
print "Laser Off"
|
||||
def switch_off_magnets(magnets = None):
|
||||
pass
|
||||
add_device(DummyPositioner("gun_solenoid"), True)
|
||||
do_elog = False
|
||||
"""
|
||||
|
||||
laser_was_on = is_laser_on()
|
||||
original_gun_solenoid = gun_solenoid.read()
|
||||
positioner = DummyPositioner("positioner") if dry_run else gun_solenoid
|
||||
|
||||
original_gun_solenoid = positioner.read()
|
||||
multiple_background = multiple_background and use_background
|
||||
print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds
|
||||
|
||||
if source == "camtool":
|
||||
check_camtool()
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if source == "bpm":
|
||||
run("Devices/BpmStats")
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
else:
|
||||
run("Devices/ImageStats")
|
||||
add_device(ImageStats("image_stats", camera_name), True)
|
||||
add_device(image_stats.source, True)
|
||||
image_stats.enableBackground(use_background)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
image_stats.setNumberOfImages(max(number_images,1))
|
||||
setup_camera_scan()
|
||||
|
||||
#switch_off_magnets()
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample(position, scan):
|
||||
if source == "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:
|
||||
if multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
laser_on()
|
||||
image_stats.update()
|
||||
|
||||
def after_sample(record, scan):
|
||||
x = record.values[0]
|
||||
y = record.values[1]
|
||||
stdev_x = record.values[2]
|
||||
stdev_y = record.values[3]
|
||||
if source == "camtool":
|
||||
if source in ["camtool", "server"]:
|
||||
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
|
||||
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
|
||||
scan_series.appendData(x, y, abs(stdev_x), abs(stdev_y));
|
||||
if multiple_background:
|
||||
laser_off()
|
||||
after_sample_camera_scan()
|
||||
|
||||
r = None
|
||||
if not multiple_background:
|
||||
laser_on()
|
||||
|
||||
try:
|
||||
if source != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
if plot_image and (source == "direct"):
|
||||
sensors.append(image_stats.source.getDataMatrix())
|
||||
else:
|
||||
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)
|
||||
sensors = get_camera_scan_sensors()
|
||||
r = lscan(positioner, sensors , I1, I2, dI, settling_time, before_read = before_sample_camera_scan, after_read = after_sample)
|
||||
finally:
|
||||
if source == "camtool":
|
||||
camtool.stop()
|
||||
else:
|
||||
image_stats.stop()
|
||||
gun_solenoid.write(original_gun_solenoid)
|
||||
if laser_was_on:
|
||||
laser_on()
|
||||
else:
|
||||
laser_off()
|
||||
end_camera_scan()
|
||||
positioner.write(original_gun_solenoid)
|
||||
|
||||
# take the result of the scan and generate convex hull plot
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
|
||||
import datetime
|
||||
|
||||
do_elog = True
|
||||
dry_run = False
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
|
||||
camera_name = "SINEG01-DSCR190"
|
||||
use_good_region=False
|
||||
do_elog = True
|
||||
|
||||
|
||||
if not is_panel:
|
||||
source = "camtool" # "camtool", "bpm" or "direct"
|
||||
source = "server" # "server", "camtool", "bpm" or "direct"
|
||||
phi1= 95.0
|
||||
phi2 = 100.0
|
||||
dphi = 1.0
|
||||
@@ -46,105 +47,40 @@ centroid_plot.addSeries(scan_series)
|
||||
scan_series.setLinesVisible(False)
|
||||
scan_series.setPointSize(4)
|
||||
|
||||
"""
|
||||
#Testing
|
||||
camera_name = "SLG-LCAM-C041"
|
||||
def laser_on():
|
||||
print "Laser On"
|
||||
def laser_off():
|
||||
print "Laser Off"
|
||||
def switch_off_magnets(magnets = None):
|
||||
pass
|
||||
add_device(DummyPositioner("gun_phase"), True)
|
||||
do_elog = False
|
||||
"""
|
||||
positioner = DummyPositioner("positioner") if dry_run else gun_phase
|
||||
|
||||
laser_was_on = is_laser_on()
|
||||
original_phase = gun_phase.read()
|
||||
original_phase = positioner.read()
|
||||
multiple_background = multiple_background and use_background
|
||||
print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds
|
||||
|
||||
|
||||
if source == "camtool":
|
||||
#kill_camtool()
|
||||
check_camtool()
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
camtool.stop()
|
||||
camtool.grabBackground(camera_name, number_backgrounds)
|
||||
camtool.start(camera_name, 0, use_background, None, 0.0, None)
|
||||
else:
|
||||
if source == "bpm":
|
||||
run("Devices/BpmStats")
|
||||
add_device(BpmStats("image_stats", camera_name), True)
|
||||
multiple_background = False
|
||||
use_background = False
|
||||
else:
|
||||
run("Devices/ImageStats")
|
||||
add_device(ImageStats("image_stats", camera_name), True)
|
||||
add_device(image_stats.source, True)
|
||||
image_stats.enableBackground(use_background)
|
||||
if use_background:
|
||||
laser_off()
|
||||
if not multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
image_stats.setNumberOfImages(max(number_images,1))
|
||||
setup_camera_scan()
|
||||
|
||||
#switch_off_magnets()
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def before_sample(position, scan):
|
||||
if source == "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:
|
||||
if multiple_background:
|
||||
image_stats.grabBackground(number_backgrounds)
|
||||
laser_on()
|
||||
image_stats.update()
|
||||
|
||||
def after_sample(record, scan):
|
||||
x = record.values[0]
|
||||
y = record.values[1]
|
||||
stdev_x = record.values[2]
|
||||
stdev_y = record.values[3]
|
||||
if source == "camtool":
|
||||
if source in ["camtool", "server"]:
|
||||
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
|
||||
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
|
||||
scan_series.appendData(x, y, abs(stdev_x), abs(stdev_y));
|
||||
if multiple_background:
|
||||
laser_off()
|
||||
after_sample_camera_scan()
|
||||
|
||||
r = None
|
||||
if not multiple_background:
|
||||
laser_on()
|
||||
|
||||
try:
|
||||
if source != "camtool":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
if plot_image and (source == "direct"):
|
||||
sensors.append(image_stats.source.getDataMatrix())
|
||||
else:
|
||||
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)
|
||||
sensors = get_camera_scan_sensors()
|
||||
r = lscan(positioner, sensors , phi1, phi2, dphi, settling_time, before_read = before_sample_camera_scan, after_read = after_sample)
|
||||
finally:
|
||||
if source == "camtool":
|
||||
camtool.stop()
|
||||
else:
|
||||
image_stats.stop()
|
||||
gun_phase.write(original_phase)
|
||||
if laser_was_on:
|
||||
laser_on()
|
||||
else:
|
||||
laser_off()
|
||||
end_camera_scan()
|
||||
positioner.write(original_phase)
|
||||
|
||||
|
||||
# take the result of the scan and generate convex hull plot
|
||||
(hx,hy)= convex_hull(x=to_array(r.getReadable(0), 'd'), y=to_array(r.getReadable(1),'d'))
|
||||
|
||||
Reference in New Issue
Block a user