Closedown

This commit is contained in:
sfop
2017-04-04 15:29:52 +02:00
parent 64d33591bc
commit 5e02cbc13e
4 changed files with 116 additions and 34 deletions
+8 -5
View File
@@ -7,15 +7,17 @@ if get_exec_pars().source == CommandSource.ui:
step = 20.0
nb = 5
lat = 1.0
disp = caget("SINBD01-DSCR010:DISPERSION-SIM")
energy0 = caget("SINBD01-DSCR010:ENERGY-SIM")
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
energy0 = args[6]
disp = caget("SINBD01-DSCR010:DISPERSION-SIM")
energy0 = caget("SINBD01-DSCR010:ENERGY-SIM")
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE", "SINEG01-RSYS:SET-VSUM-PHASE")
phase.config.minValue =-180.0
@@ -29,13 +31,11 @@ camtool.start("SINBD01-DSCR010")
while camtool.stream.getChild("gr_x_fit_mean") == None:
time.sleep(0.1)
x = camtool.stream.getChild("gr_x_fit_mean")
dx = camtool.stream.getChild("gr_x_fit_standard_deviation")
try:
xb = create_averager(x, nb, -1)
xb = create_averager(x, nb, -1) # -1 event based, waits for the next value
dxb = create_averager(dx, nb, -1)
dxb.monitored=True # not blocking, will return last nb values
r = lscan(phase, [xb, dxb], start, stop, step , latency=lat)
@@ -44,6 +44,7 @@ try:
dE = [energy0 * (val.mean / 1e6 / disp) for val in r.getReadable(1)]
finally:
phase.close()
camtool.stop() # stops camtool but does not close it camtool is a global object
p = plot(None, title="Output")[0]
p.clear()
@@ -52,3 +53,5 @@ p.addSeries(LinePlotSeries("Energy spread"))
p.getSeries(0).setData(to_array(rf_phase, 'd'), E)
p.getSeries(1).setData(to_array(rf_phase, 'd'), dE)
p.setLegendVisible(True)
set_return([E,dE])