Creation
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 12670.0, 12690.0, 10.0 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11102 intensity", 50, 0.1, "Enabled" ], [ "CamServer", "tcp://sf-daqsync-14.psi.ch:9007 intensity", 50, 0.05, "Disabled" ], [ "Stream", "SAROP21-PPRM113:intensity", 50, 0.05, "Disabled" ], [ "CamServer", "tcp://sf-daqsync-03.psi.ch:9009 intensity", 50, 0.05, "Disabled" ], [ "Channel", "SAROP21-PBPS103:INTENSITY", 50, 0.05, "Disabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 12670.0, 12690.0, 10.0 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11102 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 11850.0, 12000.0, 2.5 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11115 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 12200.0, 12460.0, 2.5 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11134 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 7950.0, 8060.0, 2.5 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11133 intensity", 50, 0.1, "Enabled" ], [ "Stream", "SAROP21-PBPS103:INTENSITY", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP21-ARAMIS:ENERGY_SP.VAL", 8300.0, 8440.0, 2.5 ] ], [ [ "CamServer", "tcp://sf-daqsync-14.psi.ch:11154 intensity", 50, 0.05, "Enabled" ], [ "Stream", "SAROP21-PBPS103:INTENSITY", 50, 0.05, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SARES30-LTIM01-EVR0:Pul0_NEW_DELAY", 7200.0, 7500.0, 1 ] ], [ [ "Channel", "SARES30-LSCP1-FNS:CH0:VAL_GET", 10, 0.01, "Enabled" ] ], false, [ ], "", 1, 1.0, 0.0, false, false, true, true, "", "", " ", "", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU107:MOTOR_X.VAL", -1.0, 1.0, 0.2 ] ], [ [ "Stream", "SAROP31-PPRM113:intensity", 50, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS113:INTENSITY", 50, 0.1, "Enabled" ] ], false, [ ], "OAPU107 X-scan", 1, 1.0, 0.0, false, false, true, true, "", "", "", "h5", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU107:MOTOR_H.VAL", 0.0, 2.0, 0.02 ] ], [ [ "CamServer", "http://sf-daqsync-01:8889/SAROP31-PPRM113_sp1 intensity", 10, 0.1, "Enabled" ] ], false, [ ], "OAPU149 X-scan", 1, 1.0, 0.0, false, false, true, true, "test2", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU149:MOTOR_X.VAL", -1.3, 2.1, 0.05 ] ], [ [ "CamServer", "tcp://sf-daqsync-16.psi.ch:11112 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "OAPU149 X-scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "csv", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU149:MOTOR_Y.VAL", -1.2, 1.2, 0.05 ] ], [ [ "CamServer", "tcp://sf-daqsync-16.psi.ch:11112 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "OAPU149 Y-scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "csv", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-ODCC110:MOT_ENY.VAL", 7.94, 8.06, 0.002 ] ], [ [ "CamServer", "SAROP31-PPRM113_sp intensity", 80, 0.1, "Disabled" ], [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD4", 80, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-ODCC110:MOT_OFS.VAL", 0.018, 0.026, 2.5E-4 ] ], [ [ "CamServer", "SAROP31-PPRM113_sp intensity", 50, 0.1, "Disabled" ], [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD4", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-ODCC110:MOT_RX2.VAL", 8.725, 8.731, 2.5E-4 ] ], [ [ "CamServer", "SAROP31-PPRM113_sp intensity", 50, 0.1, "Enabled" ] ], false, [ ], "Bernina DCM scan", 1, 1.0, 0.0, false, false, true, true, "", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-PBPS113:MOTOR_X1.VAL", -0.2, 0.2, 0.025 ] ], [ [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD0", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD2", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD1", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS113:Lnk9Ch0-PP_VAL_PD3", 20, 0.1, "Enabled" ] ], false, [ ], "PBPS113 X calibration", 1, 1.0, 0.0, false, false, true, true, "", "", " ", "h5", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-PBPS149:MOTOR_X1.VAL", -0.2, 0.2, 0.05 ] ], [ [ "Stream", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD0", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD2", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD1", 20, 0.1, "Enabled" ], [ "Stream", "SAROP31-PBPS149:Lnk9Ch0-PP_VAL_PD3", 20, 0.1, "Enabled" ] ], false, [ ], "PBPS149 X calibration", 1, 1.0, 0.0, false, false, false, true, "", "", "", "", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAR-EXPMX:MOT_FY.VAL", -0.385, -0.375, 5.0E-4 ], [ "Channel", "", 0.0, 0.0, 1 ] ], [ [ "CamServer", "http://sf-daqsync-01:8889/SARES30-CAMS156-X8M_sp1 intensity", 50, 0.1, "Enabled" ] ], false, [ ], "Sample F-Trans Y", 1, 1.0, 0.0, false, false, true, true, "", "", "", "csv", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAR-EXPMX:MOT_FY.VAL", 3.6053, 3.6253, 5.0E-4 ] ], [ [ "CamServer", "tcp://sf-daqsync-09.psi.ch:11113 intensity", 10, 0.1, "Enabled" ] ], false, [ ], "SwissMX edge scan", 1, 1.0, 0.0, false, false, true, true, "p22553_y1.txt", "", "Default", "txt", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU149:MOTOR_X.VAL", -2.0, 2.0, 0.1 ] ], [ [ "CamServer", "http://sf-daqsync-01:8889/SAROP31-PPRM150_sp1 intensity", 10, 0.1, "Enabled" ], [ "Device", "create_device(\"bs://SAROP31-PBPS149:INTENSITY\")", 10, 0.1, "Enabled" ] ], false, [ ], "", 1, 1.0, 0.0, false, false, true, true, "", "", " ", "", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Deployment specific global definitions - executed after startup.groovy
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Deployment specific global definitions - executed after startup.js
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Executable
+369
@@ -0,0 +1,369 @@
|
||||
###################################################################################################
|
||||
# Deployment specific global definitions - executed after startup.py
|
||||
###################################################################################################
|
||||
|
||||
from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian
|
||||
from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks
|
||||
from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator
|
||||
|
||||
import java.awt.Color as Color
|
||||
|
||||
###################################################################################################
|
||||
# Layout setup
|
||||
###################################################################################################
|
||||
import ch.psi.pshell.data.LayoutSF as LayoutSF
|
||||
LayoutSF.setExperimentArguments([charge, laser, rep_rate_bunch_1, rep_rate_bunch_2, destination_AR, energy_AR])
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Machine utilities
|
||||
###################################################################################################
|
||||
|
||||
LASER_SETTLING_TIME = 3.0
|
||||
|
||||
def laser_on(bunch=None):
|
||||
print "Laser On - bunch “ + str(bunch)
|
||||
#caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 0)
|
||||
if (bunch==1) or (bunch is None):
|
||||
caput("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel", 0)
|
||||
if (bunch==2) or (bunch is None):
|
||||
caput("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel", 0)
|
||||
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
|
||||
time.sleep(LASER_SETTLING_TIME)
|
||||
|
||||
def laser_off(bunch=None):
|
||||
print "Laser Off - bunch “ + str(bunch)
|
||||
#caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 1)
|
||||
if (bunch==1) or (bunch is None):
|
||||
caput("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel", 1)
|
||||
if (bunch==2) or (bunch is None):
|
||||
caput("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel", 1)
|
||||
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
|
||||
time.sleep(LASER_SETTLING_TIME)
|
||||
|
||||
def is_laser_on(bunch=None):
|
||||
#return (caget ("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",'d') == 0 )
|
||||
if bunch==1:
|
||||
return (caget ("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel",'d') == 0 )
|
||||
if bunch==2:
|
||||
return (caget ("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel",'d') == 0 )
|
||||
if bunch is None:
|
||||
return is_laser_on(1) and is_laser_on(2)
|
||||
|
||||
def save_laser_state():
|
||||
global laser_was_on_1, laser_was_on_2
|
||||
laser_was_on_1 = is_laser_on(1)
|
||||
laser_was_on_2 = is_laser_on(2)
|
||||
|
||||
def restore_laser_state():
|
||||
global laser_was_on_1, laser_was_on_2
|
||||
if laser_was_on_1:
|
||||
laser_on(1)
|
||||
else:
|
||||
laser_off(1)
|
||||
if laser_was_on_2:
|
||||
laser_on(2)
|
||||
else:
|
||||
laser_off(2)
|
||||
|
||||
def get_beam_ok_channel(bunch):
|
||||
if bunch==2:
|
||||
return "SIN-CVME-TIFGUN-EVR0:BUNCH-2-OK"
|
||||
if bunch==1:
|
||||
return "SIN-CVME-TIFGUN-EVR0:BUNCH-1-OK"
|
||||
|
||||
def is_timing_ok():
|
||||
return caget("SIN-TIMAST-TMA:SOS-COUNT-CHECK") == 0
|
||||
|
||||
def get_repetition_rate(bunch=1, setp=None):
|
||||
if not setp:
|
||||
if bunch==2:
|
||||
ret = caget(c, 'd')
|
||||
else:
|
||||
ret = caget("SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB", 'd')
|
||||
if setp==False or ret > 0:
|
||||
return ret
|
||||
print "Readback is 0: returning Setpoint"
|
||||
sel = caget("SIN-TIMAST-TMA:Bunch-" + str(bunch) + "-Freq-Sel")
|
||||
return float(sel.split(" ")[0])
|
||||
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Maths utilities
|
||||
###################################################################################################
|
||||
|
||||
def fit(ydata, xdata = None):
|
||||
"""
|
||||
Gaussian fit
|
||||
"""
|
||||
if xdata is None:
|
||||
xdata = frange(0, len(ydata), 1)
|
||||
#ydata = to_list(ydata)
|
||||
#xdata = to_list(xdata)
|
||||
max_y= max(ydata)
|
||||
index_max = ydata.index(max_y)
|
||||
max_x= xdata[index_max]
|
||||
print "Max index:" + str(index_max),
|
||||
print " x:" + str(max_x),
|
||||
print " y:" + str(max_y)
|
||||
gaussians = fit_gaussians(ydata, xdata, [index_max,])
|
||||
(norm, mean, sigma) = gaussians[0]
|
||||
p = plot([ydata],["data"],[xdata], title="Fit" )[0]
|
||||
fitted_gaussian_function = Gaussian(norm, mean, sigma)
|
||||
scale_x = [float(min(xdata)), float(max(xdata)) ]
|
||||
points = max((len(xdata)+1), 100)
|
||||
resolution = (scale_x[1]-scale_x[0]) / points
|
||||
fit_y = []
|
||||
fit_x = frange(scale_x[0],scale_x[1],resolution, True)
|
||||
for x in fit_x:
|
||||
fit_y.append(fitted_gaussian_function.value(x))
|
||||
p.addSeries(LinePlotSeries("fit"))
|
||||
p.getSeries(1).setData(fit_x, fit_y)
|
||||
|
||||
if abs(mean - xdata[index_max]) < ((scale_x[0] + scale_x[1])/2):
|
||||
print "Mean -> " + str(mean)
|
||||
p.addMarker(mean, None, "Mean="+str(round(norm,2)), Color.MAGENTA.darker())
|
||||
return (norm, mean, sigma)
|
||||
else:
|
||||
p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY)
|
||||
print "Invalid gaussian fit: " + str(mean)
|
||||
return (None, None, None)
|
||||
|
||||
|
||||
def hfit(ydata, xdata = None):
|
||||
"""
|
||||
Harmonic fit
|
||||
"""
|
||||
if xdata is None:
|
||||
xdata = frange(0, len(ydata), 1)
|
||||
|
||||
max_y= max(ydata)
|
||||
index_max = ydata.index(max_y)
|
||||
max_x= xdata[index_max]
|
||||
|
||||
start,end = min(xdata), max(xdata)
|
||||
(amplitude, angular_frequency, phase) = fit_harmonic(ydata, xdata)
|
||||
fitted_harmonic_function = HarmonicOscillator(amplitude, angular_frequency, phase)
|
||||
|
||||
print "amplitude = ", amplitude
|
||||
print "angular frequency = ", angular_frequency
|
||||
print "phase = ", phase
|
||||
|
||||
f = angular_frequency/ (2* math.pi)
|
||||
print "frequency = ", f
|
||||
|
||||
resolution = 4.00 # 1.00
|
||||
fit_y = []
|
||||
for x in frange(start,end,resolution, True):
|
||||
fit_y.append(fitted_harmonic_function.value(x))
|
||||
fit_x = frange(start, end+resolution, resolution)
|
||||
|
||||
p = plot(ydata,"data", xdata, title="HFit")[0]
|
||||
p.addSeries(LinePlotSeries("fit"))
|
||||
p.getSeries(1).setData(fit_x, fit_y)
|
||||
|
||||
#m = (phase + math.pi)/ angular_frequency
|
||||
m = -phase / angular_frequency
|
||||
if (m<start):
|
||||
m+=(1.0/f)
|
||||
|
||||
if start <=m <=end:
|
||||
print "fit = ", m
|
||||
p.addMarker(m, None, "Fit="+str(round(m ,2)), Color.MAGENTA.darker())
|
||||
return (amplitude, angular_frequency, phase, True, m, fit_x, fit_y)
|
||||
else:
|
||||
print "max = ",max_x
|
||||
p.addMarker(max_x, None, "Max="+str(round(max_x ,2)), Color.MAGENTA.darker())
|
||||
return (amplitude, angular_frequency, phase, False, max_x, fit_x, fit_y)
|
||||
|
||||
|
||||
def clear_convex_hull_plot(title):
|
||||
plots = get_plots(title = title)
|
||||
if len(plots)>0:
|
||||
plots[0].clear()
|
||||
|
||||
def add_convex_hull_plot(title, x,y, name=None, clear = False, x_range = None, y_range = None):
|
||||
plots = get_plots(title = title)
|
||||
p = None
|
||||
if len(plots)==0:
|
||||
p = plot(None,name=name, title = title)[0]
|
||||
if x_range is not None:
|
||||
p.getAxis(p.AxisId.X).setRange(x_range[0], x_range[1])
|
||||
if y_range is not None:
|
||||
p.getAxis(p.AxisId.Y).setRange(y_range[0], y_range[1])
|
||||
p.setLegendVisible(True)
|
||||
else:
|
||||
p = plots[0]
|
||||
if clear:
|
||||
p.clear()
|
||||
p.addSeries(LinePlotSeries(name))
|
||||
s = p.getSeries(name)
|
||||
s.setLinesVisible(False)
|
||||
s.setPointSize(3)
|
||||
x, y = to_array(x,'d') , to_array(y,'d')
|
||||
s.setData(x, y)
|
||||
|
||||
#Convex Hull
|
||||
#In the first time the plot shows, it takes some time for the color to be assigned
|
||||
timeout = 0
|
||||
while s.color is None and timeout<1000:
|
||||
time.sleep(0.001)
|
||||
timeout = timeout + 1
|
||||
hull = LinePlotSeries(name + "Hull", s.color)
|
||||
p.addSeries(hull)
|
||||
#Bounding box
|
||||
#x1,x2,y1,y2 = min(x), max(x), min(y), max(y)
|
||||
#(hx,hy) = ([x1,x2, x2, x1, x1], [y1, y1, y2, y2, y1])
|
||||
(hx,hy) = convex_hull(x=x, y=y)
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
hull.setLineWidth(2)
|
||||
hull.setData(to_array(hx,'d') , to_array(hy,'d'))
|
||||
hull.setColor(s.color)
|
||||
return [hx,hy]
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Tools
|
||||
###################################################################################################
|
||||
|
||||
def elog(title, message, attachments = [], application = None, author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1):
|
||||
"""
|
||||
Add entry to ELOG.
|
||||
"""
|
||||
if author is None:
|
||||
author = "pshell" #get_context().user.name
|
||||
|
||||
if application is None:
|
||||
application = get_exec_pars().name
|
||||
|
||||
typ = "pshell"
|
||||
entry = ""
|
||||
|
||||
cmd = 'G_CS_ELOG_add -l "' + logbook + '" '
|
||||
cmd = cmd + '-a "Author=' + author + '" '
|
||||
cmd = cmd + '-a "Type=' + typ + '" '
|
||||
cmd = cmd + '-a "Entry=' + entry + '" '
|
||||
cmd = cmd + '-a "Title=' + title + '" '
|
||||
cmd = cmd + '-a "Category=' + category + '" '
|
||||
cmd = cmd + '-a "Domain=' + domain + '" '
|
||||
cmd = cmd + '-a "Application=' + application + '" '
|
||||
for attachment in attachments:
|
||||
cmd = cmd + '-f "' + attachment + '" '
|
||||
cmd = cmd + '-n ' + str(encoding)
|
||||
cmd = cmd + ' "' + message + '"'
|
||||
#print cmd
|
||||
#os.system (cmd)
|
||||
#print os.popen(cmd).read()
|
||||
import subprocess
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
||||
(out, err) = proc.communicate()
|
||||
if (err is not None) and err!="":
|
||||
raise Exception(err)
|
||||
print out
|
||||
import ch.psi.pshell.ui.App as App
|
||||
if not App.isOutputRedirected():
|
||||
import java.lang.System as System
|
||||
System.out.println(out)
|
||||
try:
|
||||
return int(out[out.find("ID=") +3 : ])
|
||||
except:
|
||||
print out
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Pseudo-devices
|
||||
###################################################################################################
|
||||
class Sinusoid(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
self.x = self.x + 5.0 if hasattr(self, 'x') else 0.0
|
||||
return math.sin(self.x * math.pi / 180.0)
|
||||
|
||||
add_device(Sinusoid("sim_sensor"), True)
|
||||
sim_sensor.polling=1000
|
||||
add_device(DummyPositioner("sim_positioner"), True)
|
||||
|
||||
###################################################################################################
|
||||
# Camera server
|
||||
###################################################################################################
|
||||
def wait_cam_server_message(number_messages = 1, timeout = 10000):
|
||||
for i in range (number_messages):
|
||||
if not cam_server.stream.waitCacheChange(timeout):
|
||||
raise Exception("Timeout receiving from camera server")
|
||||
|
||||
def get_cam_server_stats(number_images=1, async = True, interval=-1, good_region = False):
|
||||
ret = []
|
||||
wait_cam_server_message()
|
||||
prefix = "gr_" if good_region else ""
|
||||
for ident in [prefix+"x_center_of_mass", prefix+"y_center_of_mass", prefix+"x_rms", prefix+"y_rms"]:
|
||||
child = cam_server.stream.getChild(ident)
|
||||
av = create_averager(child, number_images, interval)
|
||||
av.monitored = async
|
||||
ret.append(av)
|
||||
return ret
|
||||
|
||||
def wait_cam_server_background(background, timeout = 10000):
|
||||
start = time.time()
|
||||
while True:
|
||||
processing_parameters = cam_server.getProcessingParameters()
|
||||
if (processing_parameters is not None) and (str(background) == processing_parameters["image_background"]):
|
||||
return
|
||||
if (time.time()-start) > timeout/1000:
|
||||
raise Exception("Timeout waiting for camera server background: " + str(background))
|
||||
time.sleep(0.01)
|
||||
|
||||
###################################################################################################
|
||||
# Camera scans
|
||||
###################################################################################################
|
||||
|
||||
def setup_camera_scan():
|
||||
global camera_name, bpm_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
|
||||
if not is_laser_on(1) and not is_laser_on(2):
|
||||
raise Exception("Both bunches are on delay")
|
||||
save_laser_state()
|
||||
multiple_background = multiple_background and use_background
|
||||
cam_server.start(camera_name + "_sp", use_screen_panel_stream)
|
||||
if use_background:
|
||||
if not dry_run:
|
||||
laser_off()
|
||||
bg=cam_server.captureBackground(1 if multiple_background else number_backgrounds)
|
||||
cam_server.setBackgroundSubtraction(True)
|
||||
if not multiple_background: wait_cam_server_background(bg)
|
||||
else:
|
||||
cam_server.setBackgroundSubtraction(False)
|
||||
|
||||
if not multiple_background:
|
||||
if not dry_run:
|
||||
restore_laser_state()
|
||||
|
||||
def before_sample_camera_scan():
|
||||
global camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
|
||||
if multiple_background:
|
||||
bg = cam_server.captureBackground(number_backgrounds)
|
||||
wait_cam_server_background(bg)
|
||||
if not dry_run:
|
||||
#laser_on()
|
||||
restore_laser_state()
|
||||
wait_cam_server_message(number_images)
|
||||
|
||||
def after_sample_camera_scan():
|
||||
if multiple_background:
|
||||
if not dry_run:
|
||||
laser_off()
|
||||
|
||||
def get_camera_scan_sensors():
|
||||
global camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
|
||||
sensors = get_cam_server_stats(number_images, good_region=use_good_region)
|
||||
if plot_image:
|
||||
sensors.append(cam_server.getDataMatrix())
|
||||
return sensors
|
||||
|
||||
def end_camera_scan():
|
||||
global camera_name, number_images, use_background, multiple_background, number_backgrounds, dry_run
|
||||
if not dry_run:
|
||||
restore_laser_state()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
CAMERA_NAME = "SAROP31-PPRM113"
|
||||
cam_server.start(CAMERA_NAME+"_sp1", True) # Connect to pipeline of running instance
|
||||
#Wait first stream message
|
||||
cam_server.stream.waitCacheChange(3000)
|
||||
|
||||
#Getting child devices
|
||||
intensity = cam_server.stream.getChild("gr_intensity")
|
||||
|
||||
#image = cam_server.stream.getChild("image")
|
||||
image=cam_server.getDataMatrix()
|
||||
sensors = [image,intensity, pulse_energy]
|
||||
|
||||
intensity = create_averager(intensity, 3, interval = -1, monitored = True)
|
||||
sensors = [image,intensity, intensity.samples, pulse_energy]
|
||||
lscan(slit_oh_h, sensors, -2.0, 2.0, 0.1, relative=True, latency=0.2, line_plots=[intensity.samples])
|
||||
|
||||
#s=DummyPositioner("Sample")
|
||||
#ascan((slit_oh_h, s) , sensors, (-2.0, -1.0) , (2.0, 1.0) , (0.1, 1.0), relative=True, latency=0.2, line_plots=[intensity, pulse_energy])
|
||||
|
||||
|
||||
#Fitting example
|
||||
#y=[x.doubleValue() for x in r[intensity]]
|
||||
#fit(y, r[slit_oh_h])
|
||||
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
[ "Linear", [ [ "Channel", "SAROP31-OAPU107:MOTOR_W.VAL", 2.0, 2.1, 0.01 ] ], [ [ "Channel", "SAROP31-PBPS149:INTENSITY", 10, 0.1, "Enabled" ] ], false, [ ], "Test", 1, 1.0, 0.0, false, false, true, true, "test_label", "", "Table", "csv", 0, null, null, "Positioner", false, true ]
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#CAMERA = "SAROP31-PPRM113"
|
||||
#CAMERA = "SAROP31-PPRM150"
|
||||
CAMERA = "SARES30-CAMS156-XE"
|
||||
|
||||
|
||||
CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://")
|
||||
#CAMERA_URL= "tcp://sf-sioc-cs-83:9020"
|
||||
#CAMERA_URL= "tcp://sf-sioc-cs-64:9000"
|
||||
|
||||
print CAMERA_URL
|
||||
st1 = Stream("st1", CAMERA_URL, SocketType.PULL)
|
||||
st1.initialize()
|
||||
st1.start()
|
||||
st1.waitCacheChange(3000)
|
||||
try:
|
||||
r=bscan (st1, records=5, timeout=10.0, save=False, enabled_plots=[st1,])
|
||||
v= st1.getValues()
|
||||
finally:
|
||||
st1.close()
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
CAMERA_NAME = "SARES30-CAMS156-XE"
|
||||
USE_SCREEN_PANEL = True
|
||||
SAVE = True
|
||||
|
||||
#Camera setup
|
||||
if USE_SCREEN_PANEL:
|
||||
cam_server.start(CAMERA_NAME+"_sp1", True) # Connect to pipeline of running instance
|
||||
else:
|
||||
cam_server.start(CAMERA_NAME+"_sp") # Create new pipeline given the config namoe
|
||||
|
||||
|
||||
#Changing pipeline parameters
|
||||
cam_server.setThreshold(500)
|
||||
cam_server.setBackgroundSubtraction(False)
|
||||
|
||||
#Wait first stream message
|
||||
cam_server.stream.waitCacheChange(3000)
|
||||
|
||||
#Inspecting stream values
|
||||
names=[]
|
||||
data=[]
|
||||
for k,v in cam_server.value.items():
|
||||
names.append(k)
|
||||
data.append(v)
|
||||
#print k,v
|
||||
#plot(data, names, title="Data")
|
||||
|
||||
|
||||
#Scanning all bsread stream elements
|
||||
#bscan (cam_server.stream, 10, save=SAVE)
|
||||
|
||||
|
||||
#Getting child devices
|
||||
com = cam_server.stream.getChild("x_center_of_mass")
|
||||
rms = cam_server.stream.getChild("x_rms")
|
||||
|
||||
#com=create_averager(com, 3, interval = -1, monitored = True)
|
||||
#rms=create_averager(rms, 3, interval = -1, monitored = True)
|
||||
|
||||
mscan(com, [com,rms], points = -1, timeout = 5.0, save=SAVE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user