Startup
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
run("Devices/Elements")
|
||||
run("Devices/WireScanner")
|
||||
|
||||
if is_panel:
|
||||
prefix = args[0]
|
||||
sel = args[1]
|
||||
start = args[2]
|
||||
end = args[3]
|
||||
cycles = args[4]
|
||||
velocity = args[5]
|
||||
bpm3 = args[6]
|
||||
else:
|
||||
prefix = "SINDI01-DWSC090" #"SARCL02-DWSC270"
|
||||
sel = WireScanner.W1X
|
||||
start = -200
|
||||
end = 200
|
||||
cycles = 5
|
||||
velocity = 200
|
||||
bpm3 = None
|
||||
|
||||
#Creating WireScanner object
|
||||
if prefix not in get_wire_scans():
|
||||
raise Exception("Invalid wire scan: " + prefix)
|
||||
scanner = WireScanner(prefix, sel, start, end, cycles, velocity, True)
|
||||
|
||||
#Stream channels
|
||||
bs_position = scanner.motor_bs_readback.get_name()
|
||||
bpms = get_wire_scans_bpms(prefix)
|
||||
if bpms is None:
|
||||
raise Exception("Cannot determine wire scan bpms: " + prefix)
|
||||
channels = [("w_pos", bs_position)]
|
||||
if bpm3 is not None:
|
||||
bpms.append(bpm3)
|
||||
|
||||
for i in range (len(bpms)):
|
||||
channels.append (("bpm" + str(i+1) + "_x", bpms[i] + ":X1"))
|
||||
channels.append (("bpm" + str(i) + "_y", bpms[i] + ":Y1"))
|
||||
channels.append (("bpm" + str(i) + "_q", bpms[i] + ":Q1"))
|
||||
|
||||
#Stream creation
|
||||
st = Stream("pulse_id", dispatcher)
|
||||
for c in channels:
|
||||
st.addScalar(c[0], c[1], 10, 0)
|
||||
st.initialize()
|
||||
st.start()
|
||||
st.waitCacheChange(10000)
|
||||
scanner.scan()
|
||||
scanner.waitState(State.Busy, 60000)
|
||||
|
||||
#End of scan checking
|
||||
scan_complete=False
|
||||
def check_end_scan(record, scan):
|
||||
global scan_complete
|
||||
if scanner.isReady():
|
||||
print "Abort Scan"
|
||||
scan_complete=True
|
||||
scan.abort()
|
||||
|
||||
#Metadata
|
||||
def write_metadata(path):
|
||||
try:
|
||||
set_attribute(path, "Wire Scan", prefix)
|
||||
set_attribute(path, "Selection", sel)
|
||||
set_attribute(path, "Range", scaner.scan_range)
|
||||
set_attribute(path, "Cycles", scanner.cycles )
|
||||
set_attribute(path, "Velocity", scanner.velocity )
|
||||
except:
|
||||
pass
|
||||
|
||||
#Scan
|
||||
try:
|
||||
mscan (st, st.getReadables() +[scanner.curr_cycl] , -1, scanner.get_total_time() * 2.0, after_read =check_end_scan) # *2.0 to account for accelerations an dother delays
|
||||
except:
|
||||
if not scanner.isReady():
|
||||
print "Aborting Wire Scan"
|
||||
scanner.abort()
|
||||
if not scan_complete:
|
||||
raise
|
||||
finally:
|
||||
write_metadata(get_exec_pars().scanPath)
|
||||
print "Closing scanner"
|
||||
scanner.close()
|
||||
st.close()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user