Exemplo n.º 1
0
def DICLiveImage(det, HutchLetter=None, expTime=None):
    if HutchLetter is None:
        print "hutch letter missing."
        print "e: 1-id-e"
        HutchLetter = raw_input("enter hutch letter : ")

    ## LIGHT CONTROL
    if HutchLetter is "e":
        # DIODE FOR OVERHEAD LIGHTS
        pvname = "1ide1:IPC1:ch3"
        #        while mac1id.IsLightOn(pvname):
        #            spec.sleep(0.5)

        # PULIZZI LIGHT SWITCH
        pv_indicator = "1ide1:IPC1:ch3"
        pv_on_switch = "1ide1:IPC1:on_ch3.PROC"
        pv_off_switch = "1ide1:IPC1:off_ch3.PROC"
        if ep.caget(pv_indicator) is False:
            print "pulizzi dic light is off"
            while ep.caget(pv_indicator) is False:
                ep.caput(pv_on_switch, 1)
                spec.sleep(0.25)
            print "pulizzi dic light is on"
    else:
        print "no photo diodes / dic lights implemented"

    AD.AD_set(det, "image_mode", 2)
    AD.AD_set(det, "autosave", 0)
    AD.AD_set(det, "acquire_time", expTime)
    print "python console control returned"
    print "press STOP button to finish live dic feed"
    AD.AD_set(det, "acquire", 1)
Exemplo n.º 2
0
def bpm_monitor (logname):
    print 'monitoring in progress'
    
    while True:
        mac.write_logging_header(logname)
        mac.write_logging_parameters(logname)
        
        print 'do not shut off unless authorized by ali'
        print time.ctime() + ' : wrote bpm data to ' + logname
        spec.sleep(10)
Exemplo n.º 3
0
def motor_monitor(logname):
    print "motor monitoring in progress"

    while True:
        mac.write_logging_header(logname)
        mac.write_logging_parameters(logname)

        print "do not shut off unless authorized by ali"
        print time.ctime() + " : wrote motor data to " + logname
        spec.sleep(10)
Exemplo n.º 4
0
def check_beam_shutterC(): #arm shutters
    '''If not already open, open 1-ID-C Safety shutter to bring beam into 1-ID-C.
    Keep trying in an infinite loop until the shutter opens.
    '''
    if not (EPICS and spec.UseEPICS()): # in simulation
        print "Confirm C-Hutch Shutter is open"
        return
    while shutterC_state.get() != 0: #true if shutter is closed (0=Open)
        print "opening C shutter"
        shutterC_openPV.put(1)
        spec.sleep(6) #open the shutter & wait
    return
Exemplo n.º 5
0
def check_beam_shutterA():
    '''If not already open, open 1-ID-A Safety shutter to bring beam into 1-ID-A.
    Keep trying in an infinite loop until the shutter opens.
    '''
    if not (EPICS and spec.UseEPICS()): # in simulation
        print "Confirm A-Hutch Shutter is open"
        return
    i = 0
    while shutterA_state.get() != 0: # 1 is Closed
        print "sleeping due to beam dump"
        if i == 0: 
            p = PV(shutterA_openPV)
        i += 1
        p.put(1) # send a open command to PV in shutterA_openPV (1=Open)
        spec.sleep(10)
    return
Exemplo n.º 6
0
def DICTakeImage(det, HutchLetter=None, expTime=None):
    if HutchLetter is None:
        print "hutch letter missing."
        print "e: 1-id-e"
        HutchLetter = raw_input("enter hutch letter : ")

    ## LIGHT CONTROL
    if HutchLetter is "e":
        # DIODE FOR OVERHEAD LIGHTS
        pvname = "1ide1:IPC1:ch3"
        #        while mac1id.IsLightOn(pvname):
        #            spec.sleep(0.5)

        # PULIZZI LIGHT SWITCH
        pv_indicator = "1ide1:IPC1:ch3"
        pv_on_switch = "1ide1:IPC1:on_ch3.PROC"
        pv_off_switch = "1ide1:IPC1:off_ch3.PROC"
        if ep.caget(pv_indicator) is False:
            print "pulizzi dic light is off"
            while ep.caget(pv_indicator) is False:
                ep.caput(pv_on_switch, 1)
                spec.sleep(0.25)
            print "pulizzi dic light is on"
    else:
        print "no photo diodes / dic lights implemented"

    AD.AD_set(det, "image_mode", 0)
    AD.AD_set(det, "autosave", 1)
    AD.AD_set(det, "acquire_time", expTime)
    AD.AD_set(det, "acquire", 1)

    while AD.AD_get(det, "state"):
        spec.sleep(0.25)

    AD.AD_set(det, "autosave", 0)

    filenum = AD.AD_get(det, "filenumber") - 1
    print "last image number is " + str(filenum)
