def rotate_and_collect_data(self, angle, duration): print "Rotating to " + str(angle) + " deg..." g.set_pv(self.gonio_pv, angle) g.waitfor_move() g.change_title(g.get_title + " rot " + str(angle)) print "Beginning Run " + g.get_title + ". Collecting data for " + str(duration) + " s." g.begin() g.waitfor_time(seconds=duration) # waitfor_uamps better? g.end() print "Run complete."
def pv_motion(pv_str, name): """Create a motion object around a PV string.""" return Motion( lambda: g.get_pv(pv_str), lambda x: g.set_pv(pv_str, x), name, unit=g.get_pv(pv_str + ".EGU"), velocity_getter=lambda: g.get_pv("{}.VELO".format(pv_str)), velocity_setter=lambda x: g.set_pv("{}.VELO".format(pv_str), x), tolerance_getter=lambda: g.get_pv("{}.RDBD".format(pv_str)))
def __init__(self, block, unit): blocks = g.get_blocks() if block not in blocks: new_name = [ name for name in blocks if name and name.lower() == block.lower() ] if new_name: block = new_name[0] else: raise RuntimeError("Unknown block {}.".format(block)) Motion.__init__( self, lambda: g.cget(block)["value"], lambda x: g.cset(block, x), block, unit=unit, # Workarounds until a better solution to get fields # from blocks is implemented in IBEX. Note that IBEX # blocks must point at AXIS:MTR rather than AXIS for # this to work. velocity_getter=lambda: g.get_pv("CS:SB:{}.VELO".format(block), is_local=True), velocity_setter=lambda vel: g.set_pv( "CS:SB:{}.VELO".format(block), vel, is_local=True), tolerance_getter=lambda: g.get_pv("CS:SB:{}.RDBD".format(block), is_local=True), )
def start_ngem(): g.set_pv("NGEM_01:UPDATETOF:SP", 1, is_local=True) time.sleep(0.1) g.set_pv("NGEM_01:START:SP", 1, is_local=True)
def set_ngem_file_prefix(): g.set_pv("NGEM_01:FILEPREFIX:SP", 1, is_local=True)
def write_ngem_file(): g.set_pv("NGEM_01:WRITEFILE:SP", 1, is_local=True)
def stop_ngem(): g.set_pv("NGEM_01:STOP:SP", 1, is_local=True)
def detectoronoff(onoff=0,delay=1): if(onoff==1): gen.set_pv("IN:LARMOR:CAEN:hv0:0:8:pwonoff","On") gen.set_pv("IN:LARMOR:CAEN:hv0:0:9:pwonoff","On") gen.set_pv("IN:LARMOR:CAEN:hv0:0:10:pwonoff","On") gen.set_pv("IN:LARMOR:CAEN:hv0:0:11:pwonoff","On") else: gen.set_pv("IN:LARMOR:CAEN:hv0:0:8:pwonoff","Off") gen.set_pv("IN:LARMOR:CAEN:hv0:0:9:pwonoff","Off") gen.set_pv("IN:LARMOR:CAEN:hv0:0:10:pwonoff","Off") gen.set_pv("IN:LARMOR:CAEN:hv0:0:11:pwonoff","Off") # wait for 3 minutes for ramp up 60s to ranmp down if(delay==1): if(onoff==1): print "Waiting For Detector To Power Up (180s)" sleep(180) else: print "Waiting For Detector To Power Down (60s)" sleep(60)
def homecoarsejaws(): print "Homing Coarse Jaws" gen.cset(cjhgap=40,cjvgap=40) gen.waitfor_move() # home north and west gen.set_pv("IN:LARMOR:MOT:JAWS1:JN:MTR.HOMR","1") gen.set_pv("IN:LARMOR:MOT:JAWS1:JW:MTR.HOMR","1") gen.waitfor_move() gen.set_pv("IN:LARMOR:MOT:JAWS1:JN:MTR.VAL","20") gen.set_pv("IN:LARMOR:MOT:JAWS1:JW:MTR.VAL","20") # home south and east gen.set_pv("IN:LARMOR:MOT:JAWS1:JS:MTR.HOMR","1") gen.set_pv("IN:LARMOR:MOT:JAWS1:JE:MTR.HOMR","1") gen.waitfor_move() gen.set_pv("IN:LARMOR:MOT:JAWS1:JS:MTR.VAL","20") gen.set_pv("IN:LARMOR:MOT:JAWS1:JE:MTR.VAL","20")
from genie_python import genie as g g.set_instrument(None) # set filename g.set_pv("ECLAB_01:C0:FILEPREFIX:SP", "c:/data/eclab", is_local=True) # set first ocv g.set_pv("ECLAB_01:C0:T:OCV:0:RTT:SP", 10, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:REDE:SP", 1, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:REDT:SP", 1, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:TB:SP", 20e-6, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:IRANGE:SP", 8, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:ERANGE:SP", 3, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:BW:SP", 5, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:0:XCTR:SP", 0, is_local=True) # 1 # set second ocv g.set_pv("ECLAB_01:C0:T:OCV:1:RTT:SP", 10, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:REDE:SP", 1, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:REDT:SP", 1, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:TB:SP", 20e-6, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:IRANGE:SP", 8, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:ERANGE:SP", 3, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:BW:SP", 5, is_local=True) g.set_pv("ECLAB_01:C0:T:OCV:1:XCTR:SP", 0, is_local=True) # 1 vsinit = [ 1, 1, 1 ] istep = [ 1.0, 1.0, 1.0 ] durstep = [ 10.0, 11.0, 12.0 ] stepn = len(istep) - 1