Startup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#Wed May 03 09:40:49 CEST 2017
|
||||
#Wed May 03 16:34:50 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapMax=800.0
|
||||
@@ -6,11 +6,11 @@ colormapMin=0.0
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=2160
|
||||
imageWidth=2560
|
||||
imageHeight=1040
|
||||
imageWidth=1392
|
||||
invert=false
|
||||
regionStartX=1
|
||||
regionStartY=1
|
||||
regionStartX=0
|
||||
regionStartY=0
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
@@ -21,9 +21,9 @@ rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
serverURL=localhost\:10000
|
||||
spatialCalOffsetX=-649.4689449397814
|
||||
spatialCalOffsetY=-522.5163272053469
|
||||
spatialCalScaleX=-8.737659608697616
|
||||
spatialCalScaleY=-8.83489815158259
|
||||
spatialCalOffsetX=-1279.4997788627065
|
||||
spatialCalOffsetY=-1079.4997788915095
|
||||
spatialCalScaleX=-53.02070816236811
|
||||
spatialCalScaleY=-53.02454840203798
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Tue May 02 18:33:33 CEST 2017
|
||||
#Wed May 03 11:35:37 CEST 2017
|
||||
defaultSpeed=282.842712474619
|
||||
estbilizationDelay=0
|
||||
hasEnable=false
|
||||
|
||||
@@ -9,12 +9,13 @@ BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel s
|
||||
prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
|
||||
scan_type = args[1] if is_panel else WireScanner.WireX1
|
||||
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
|
||||
cycles = args[3] if is_panel else 2
|
||||
cycles = args[3] if is_panel else 5
|
||||
velocity = args[4] if is_panel else 200
|
||||
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
|
||||
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
|
||||
bkgrd = args[7] if is_panel else 10
|
||||
bkgrd = args[7] if is_panel else 20
|
||||
plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
|
||||
do_elog = True if is_panel else False
|
||||
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, cycles, bpms
|
||||
|
||||
|
||||
@@ -31,9 +32,6 @@ print "Creating scanner..."
|
||||
if prefix not in get_wire_scanners():
|
||||
raise Exception("Invalid wire scan: " + prefix)
|
||||
scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
|
||||
scanner.set_selection(get_scan_selection(scan_type))
|
||||
scanner.init()
|
||||
scanner.waitValue("At start", 60000)
|
||||
|
||||
#List of stream channels
|
||||
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
|
||||
@@ -41,7 +39,10 @@ channels = [("m_pos", scanner.motor_bs_readback.get_name()),
|
||||
("scanning", scanner.status_channels[0].get_name())]
|
||||
for i in range (len(blms)):
|
||||
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
|
||||
plt.addSeries(LinePlotSeries(blms[i], None, min(i+1, 2)))
|
||||
series = LinePlotSeries(blms[i], None, min(i+1, 2))
|
||||
plt.addSeries(series)
|
||||
series.setLinesVisible(False)
|
||||
series.setPointSize(3)
|
||||
for i in range (len(bpms)):
|
||||
for sensor in BPM_SENSORS:
|
||||
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
|
||||
@@ -53,24 +54,22 @@ set_attribute("/", "Range", scan_range)
|
||||
set_attribute("/", "Cycles", cycles)
|
||||
set_attribute("/", "Motor Velocity", velocity*math.sqrt(2))
|
||||
set_attribute("/", "Wire Velocity", velocity)
|
||||
set_attribute("/", "Background Measures", bkgrd)
|
||||
|
||||
#Stream creation
|
||||
print "Starting stream..."
|
||||
st = Stream("pulse_id", dispatcher)
|
||||
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
|
||||
for c in channels:
|
||||
st.addScalar(c[0], c[1], 10, 0)
|
||||
st.initialize()
|
||||
st.start()
|
||||
st.waitCacheChange(10000) #Wait stream be running before starting scan
|
||||
|
||||
|
||||
|
||||
#Pseudo-device returning the wire position
|
||||
class w_pos(Readable):
|
||||
def read(self):
|
||||
return scanner.get_sel_wire_pos(st.getChildren()[0].take())
|
||||
#return scanner.get_sel_wire_pos(scanner.motor_bs_readback.read())
|
||||
|
||||
#End of scan checking
|
||||
scan_complete = None
|
||||
@@ -84,24 +83,55 @@ def check_end_scan(record, scan):
|
||||
record.cancel() #So it won't be saved
|
||||
else:
|
||||
position = record[0]
|
||||
for i in range (len(blms)):
|
||||
plt.getSeries(i).appendData(position, record[5 + i])
|
||||
if record[3] != cur_cycle:
|
||||
cur_cycle = record[3]
|
||||
get_context().dataManager.splitScanData(scan)
|
||||
#for s in plt.getAllSeries():
|
||||
# s.clear()
|
||||
for i in range (len(blms)):
|
||||
plt.getSeries(i).appendData(position, record[5 + i])
|
||||
|
||||
|
||||
#Process background
|
||||
def do_background():
|
||||
#Store Background
|
||||
if bkgrd>0:
|
||||
#scanner.park()
|
||||
#scanner.waitValue("At start", 60000)
|
||||
set_exec_pars(group = "background")
|
||||
r = mscan (st, st.getReadables()[4:], bkgrd)
|
||||
for i in range(len(r.getReadables())):
|
||||
d = r.getReadable(i)
|
||||
m,s = mean(d), stdev(d)
|
||||
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
|
||||
set_attribute(path, "Mean", m)
|
||||
set_attribute(path, "Sigma", s)
|
||||
|
||||
|
||||
|
||||
#Scan
|
||||
def do_scan():
|
||||
def do_scan(index):
|
||||
global scan_complete, cur_cycle
|
||||
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY1]) else "x"
|
||||
set_exec_pars(group=wire+"_{count}", reset=True)
|
||||
scanner.set_selection(get_scan_selection(scan_type, index))
|
||||
if wire == "x":
|
||||
plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
|
||||
else:
|
||||
plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
|
||||
|
||||
scanner.init()
|
||||
scanner.waitValue("At start", 60000)
|
||||
|
||||
scanner.curr_cycl.write(0)
|
||||
time.sleep(1.0)
|
||||
global scan_complete, cur_cycle
|
||||
scan_complete=False
|
||||
cur_cycle = 1
|
||||
cur_cycle = 1.0
|
||||
for s in plt.getAllSeries():
|
||||
s.clear()
|
||||
try:
|
||||
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
|
||||
mscan (st, [w_pos()] + st.getReadables(), -1, -1, after_read = check_end_scan)
|
||||
st.getChild("scanning").waitValue(1.0, 10000)
|
||||
mscan (st, [w_pos()] + st.getReadables(), -1, -1, take_initial = True, after_read = check_end_scan)
|
||||
except:
|
||||
if not scanner.isReady():
|
||||
print "Aborting scan"
|
||||
@@ -109,6 +139,13 @@ def do_scan():
|
||||
if not scan_complete:
|
||||
raise
|
||||
finally:
|
||||
#TODO: Display average of cycles
|
||||
|
||||
#Combining data of multiple series
|
||||
#s=plt.getSeries(0)
|
||||
#indexes = sorted(range(len(s.x)),key=lambda x:s.x[x])
|
||||
#x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
|
||||
#plot(y, xdata = x)
|
||||
img_file = os.path.abspath(get_exec_pars().path + "_" + get_exec_pars().group[0:1] + ".png")
|
||||
time.sleep(0.1) #Give some time to plot finish (async)
|
||||
plt.saveSnapshot(img_file, "png")
|
||||
@@ -116,39 +153,25 @@ def do_scan():
|
||||
|
||||
print "Starting scan..."
|
||||
try:
|
||||
#Background
|
||||
if bkgrd>0:
|
||||
set_exec_pars(group = "background")
|
||||
scanner.curr_cycl.write(1) #To Free the filter
|
||||
mscan (st, st.getReadables(), bkgrd)
|
||||
|
||||
set_exec_pars(group= "y_{count}" if scan_type in [WireScanner.WireY1, WireScanner.WireY1] else "x_{count}");
|
||||
do_scan()
|
||||
do_background()
|
||||
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
|
||||
do_scan(0)
|
||||
if scan_type in [WireScanner.Set1, WireScanner.Set2]:
|
||||
scanner.set_selection(get_scan_selection(scan_type))
|
||||
scanner.set_selection(get_scan_selection(scan_type, 1))
|
||||
scanner.init()
|
||||
scanner.waitValue("At start", 60000)
|
||||
set_exec_pars(group="y_{count}", reset=True)
|
||||
do_scan()
|
||||
# save the entry in the logbook
|
||||
gsa_log_msg = "Data file: " + get_exec_pars().path
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Scanner: " + prefix
|
||||
gsa_log_msg = gsa_log_msg + "\nScan Type: " + str(scan_type)
|
||||
gsa_log_msg = gsa_log_msg + "\nRange: " + str(scan_range)
|
||||
gsa_log_msg = gsa_log_msg + "\nCycles: " + str(cycles)
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Velocity: " + str(velocity)
|
||||
|
||||
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\nSave to ELOG?", "YesNo") == "Yes":
|
||||
elog("Wire Scan", gsa_log_msg, snapshots)
|
||||
|
||||
|
||||
do_scan(1)
|
||||
finally:
|
||||
print "Closing scanner"
|
||||
scanner.close()
|
||||
print "Closing stream"
|
||||
st.close()
|
||||
|
||||
|
||||
|
||||
# save the entry in the logbook
|
||||
if do_elog:
|
||||
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\nSave to ELOG?", "YesNo") == "Yes":
|
||||
gsa_log_msg = "Data file: " + get_exec_pars().path
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Scanner: " + prefix
|
||||
gsa_log_msg = gsa_log_msg + "\nScan Type: " + str(scan_type)
|
||||
gsa_log_msg = gsa_log_msg + "\nRange: " + str(scan_range)
|
||||
gsa_log_msg = gsa_log_msg + "\nCycles: " + str(cycles)
|
||||
gsa_log_msg = gsa_log_msg + "\nWire Velocity: " + str(velocity)
|
||||
elog("Wire Scan", gsa_log_msg, snapshots)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user