Exemplo n.º 7
0
def beep_dac(beeptime=1.0):
    '''
    Set the 1-ID beeper on for a fixed period, which defaults to 1 second
    uses PV object beeper (defined as 1id:DAC1_8.VAL)
    makes sure that the beeper is actually turned on and off
    throws exception if beeper fails

    :param float beeptime: time to sound the beeper (sec), defaults to 1.0

    '''
    if not (EPICS and spec.UseEPICS()): # in simulation, use the terminal bell
        print('\a\a\a')
        return
    volume = 9 # beeper volume setting
    # part 1: set DAC to ON
    val = 0 # value of DAC (initialized)
    i = 0 # loop counter
    while abs(val-volume)>0.1: # within 0.1 V is OK by me
        if i > 10: # give up after 10 tries
            raise Exception,'Set Beep failed in 10 tries'
        i+=1
        beeper.put(volume, True, 10.) # set on
        val = beeper.get(use_monitor=False) # read value; force rereading of current value
        if val != volume: spec.sleep(0.01) # wait before trying again
        if val is None: val = 9999  # don't crash, even if beeper.get fails on read
        
    # part 2: delay while on
    spec.sleep(beeptime)
    
    # part 3: turn DAC OFF
    i = 0
    while abs(val)>0.1:
        if i > 10: 
            raise Exception,'Clear Beep failed in 10 tries'
        i += 1
        beeper.put(0, True, 10.)   # 0 is beeper off
        spec.sleep(0.001)
        val = beeper.get()
        if val is None: val = 9999  # don't crash, even if beeper.get fails on read
    # all done
    return
Exemplo n.º 8
0
def waitmove():
    while not alldone.get():
        spec.sleep(1)
    logging.info("keep waiting for motor(s) to stop? " + str(alldone.get() != 1) )
Exemplo n.º 9
0
     vval = spectrum_y + numpy.random.normal(size=len(spectrum_x))*25
     vbg = spectrum_y + numpy.random.normal(size=len(spectrum_x))*25
     
     time.sleep(tframe)
     
 elif testing_flag is False:
     print '###################################################'
     print 'In experiment mode - Motors WILL be moved'
     print '###################################################'
     
     ## check motors have gotten to positions & wait until motion finished
     spec.mmv(targets,wait=False)
     spec.ummv(targets)
     
     ## Safety
     spec.sleep(0.2)
     
     ### CHECK FOR RING STATUS
     while ring_current.get() < 10:
         print 'waiting for ring to come back'
         spec.sleep(10)
         
     ### WAIT FOR SHUTTER IF CLOSED OR TRY TO OPEN
     while (shutter_state.get() is 0) and (ring_current.get() > 10):
         print 'waiting for shutter to open'
         shutter_control.put(1)
         spec.sleep(20)
         
     ### TAKE DATA
     horz_EraseStart.put(1)
     vert_EraseStart.put(1)
Exemplo n.º 10
0
    prefixstr = '1ide1:m' + str(i)
    spec.DefineMtr(symstr, prefixstr, '')

###################################################    
### START MONITORING
###################################################
nmtr = len(spec.mtrDB)

#################################################
# PV RECORD
#################################################       
while True:
    for i in range(0, nmtr+1):
        print time.ctime()
        print 'monitoring in progress'
        print 'do not shut off unless authorized by ali'
        idx = 1000 + i
        idxstr = 'mtr' + str(idx)

        mtr = spec.mtrDB[idxstr]
        t = time.localtime()
        
        fname = mtr.symbol + "_" + str(t[0]) + "_" + str(t[1]) + "_" + str(t[2]) + "_" + str(t[3]) + "_" + str(t[4]) + ".data"
        pfname = os.path.join(pname, fname)

        ## hdf5_db = h5py.File('myfile.hdf5','r')
        mtr.mtr_pv.show_all()
        mtr.mtr_pv.write_state(pfname)
        
    spec.sleep(30*60)
