def waitfor_proton_charge(threshold): """Set, trigger, read until the current reaches threshold""" i = 0 while True: print("Waiting for Proton Charge (> %f) LOOP %d" % (threshold, i)) yield from trigger(bs_pcharge, wait=True) current_pcharge = yield from read(bs_pcharge) if current_pcharge['bs_pcharge']['value'] >= threshold: print('DONE') break i += 1
def inner_xpcs(): yield from bp.checkpoint() yield from bp.create() for det in detectors: # Start acquisition. yield from bp.trigger(det) # Read the UID that points to this dataset in progress. yield from bp.read(det) # Insert an 'Event' document into databroker. Now we can access the (partial) dataset. yield from bp.save() # *Now* wait for the detector to actual finish acquisition. yield from bp.wait()
def dull_scan(mot, count, sig=None, sleep_time=0): if sig: thread = threading.Thread(target=sig_sequence, args=(sig, )) thread.start() for i in range(count): yield from checkpoint() try: yield from mv(mot, i) except: pass # make every step take 1s extra yield from sleep(sleep_time) yield from checkpoint() yield from create() yield from read(mot) yield from save() yield from checkpoint()