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_channel_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() scanner.scan() scanner.waitState(State.Busy, 60000) #Scan def check_end_scan(record, scan): if scanner.isReady(): print "Abort Scan" scan.abort() try: #tscan (st.getReadables(), int(scanner.get_total_time() * 2.0 / 0.1), 0.1, after_read =check_end_scan) #bscan (st, int(scanner.get_total_time() * 2.0 / 0.1), after_read =check_end_scan) #Sampling 10 elements 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() raise finally: print "Closing" scanner.close() st.close()