Exemplo n.º 11
0
def pv_monitor (LogName, TimeInterval):
    print 'monitoring in progress'
    
    # s1id_staff = ['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
    s1id_staff = ['pa[email protected]', '[email protected]']
    
    GE_Temp_Thresh = 27
    
    ###################################################    
    ### INITIATE LOGGING
    ###################################################
    mac.init_logging()
    
    ### INFO FROM TALL PANEL
    mac.add_logging_PV('Iring (mA)','S:SRcurrentAI')
    mac.add_logging_PV('ID Gap (mm)','ID01:Gap.VAL')
    mac.add_logging_PV('Energy (keV)','1id:userTran3.A')

    mac.add_logging_PV('1st Raw Signal A (uA)','FE:01:ID:1XBPM:A:CC')
    mac.add_logging_PV('1st Raw Signal B (uA)','FE:01:ID:1XBPM:B:CC')
    mac.add_logging_PV('1st Raw Signal C (uA)','FE:01:ID:1XBPM:C:CC')
    mac.add_logging_PV('1st Raw Signal D (uA)','FE:01:ID:1XBPM:D:CC')
    
    mac.add_logging_PV('2nd Raw Signal A (uA)','FE:01:ID:2XBPM:A:CC')
    mac.add_logging_PV('2nd Raw Signal B (uA)','FE:01:ID:2XBPM:B:CC')
    mac.add_logging_PV('2nd Raw Signal E (uA)','FE:01:ID:2XBPM:E:CC')
    mac.add_logging_PV('2nd Raw Signal F (uA)','FE:01:ID:2XBPM:F:CC')
    
    mac.add_logging_PV('1XBPM VPOS (mm)','FE:01:ID:1XBPM:VPOS:CC')
    mac.add_logging_PV('2XBPM VPOS (mm)','FE:01:ID:2XBPM:VPOS:CC')
    
    mac.add_logging_PV('1XBPM HPOS (mm)','FE:01:ID:1XBPM:HPOS:CC')
    mac.add_logging_PV('2XBPM HPOS (mm)','FE:01:ID:2XBPM:HPOS:CC')
    
    mac.add_logging_PV('XBPM VPOS Norm @ SRC (mm)','FE:01:ID:VPOSITION:CC')
    mac.add_logging_PV('XBPM VANGLE Norm @ SRC (urad)','FE:01:ID:VANGLE:CC')
    mac.add_logging_PV('XBPM HPOS Norm @ SRC (mm)','FE:01:ID:HPOSITION:CC')
    mac.add_logging_PV('XBPM HANGLE Norm @ SRC (urad)','FE:01:ID:HANGLE:CC')
    
    mac.add_logging_PV('PBPM VPOS (mm)','S1:ID:SrcPt:yPositionM')
    mac.add_logging_PV('PBPM VANGLE (urad)','S1:ID:SrcPt:yAngleM')
    mac.add_logging_PV('PBPM HPOS (mm)','S1:ID:SrcPt:xPositionM')
    mac.add_logging_PV('PBPM HANGLE (urad)','S1:ID:SrcPt:xAngleM')
    
    ### INFO FROM WIDE PANEL
    mac.add_logging_PV('SR Current (mA)','BL01:srCurrent')
    mac.add_logging_PV('SR Life Time (h)','BL01:srLifetime')
    # mac.add_logging_PV('ID Gap (mm)','BL01:Gap')
    # mac.add_logging_PV('Harmonic','BL01:Harmonic')
    # mac.add_logging_PV('Energy (keV)','BL01:Energy')
    
    mac.add_logging_PV('1st Raw Signal A (uA)','BL01:ID:1XBPM:A')
    mac.add_logging_PV('1st Raw Signal B (uA)','BL01:ID:1XBPM:B')
    mac.add_logging_PV('1st Raw Signal C (uA)','BL01:ID:1XBPM:C')
    mac.add_logging_PV('1st Raw Signal D (uA)','BL01:ID:1XBPM:D')
    
    mac.add_logging_PV('2nd Raw Signal A (uA)','BL01:ID:2XBPM:A')
    mac.add_logging_PV('2nd Raw Signal B (uA)','BL01:ID:2XBPM:B')
    mac.add_logging_PV('2nd Raw Signal C (uA)','BL01:ID:2XBPM:E')
    mac.add_logging_PV('2nd Raw Signal D (uA)','BL01:ID:2XBPM:F')
    
    mac.add_logging_PV('RF BPM VPOS Norm @ SRC','BL01:SRID:VPosition')
    mac.add_logging_PV('RF BPM VANGLE Norm @ SRC','BL01:SRID:VAngle')
    mac.add_logging_PV('RF BPM HPOS Norm @ SRC','BL01:SRID:HPosition')
    mac.add_logging_PV('RF BPM HANGLE Norm @ SRC','BL01:SRID:HAngle')
    
    mac.add_logging_PV('1XBPM VPOS (mm)','BL01:ID:1XBPM:VPOS')
    mac.add_logging_PV('2XBPM VPOS (mm)','BL01:ID:2XBPM:VPOS')
    mac.add_logging_PV('VPOS (mm)','BL01:ID:XBPM:VPosition')
    
    mac.add_logging_PV('1XBPM HPOS (mm)','BL01:ID:1XBPM:HPOS')
    mac.add_logging_PV('2XBPM HPOS (mm)','BL01:ID:2XBPM:HPOS')
    mac.add_logging_PV('HPOS (mm)','BL01:ID:XBPM:HPosition')
    
    mac.add_logging_PV('VANGLE (urad)','BL01:ID:XBPM:VAngle')
    mac.add_logging_PV('HANGLE (urad)','BL01:ID:XBPM:HAngle')
    
    ### SR PARAMETERS INFO
    mac.add_logging_PV('BEAM RMS V Motion (um)','SRFB:dsp2:yRMSmotion30HzPkM.VAL')
    mac.add_logging_PV('BEAM RMS H Motion (um)','SRFB:dsp2:xRMSmotion30HzPkM.VAL')
    mac.add_logging_PV('BEAM V EMITTANCE','S:VID1:filteredYemittance')
    mac.add_logging_PV('BEAM H EMITTANCE','S:VID1:filteredXemittance')
    mac.add_logging_PV('Coupling','S:VID1:filteredCoupling')
    
    ### UNDULATOR INFO
    mac.add_logging_PV('US UND GAP (mm)','ID01us:Gap.VAL')
    mac.add_logging_PV('US UND GAP SET (mm)','ID01us:GapSet.VAL')
    mac.add_logging_PV('US UND Harmonic Value','ID01us:HarmonicValue')
    mac.add_logging_PV('DS UND GAP (mm)','ID01ds:Gap.VAL')
    mac.add_logging_PV('DS UND GAP SET (mm)','ID01ds:GapSet.VAL')
    mac.add_logging_PV('DS UND Harmonic Value','ID01ds:HarmonicValue')
    
    ### HEM TEMPERATURE
    mac.add_logging_PV('HEM 1st XSTAL Temp (K)','1ida:LS218:1:ch1_degK.VAL')
    mac.add_logging_PV('HEM 1st XSTAL MANIFOLD T (K)','1ida:LS218:1:ch2_degK.VAL')
    
    ### LOVE CONTROLLER CONTROL VALUES
    mac.add_logging_PV('P1','1ida:love32:Value')
    mac.add_logging_PV('P2','1ida:love33:Value')
    
    ### AMI
    mac.add_logging_PV('Stablizer Level','1ida:AMI286:1:ch1:Level.VAL')
    mac.add_logging_PV('DD Level','1ida:AMI286:1:ch2:Level.VAL')
    mac.add_logging_PV('DD Valve','1ida:AMI286:1:ch2:Fill.VAL')
    mac.add_logging_PV('Buffer Level','1ida:AMI286:2:ch1:Level.VAL')
    mac.add_logging_PV('Vessel Level','1ida:AMI286:2:ch2:Level.VAL')
    mac.add_logging_PV('Vessel Valve','1ida:AMI286:2:ch2:Fill.VAL')
    
    ### HUTCH TEMPERATURES
    mac.add_logging_PV('A-hutch T (deg C)','1ida:DP41:s1:temp.VAL')
    mac.add_logging_PV('B-hutch T (deg C)','1ida:DP41:s2:temp.VAL')
    mac.add_logging_PV('C-hutch T (deg C)','1id:DP41:s1:temp.VAL')
    mac.add_logging_PV('E-hutch T TILT1 (deg C)','1ide:USdig_X3:1:T')
    mac.add_logging_PV('E-hutch T TILT2 (deg C)','1ide:USdig_X3:2:T')
    
    ### WB SLITS
    mac.add_logging_PV('WB Hr Size','1ida:Slit1Ht2.C')
    mac.add_logging_PV('WB Vt Size','1ida:Slit1Vt2.C')
    mac.add_logging_PV('WB Hr Pos','1ida:Slit1Ht2.D')
    mac.add_logging_PV('WB Vt Pos','1ida:Slit1Vt2.D')
    
    ### IC
    mac.add_logging_PV('B-IC1','1id:scaler2.S3')
    mac.add_logging_PV('C-Split IC1','1id:scaler2.S11')
    mac.add_logging_PV('C-Split IC2','1id:scaler2.S12')
    mac.add_logging_PV('E-Split IC1','1ide:S1:scaler1.S2')
    mac.add_logging_PV('E-Split IC2','1ide:S1:scaler1.S3')
    
    ### GAS PRESSURES
    mac.add_logging_PV('Ni P','1idc:DP41:1:Filtered')
    mac.add_logging_PV('He P','1idc:DP41:2:Filtered')
    mac.add_logging_PV('Ar P','1idc:DP41:3:Filtered')
    
    ### GE TEMPERATURES
    mac.add_logging_PV('HYDRA ORANGE LOOP (deg C)','1ide:DP41:s2:temp.VAL')
    mac.add_logging_PV('HYDRA BLUE LOOP (deg C)','1ide:DP41:s3:temp.VAL')
    
    OrgLoopPV = PyEpics.pv.PV('1ide:DP41:s2:temp.VAL')
    BluLoopPV = PyEpics.pv.PV('1ide:DP41:s3:temp.VAL')
    
    while True:
        mac.write_logging_header(LogName)
        mac.write_logging_parameters(LogName)
        
        print 'Do not shut off unless authorized by S1 staff'
        print time.ctime() + ' : wrote PV data'
        
        if (OrgLoopPV.get() > GE_Temp_Thresh) or (BluLoopPV.get() > GE_Temp_Thresh):
            pv_alert(s1id_staff, LogName, TimeInterval, AlertType=1)
            
        spec.sleep(TimeInterval)
