scan_completed = False try: while True: waiting = True class Time(Readable): def __init__(self): self.start = time.time() def read(self): return time.time()-self.start tm = Time() class norm_tey(Readable): def read(self): return float(cadc1.take())/float(cadc2.take()) class norm_diode(Readable): def read(self): return float(cadc3.take())/float(cadc2.take()) snaps = (pol_mode, pol_angle,pol_offset) diags = (current.cache) sensors = [energy_ma_rbv, cadc1, cadc2, cadc3, cadc4, cadc5, norm_tey(), norm_diode(), tm] tm.setAlias("time") cadc1.setAlias("tey_raw") cadc2.setAlias("i0") cadc3.setAlias("diode_raw") def monitoring_task(): global scan_completed time.sleep(5.0) scan_completed = True get_exec_pars().currentScan.abort() monitoring_future = fork(monitoring_task)[0] print "Scanning...", try: mscan( energy_ma_rbv, sensors, -1, None, \ range="auto", domain_axis=tm.alias, \ #energy_ma_rbv.name, enabled_plots=["norm_tey", "norm_diode", cadc1, cadc3, cadc2], \ snaps=snaps, diags=diags) finally: monitoring_future.cancel(True) print "Finished Energy scan." if after_sample(): #Repeat if id error and not ABORT_ON_ID_ERROR: break except: if not scan_completed: print sys.exc_info() print("Aborting...") raise