Exemplo n.º 12
0
def EnergyMonitor(pfname=None, elename=None):
    ''' 
    Energy monitoring macro 
    Foil configuration needs to be checked to make sure that it is up to date.

    :param str pfname: output file for energy monitoring result. 
    if nonthing is provided, results is written in the default file.

    :param int/str elename: element name or number for energy monitor. 
    if nothing is provided, user gets to choose before the function spins the wheel.
    '''

    # DEFINE INPUT & OUTPUT FILES
    if pfname is None:
        # pfname = os.path.join(
        #     os.path.split(os.path.split(os.path.abspath(__file__))[0])[0],
        #     '1ID',
        #     'EnergyMonitor.data')
        pfname = './exp_setup/energymonitortest.data'
    print('writing energy monitor results to file: '+str(pfname))

    if elename is None:
        print '65: Tb, 51.996 keV'
        print '70: Yb, 61.332 keV'
        print '72: Hf, 65.351 keV'
        print '79: Au, 80.723 keV'
        print '83: Bi, 90.527 keV'
        elename = raw_input('enter appropriate element number to start energy monitor: ')
        elename = int(elename)
    
    # MOVE FOIL IN
    if elename == 65 or elename is 'Tb':
        spec.umv(spec.foilB, 135)
    elif elename == 70 or elename is 'Yb':
        spec.umv(spec.foilB, 90)
    elif  elename == 72 or elename is 'Hf':
        spec.umv(spec.foilB, -135)
    elif  elename == 83 or elename is 'Bi':
        spec.umv(spec.foilB, 45)
    else:
        raise NameError('foil not on the wheel.')
    spec.sleep(0.25)

    # COUNT / CALCULATE
    spec.count_em(5); spec.wait_count()
    print (mac.specdate() + ', ' + 
             str(ep.caget('1id:userCalc9.VAL')) + ', ' +
             str(ep.caget('1id:scaler1.S3')) + ', ' +
             str(ep.caget('1id:scaler1.S5')) + ', ' +
             str(ep.caget('1id:scaler1.T')))
    fo = open(pfname, 'a')
    fo.write(mac.specdate() + ', ' + 
             str(ep.caget('1id:userCalc9.VAL')) + ', ' +
             str(ep.caget('1id:scaler1.S3')) + ', ' +
             str(ep.caget('1id:scaler1.S5')) + ', ' +
             str(ep.caget('1id:scaler1.T')) + '\n')
    fo.close()

    # MOVE FOIL OUT
    spec.umv('foilB', 0)
    return