def get_epicsPV(channel): try: from CaChannel import * from epicsMotor import * from epicsPV import * import time import string except: try: sys.path.insert(0, os.path.expandvars("$SLSBASE/sls/lib/python22/CaChannel")) sys.path.insert(0, os.path.expandvars("/exchange/share/mXAS/pyth/mod")) from CaChannel import * from epicsPV import * except: os.system ("xkbbell") os.system ("xmessage -nearmouse -timeout 30 \ -buttons \"\" \"epicsPV or CaChannel module cannot be found\"") sys.exit(1) # endtry # endtry n_tries=0 tt=0 b=-1 while tt==0: try: #print ' try reading channel' ,channel,'Tr Nr ',tt b=epicsPV(channel).getw() tt=1 except: print ' \n ' print 'trouble reading epics PV..',channel,' try again ' print ' \n ' n_tries=n_tries+1 tt=0 time.sleep(.25) if n_tries==20: tt=1 print 'give up after 20 trying reading channel ' sys.exit("*** Program STOP ***") #endif #endtry #endwhile return b def error_stop(info_line): import time print ' --------------------------------------------- ' print ' ' print ' EMERGENCY STOP ' print ' ' print info_line print ' ' print ' ' print ' ' print ' ' print ' ' print ' script stops in 30 sec ' print ' ' print ' ' print ' Window can be closed or closes automatically' print ' --------------------------------------------- ' time.sleep(30) stop # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ def get_channels(scan_type): # # This routine reads the epics chanels and stores the inout data into the correct # variables in the python script epics chanels to be defined later. # detectors, e_active,e_i,E_f,Delta_e, p_active,Scanx, Scany, Theta, Trx, TRZ ): # # Author T.Huthwelker October 2011 # # # INPUT scan_type defines the type of scan. # needs to be defined in the scan # currently we have # # 'IMAGE' (for imaging) X_X07MB_regions.py # # 'SPECTRA' spectra, all data sets into one single data file (file X_X07MB_XAS_points.py) # # 'SPETRA_QUEUE' spectra, but each spectrum into a singl data file # # currently only used to check for consistencies of data input. # On long term, we can minimize the number of chanles to be read #import os ##os.system ("ls -altr") #try: # from CaChannel import * # from epicsMotor import * # from epicsPV import * # import time # import string #except: # try: # sys.path.insert(0, os.path.expandvars("$SLSBASE/sls/lib/python22/CaChannel")) # sys.path.insert(0, os.path.expandvars("/exchange/share/mXAS/pyth/mod")) # from CaChannel import * # from epicsPV import * # except: # os.system ("xkbbell") # os.system ("xmessage -nearmouse -timeout 30 \ # -buttons \"\" \"epicsPV or CaChannel module cannot be found\"") # sys.exit(1) # # endtry # endtry beamline='X07MB' filename = get_epicsPV(beamline+'-PC-PSCAN:FdaFname') # .... remove all blanks from filenam filename=filename.replace(' ', '') # ......... define general Channels.... # ........ define scan type #scan_type=['XAS_several_points'] # options are # 'XAS_several_points' : several XAS spectra # at different points # 'E_Image' : image for a given (or several energies) n_roi_for_xas = int(get_epicsPV(beamline+'-PC-PSCAN:FdaXasRoi')) # this is the roi we are choosing # for taking the XAS spectrum (starts at 0) XMAP_save_only_xas_roi = int(get_epicsPV(beamline+'-PC-PSCAN:FdaSRoi')) # if 1 we store ony roi choosen for XAS, # other wise store all rois defined. XMAP_save_spectra = int(get_epicsPV(beamline+'-PC-PSCAN:FdaSSpec')) # flag whether we store fluo spectra or not. # ........... number of scans number_of_executions = int(get_epicsPV(beamline+'-PC-PSCAN:FdaNexec')) # number of repetitions in scan # ............ read detectors.... # create a list of detetectors used in experiment detectors=['no_Detector'] # define list of detectors by creating dumma if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_ES1_SD1')): detectors.append('MOENCH') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_PS1_CAM1')): detectors.append('PS1_CAM1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:USE_PS2_CAM1')): detectors.append('PS1_CAM2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:VORT_XM')): detectors.append('Vortex') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:ROENT_XM')): detectors.append('ROENTEC_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KETEK_XM')): # Add KETK as option. This detector uses only Channel 2 of 4 XMAP Channels detectors.append('KETEK_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH1')): detectors.append('KEITHLEY1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH2')): detectors.append('KEITHLEY2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:KEITH3')): detectors.append('KEITHLEY3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:BL_PRESS')): detectors.append('BL_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:BL_TEMP')): detectors.append('BL_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:ES1_PRESS')): detectors.append('ES1_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:MO_ENC')): detectors.append('MONO_ENC') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:MO_TEMP')): detectors.append('MONO_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM3')): detectors.append('XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM4')): detectors.append('XBPM4') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:XBPM3')): detectors.append('XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:CAM1_POS')): detectors.append('CAM1_POS') #endif print get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET') if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET')): print 'gggggggg' detectors.append('USER_DET') #endif #print detectors if len(detectors) == 1: error_stop('!!!!!!!!!!! no detector choosen') # endif # create a list of plots to be choosen detectors_to_plot=['no_Plot'] # define list of detectors by creating dumma if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_VORT_XM')): detectors_to_plot.append('PL_Vortex') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_ROENT_XM')): detectors_to_plot.append('PL_ROENTEC_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KETEK_XM')): detectors_to_plot.append('PL_KETEK_XMAP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH1')): detectors_to_plot.append('PL_KEITHLEY1') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH2')): detectors_to_plot.append('PL_KEITHLEY2') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_KEITH3')): detectors_to_plot.append('PL_KEITHLEY3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_BL_PRESS')): detectors_to_plot.append('PL_BL_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_BL_TEMP')): detectors_to_plot.append('PL_BL_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_ES1_PRESS')): detectors_to_plot.append('PL_ES1_PRESS') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_MO_ENC')): detectors_to_plot.append('PL_MONO_ENC') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_MO_TEMP')): detectors_to_plot.append('PL_MONO_TEMP') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_XBPM3')): detectors_to_plot.append('PL_XBPM3') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_XBPM4')): detectors_to_plot.append('PL_XBPM4') #endif if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_CAM1_POS')): detectors_to_plot.append('PL_CAM1_POS') if 1==int(get_epicsPV(beamline+'-PC-PSCAN:PL_USER_DET')): detectors_to_plot.append('PL_USER_DET') # GET NAMING CONVENTION FOR FDA # if channel X07MB-PC-PSCAN:FdaNConv = 1 get names from XMAP rois # other wise use standard definition det_i_roi_j if get_epicsPV(beamline+'-PC-PSCAN:FdaNConv') == 1: XMAP_name_convention= 'ROI' # if ROI is choosen, the column name in data file is the else: XMAP_name_convention= ' ' # endelse #... if XMAP is used determine the number of ROIS chosen: if ('Vortex' in detectors) and ('ROENTEC_XMAP' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif if ('Vortex' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif if ('ROENTEC_XMAP' in detectors) and ('KETEK_XMAP' in detectors): error_stop('!!!!!!!!!!! ERROR CANNOT USE BOTH VORTEX AND ROENTEC WITH XMAP ') # endif n_roi=-1 # set to -1 as not yet defined, will be reset if XMAP is used, otherwise -1 means error n_det_fluo = -1 # set to -1 as not yet defined, will be reset if XMAP is used, otherwise -1 means error Id_XMAP_roi_by_name=-1 d_list_fluo =[-1] # changed 10.10. Need to give initial definition for d_list_fluo, # as it will remain undefined of no Fluo detector is used. # Define channel 0 as number for unused channel' XMAP_roi_numbers =-1 if ('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors) or ('KETEK_XMAP' in detectors): if ('Vortex' in detectors): n_det_fluo = 4 # do script for 4 detectors (VORTEX) d_list_fluo =[1,2,3,4] # endif if ('ROENTEC_XMAP' in detectors): n_det_fluo = 1 # do script for 1 detector (ROENTEC ) d_list_fluo =[1] # roentek by default in XMAP Channel # 1 # endif if ('KETEK_XMAP' in detectors): n_det_fluo = 1 # do script for 1 detector (Ketek ) d_list_fluo =[2] # Ketek by default in XMAP channel # 2 # endif print 'analyse XMAP ' # case 1 roentec and vortex, use ROI's as defined for detector 1 if ('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors): print 'vortex assuming that rois defined for detector 1 are equal for all detectors...' n_roi=0 for i1 in range(31): this_name=get_epicsPV(beamline+'-XMAP:mca1.R'+str(i1)+'NM') # note that this assumes that the # same roi name is choosen for all four spectra. # XMAP allow different labels for each roi and each detector. # ..... remove blanks from string box='' for i2 in range(len(this_name.split())): box=box+this_name.split()[i2] # endfor if box <> '': n_roi=n_roi+1 if n_roi ==1: Id_XMAP_roi_by_name=[box] XMAP_roi_numbers=[i1] else: Id_XMAP_roi_by_name.append(box) XMAP_roi_numbers.append(i1) # endelse # endif # endfor # endif # case 2 Ketek, which is by defalut defined on channel 2 if ('KETEK_XMAP' in detectors): print 'KETEC assuming that channel 2 is used in XMAP ' n_roi=0 for i1 in range(31): this_name=get_epicsPV(beamline+'-XMAP:mca2.R'+str(i1)+'NM') # note that this assumes that the # same roi name is choosen for all four spectra. # XMAP allow different labels for each roi and each detector. # ..... remove blanks from string box='' for i2 in range(len(this_name.split())): box=box+this_name.split()[i2] # endfor if box <> '': n_roi=n_roi+1 if n_roi ==1: Id_XMAP_roi_by_name=[box] XMAP_roi_numbers=[i1] else: Id_XMAP_roi_by_name.append(box) XMAP_roi_numbers.append(i1) # endelse # endif # endfor # endif print n_roi if n_roi == 0 : error_stop('! NO ROI DEFINED IN XMAP (GOTO Phoenix user panel --> CHOOSE SDD/FLUO and ADD ROI ') #endif if n_roi_for_xas > n_roi: print 'stop inconsistent input ' print ' value for n_roi_for_xas is larger that maximum value of defines roi' print Id_XMAP_roi_by_name print ' Use name convention: ',XMAP_name_convention #endif #endif print Id_XMAP_roi_by_name # finally define variable which contains the roi used fro XAs in the list of rois we use n_roi_for_xas_index=n_roi_for_xas # now, for case use onlz XAS roi, create the subset from ID_XMAP # default is to store all ROI to data files. Now treat case where we need a data subset n_roi_for_xas_index=n_roi_for_xas print Id_XMAP_roi_by_name if XMAP_save_only_xas_roi == 1: # create list for headers for subset Id_XMAP_roi_by_name=[Id_XMAP_roi_by_name[n_roi_for_xas]] # create list with indices for roi chosen. by this prepare solution to make a list of rois to store XMAP_roi_numbers=[n_roi_for_xas] # set n_roi to 1 as we now consider only one region of interest n_roi_for_xas_index=0 n_roi=1 # ............... now store the 21 possible regions for the energy scans # once chanels are defined create array with chanle names and go through loop n_e = 21 # start with maximun, reset number later ch_e_base=beamline+'-PC-PSCAN:E-' # faster code reads only active channels..... i_0=0 if ('SPECTRA' == scan_type) or ('SPECTRA_QUEUE' == scan_type) or ('STACK' == scan_type): # read parameter only if a spectrum is to be taken for i in range(n_e): print 'read energy points'+str(i) this_active = get_epicsPV(ch_e_base+'ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : print ' first region active' e_active = [this_active] # must be one or zero e_i = [get_epicsPV(ch_e_base+'I'+str(i))] e_f = [get_epicsPV(ch_e_base+'F'+str(i))] e_delta = [get_epicsPV(ch_e_base+'D'+str(i))] e_n_cycles = [int(get_epicsPV(ch_e_base+'NCY'+str(i)))] i_0=i_0+1 else: if ( this_active== 1): e_active.append(this_active) # must be one or zero e_i.append(get_epicsPV(ch_e_base+'I'+str(i))) e_f.append(get_epicsPV(ch_e_base+'F'+str(i))) e_delta.append(get_epicsPV(ch_e_base+'D'+str(i))) e_n_cycles.append(int(get_epicsPV(ch_e_base+'NCY'+str(i)))) i_0=i_0+1 # endif # endelse if i_0 == 0 : box='!choose at least one ENERGY range with constant energy' box2=box+'spacing for taking SPECTRA (Menue XAS SCANS)' #error stop as no energy is defined for energy scan error_stop(box2) #error stop as no energy is defined for energy scan # endif else: # case data set is not a spectrum assign dummy values e_active = ['undefined'] e_i = ['undefined'] e_f = ['undefined'] e_delta = ['undefined'] e_n_cycles = ['undefined'] i_0 = 0 # endelse print e_f,e_i,i_0 # now READ POSITIONER FOR exafs DATA.. n_e = i_0 # reset n_e to number of real data points ch_ex_base=beamline+'-PC-PSCAN:EX-' e_ex_E_edge = [get_epicsPV(ch_ex_base+'E-EDGE')] # do not check whether i_0 is zero, program assumes that at least # on range with constant range is chosen. n_exafs=2 # currently allow for 2 region i_0 = 0 e_ex_active=[-1] # set to -1. If there is no active region for EXAFS scans, e_ex_active = -1 print n_exafs for i in range(n_exafs): this_active = get_epicsPV(ch_ex_base+'ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : e_ex_active = [this_active] # must be one or zero e_ex_e_i = [get_epicsPV(ch_ex_base+'E-I'+str(i)) ] e_ex_e_f = [get_epicsPV(ch_ex_base+'E-F'+str(i)) ] e_ex_k_i = [get_epicsPV(ch_ex_base+'K-I'+str(i)) ] e_ex_k_f = [get_epicsPV(ch_ex_base+'K-F'+str(i)) ] e_ex_d_i = [get_epicsPV(ch_ex_base+'D'+str(i)) ] e_ex_ncy = [get_epicsPV(ch_ex_base+'NCY'+str(i)) ] e_ex_ncy_f = [get_epicsPV(ch_ex_base+'NCY-F'+str(i)) ] e_ex_icy = [get_epicsPV(ch_ex_base+'ICY'+str(i)) ] e_ex_nst = [get_epicsPV(ch_ex_base+'NST'+str(i)) ] e_ex_t = [get_epicsPV(ch_ex_base+'T'+str(i)) ] i_0=i_0+1 else: if ( this_active== 1): e_ex_active.append(this_active) # must be one or zero e_ex_e_i.append(get_epicsPV(ch_ex_base+'E-I'+str(i)) ) e_ex_e_f.append(get_epicsPV(ch_ex_base+'E-F'+str(i)) ) e_ex_k_i.append(get_epicsPV(ch_ex_base+'K-I'+str(i)) ) e_ex_k_f.append(get_epicsPV(ch_ex_base+'K-F'+str(i)) ) e_ex_d_i.append(get_epicsPV(ch_ex_base+'D'+str(i)) ) e_ex_ncy.append(get_epicsPV(ch_ex_base+'NCY'+str(i)) ) e_ex_ncy_f.append(get_epicsPV(ch_ex_base+'NCY-F'+str(i))) e_ex_icy.append(get_epicsPV(ch_ex_base+'ICY'+str(i))) e_ex_nst.append(get_epicsPV(ch_ex_base+'NST'+str(i))) e_ex_t.append(get_epicsPV(ch_ex_base+'T'+str(i))) i_0=i_0+1 # endif # endelse # endfor n_exafs = i_0 # determine the number of EXAFS ranegs choosen. if i_0 == 0 : print 'NO EXAFS REABGE CHOOSEN ' e_ex_e_i = [-1] e_ex_e_f = [-1] e_ex_k_i = [-1] e_ex_k_f = [-1] e_ex_d_i = [-1] e_ex_ncy = [-1] e_ex_ncy_f = [-1] e_ex_icy = [-1] e_ex_nst = [-1] e_ex_t = [-1] # endif #print e_ex_e_i #print e_ex_e_f #print e_ex_k_i #print e_ex_k_f #print e_ex_d_i #print e_ex_ncy #print e_ex_ncy_f #print e_ex_nst #print e_ex_t # Now read also the parameters for the region with non equi distant energy spacing #print n_e #print e_active #print e_i #print e_f #print e_delta # ............ now store the various data point for the energy scans.... # ............ put these names into a configuration file ???? ch_p_base=beamline+'-PC-PSCAN:P-' # first read all positions for standard detectors for regions # to do read only active columns ... n_p = 21 # set first to max number of datapoints, reset later # faster code read only active chanels ........(but still all positioner, even if undefined..) i_0_tmp=0 p_label='undefined_label' for i in range(n_p): print ' read positions for point scans '+str(i)+str(n_p) this_active = int(get_epicsPV(ch_p_base+'ACT'+str(i))) # read channel with active / inactive... print i, this_active if (i_0_tmp ==0 ) and ( this_active== 1) : p_label = [get_epicsPV(ch_p_base+'LABEL'+str(i))] p_active = [this_active] p_0 = [get_epicsPV(ch_p_base+'P0D'+str(i))] p_1 = [get_epicsPV(ch_p_base+'P1D'+str(i))] p_2 = [get_epicsPV(ch_p_base+'P2D'+str(i))] p_3 = [get_epicsPV(ch_p_base+'P3D'+str(i))] p_4 = [get_epicsPV(ch_p_base+'P4D'+str(i))] p_5 = [get_epicsPV(ch_p_base+'P5D'+str(i))] print 'First found' i_0_tmp=i_0_tmp+1 else: if ( this_active== 1): print 'next found ' print i p_label.append(get_epicsPV(ch_p_base+'LABEL'+str(i))) p_active.append(this_active) p_0.append(get_epicsPV(ch_p_base+'P0D'+str(i))) p_1.append(get_epicsPV(ch_p_base+'P1D'+str(i))) p_2.append(get_epicsPV(ch_p_base+'P2D'+str(i))) p_3.append(get_epicsPV(ch_p_base+'P3D'+str(i))) p_4.append(get_epicsPV(ch_p_base+'P4D'+str(i))) p_5.append(get_epicsPV(ch_p_base+'P5D'+str(i))) i_0_tmp=i_0_tmp+1 #endif #endif if i_0_tmp == 0 : print 'error stop removed' #error_stop('!!!!! INCONSISTENT INPUT: choose at least one POSITION # for SPECTRA (MENUE XAS SCANS)') # create mark in positioner variables that no position has been chosen p_0='no pos' p_1='no pos' p_2='no pos' p_3='no pos' p_4='no pos' p_5='no pos' # set count of data points to 1, this is the case where we take a spectrum # at all current positioners without moving the positioner i_0_tmp = 1 # endif print p_label n_p = i_0_tmp # reset n_p to real number of data points print n_p # put all data into one full list p_data_full=[[p_0],[p_1],[p_2],[p_3],[p_4],[p_5]] #print i_0_tmp # ........... done reading all positions for standard positioner ... # .... get epics chanels of defau;lt positioner (set value) print ' read actuators' # CHANNEL NEEDED .rbv is as default in channel.remove .rbv and create .val for p_channel_full here # case 1 extension of ch0 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN0') ch1 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN1') ch2 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN2') ch3 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN3') ch4 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN4') ch5 = get_epicsPV(beamline+'-PC-PSCAN:POS-CHN5') [ch0_rbv,ch0_val] = create_rbv_val(ch0) [ch1_rbv,ch1_val] = create_rbv_val(ch1) [ch2_rbv,ch2_val] = create_rbv_val(ch2) [ch3_rbv,ch3_val] = create_rbv_val(ch3) [ch4_rbv,ch4_val] = create_rbv_val(ch4) [ch5_rbv,ch5_val] = create_rbv_val(ch5) p_channel_full = [ch0_val,ch1_val,ch2_val,ch3_val,ch4_val,ch5_val] print ' read actuator rbv ' # .... get epics chanels of default positioner (rbv value) p_channel_rbv_full = [ch0_rbv,ch1_rbv,ch2_rbv,ch3_rbv,ch4_rbv,ch5_rbv] #print p_channel_full #print p_channel_rbv_full # names for identifier for 6 default positioner in point scans..) print ' read actuator FDA ID ' p_id_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID0'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID1'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID2'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID3'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID4'), get_epicsPV(beamline+'-PC-PSCAN:POS-FDAID5') ] # read done channels for positioner p_done_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-RBC0'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC1'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC2'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC3'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC4'), get_epicsPV(beamline+'-PC-PSCAN:POS-RBC5') ] #print p_done_full # read on / off for done mode done channels for positioner p_done_switch_full = [get_epicsPV(beamline+'-PC-PSCAN:POS-DN0-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN1-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN2-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN3-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN4-ACT'), get_epicsPV(beamline+'-PC-PSCAN:POS-DN5-ACT') ] #print p_done_switch_full # ................................... read additional predefined user detectors i_tmp=0 CH_User_detector = ['noUserDetector'] User_detector_fda_id = ['noUserDetector'] for i in range(10): User_detector_box = get_epicsPV(beamline+'-PC-PSCAN:UDET'+str(i)) User_detector_fda_id_box = get_epicsPV(beamline+'-PC-PSCAN:UDET'+str(i)+'-FDAID') if (remove_blanks_from_str(User_detector_box) <> '') : if i_tmp == 0 : CH_User_detector = [remove_blanks_from_str(User_detector_box)] if User_detector_box <> '': User_detector_fda_id = [remove_blanks_from_str(User_detector_fda_id_box)] else: User_detector_fda_id = ['User_det_'+str(i)] #endelse i_tmp = i_tmp + 1 else: CH_User_detector.append(remove_blanks_from_str(User_detector_box)) User_detector_fda_id.append(remove_blanks_from_str(User_detector_fda_id_box)) # endelse # endif # endfor print CH_User_detector print User_detector_fda_id # get the active detectors now... p_positioner_active=[0,0,0,0,0,0] # variable which of the default positioner is active p_positioner_active[0] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT0')) # Default scanx p_positioner_active[1] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT1')) # Default scany p_positioner_active[2] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT2')) # Default ROT p_positioner_active[3] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT3')) # Default TRX p_positioner_active[4] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT4')) # Default TRZ p_positioner_active[5] = int(get_epicsPV(beamline+'-PC-PSCAN:POS-ACT5')) # Default DETECTOR print p_positioner_active # stop # create array with Id values and EPICS channels for fda... p_data_full=[p_0,p_1,p_2,p_3,p_4,p_5] if sum(p_positioner_active) == 0 : # case I no positioner defined p_channel=[' '] p_channel_rbv=[' '] p_id =[' '] p_data =[' '] p_done =[' '] p_done_switch =[' '] else: # case II no positioner are defined i_0_tmp=0 for i in range(len(p_positioner_active)): #print i_0_tmp #print i if (i_0_tmp == 0) and (p_positioner_active[i] == 1 ): p_channel=[p_channel_full[i]] p_channel_rbv= [p_channel_rbv_full[i]] p_id = [p_id_full[i]] p_data = [p_data_full[i]] p_done = [p_done_full[i]] p_done_switch =[p_done_switch_full[i]] i_0_tmp =i_0_tmp+1 else: if (p_positioner_active[i] == 1 ): p_channel.append(p_channel_full[i]) p_channel_rbv.append(p_channel_rbv_full[i]) p_id.append(p_id_full[i]) p_data.append(p_data_full[i]) p_done.append(p_done_full[i]) p_done_switch.append(p_done_switch_full[i]) i_0_tmp =i_0_tmp+1 #endif #endelse #endfor #endelse #print 'i_0_tmp' #print i_0_tmp #print 'p_data' #print p_data #print p_done #print p_done_switch # now after we have stored all positions (including the non-active data sets...) into the matrices # we create an array containing the complete data set...(Positioner ID and positions data) # #print 'p_positioner_active' #print p_positioner_active #print 'p0' #print p_0 #print 'p_id' #print p_id # .................... done creation of full array for all positions... # now connect the data to one variable with dictionary # ----------------------------------------------------------------- # # ............set up data for image regions ....... # # ------------------------------------------------------------------ # ........... first the energies (currently as a few fixed energy values, # we can think about stacks as well later ch_r_base=beamline+'-PC-PSCAN:R' r_n_e = 20 # start with max number of data points i_0=0 for i in range(r_n_e): print 'read energies for regions'+str(i) #print ch_r_base+'-EACT'+str(i) this_active = get_epicsPV(ch_r_base+'-EACT'+str(i)) #print 'this_active' #xprint this_active if (i_0 ==0 ) and ( this_active== 1) : r_energies_active = [this_active] time.sleep(0.05) r_energies = [(get_epicsPV(ch_r_base+'-E'+str(i)))] time.sleep(0.05) r_energy_cycles = [int(get_epicsPV(ch_r_base+'-E-NCY'+str(i)))] i_0 = i_0 + 1 #print 'first found ' else: if (this_active == 1): #print 'next found ' r_energies_active.append(1) time.sleep(0.05) r_energies.append( (get_epicsPV(ch_r_base+ '-E' +str(i)))) time.sleep(0.05) r_energy_cycles.append( int(get_epicsPV(ch_r_base+ '-E-NCY' +str(i)))) i_0 = i_0 + 1 #print 'energies',r_energies #endif #endelse # endfor # ___________ stop, if there are no energies chosen..... if i_0 == 0 : # error_stop('!!!!! INCONSISTENT INPUT: choose at least one ENERGY for taking images') # in case there no energy is chosen, work with current status of the beamline r_energies = 'undefined' r_energy_cycles = 'undefined' r_energies_active = 'undefined' #endif r_n_e=i_0 # reset r_n_e print r_energies print r_energy_cycles # ....................................... finally the image coordinates n_r = 21 # maximum 10 images at current # allow for scanx, scany and detector for now. Default for taking 2-D images # this is by default in actuator 0,1, and 5. (ScanX, ScanY and Detector) # the following code is historically grown and extremly unnice # detector movement prepared, but not implemented yet in IOC # TO DO REMOVE DETECTOR AS THIS IS USELESS:.. r_indices=[p_id_full[0] ,p_id_full[1] ,p_id_full[5] ] r_channel = { p_id_full[0] : p_channel_full[0] ,p_id_full[1] : p_channel_full[1] ,p_id_full[5] :p_channel_full[5] } r_channel_rbv = { p_id_full[0] : p_channel_rbv_full[0] ,p_id_full[1] : p_channel_rbv_full[1] ,p_id_full[5] : p_channel_rbv_full[5]} r_id = { p_id_full[0] : p_id_full[0] ,p_id_full[1] : p_id_full[1] ,p_id_full[5] : p_id_full[5]} r_done = {p_id_full[0] : p_done_full[0] ,p_id_full[1] : p_done_full[1] ,p_id_full[5] : p_done_full[5] } r_done_switch = {p_id_full[0] : p_done_switch_full[0] ,p_id_full[1] : p_done_switch_full[1] ,p_id_full[5] : p_done_switch_full[5] } #print r_channel # faster code , reads only active chanels i_0 = 0 for i in range(n_r): print 'read region'+str(i) this_active = get_epicsPV(ch_r_base+'-ACT'+str(i)) if (i_0 ==0 ) and ( this_active== 1) : #print ' first region active' r_active = [this_active] time.sleep(0.05) r_ll_x = [get_epicsPV(ch_r_base+'-XLL'+str(i))] time.sleep(0.05) r_ll_y = [get_epicsPV(ch_r_base+'-YLL'+str(i))] time.sleep(0.05) r_ur_x = [get_epicsPV(ch_r_base+'-XUR'+str(i))] time.sleep(0.05) r_ur_y = [get_epicsPV(ch_r_base+'-YUR'+str(i))] time.sleep(0.05) r_delta_x = [get_epicsPV(ch_r_base+'-DX'+str(i))] time.sleep(0.05) r_delta_y = [get_epicsPV(ch_r_base+'-DY'+str(i))] r_num = [i+1] # runing number for region to generate the numbering of filename i_0=i_0+1 else: if ( this_active== 1): #print 'next found ' r_active.append( this_active) r_ll_x.append( get_epicsPV(ch_r_base+'-XLL'+str(i))) time.sleep(0.05) r_ll_y.append( get_epicsPV(ch_r_base+'-YLL'+str(i))) time.sleep(0.05) r_ur_x.append( get_epicsPV(ch_r_base+'-XUR'+str(i))) time.sleep(0.05) r_ur_y.append( get_epicsPV(ch_r_base+'-YUR'+str(i))) time.sleep(0.05) r_delta_x.append( get_epicsPV(ch_r_base+'-DX'+str(i))) time.sleep(0.05) r_delta_y.append( get_epicsPV(ch_r_base+'-DY'+str(i))) r_num.append(i+1) # endif #endelse if (i_0 == 0 ): error_stop('!!!!! INCONSISTENT INPUT: choose at least one REGION for taking images') # endif n_r=i_0 # reset number of data points # ..... configure general preactions (configure at end, # ..... as preaction in later version wil be derived from general input. # This is the case if KEthley and Vortex are used add distinction for case w/o keithley # ... preactions for DAQ with XMAP ................ # First check whether we need XMAP Actions: if (('Vortex' in detectors) or ('ROENTEC_XMAP' in detectors) or ('KETEK_XMAP' in detectors) ): DAQ_XMAP = 1 else: DAQ_XMAP = 0 # endif_else preaction_1={'channel' : 'X07MB-OP2:START-CSMPL','value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_2={'channel' : 'X07MB-XMAP:StopAll' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # set to mca spectac mode (later add option for OTF mapping) preaction_2a={'channel' : 'X07MB-XMAP:CollectMode' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # force application of collection mode setting. preaction_2b={'channel' : 'X07MB-XMAP:Apply' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_3={'channel' : 'X07MB-XMAP:PresetReal' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_4={'channel' : 'X07MB-OP2:TOTAL-CYCLES' ,'value' : '2' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} # 7.5.2018 press once start sampling to allow system to reset delay = 0.7 sec to maske sure # that there is sufficient time to count up once for 2 cycles. This is a backup # to ensure that the trigger EPIC setup does not hand when the system starts preaction_4a={'channel' : 'X07MB-OP2:SMPL' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.7'} preaction_5={'channel' : 'X07MB-ES1-PP2:VO5' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.01'} # preaction: open local shutter automatically preaction_6={'channel' : 'X07MB-OP-WV1:WT_SET' ,'value' : '1' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_Moench_1={'channel' : 'X07MB-ES1-SD1:cam1:FileNumber' ,'value' : '0' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} #Moench 2 and 3 DO NOT WORK WOTH FDA FDA CANNOT WRITE A STRING preaction_Moench_2={'channel' : 'X07MB-ES1-SD1:cam1:FilePath' ,'value' : '/tmp' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_Moench_3={'channel' : 'X07MB-ES1-SD1:cam1:FileName' ,'value' : 'moench_' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.05'} preaction_MO_ID_Off={'channel' : 'X07MB-OP-MO:E-SET.OUT' ,'value' : ' ' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.2'} preaction_MO_ID_on={'channel' : 'X07MB-OP-MO:E-SET.OUT' ,'value' : 'X07MA-ID:ENERGY NPP NMS' ,'operation' : 'put' ,'type' : 'String' ,'delay' : '0.2'} # general case ... if DAQ_XMAP == 1: # IDCOUPLING preactions=[preaction_1 ,preaction_2 ,preaction_2a ,preaction_2b ,preaction_3 ,preaction_4 ,preaction_4a # ,preaction_5 # 4.10 take light out tmp # ,preaction_MO_ID_Off # ,preaction_MO_ID_on ] # endif DAQ_XMAP = 1 # case no XMAP in data aquisition if DAQ_XMAP == 0: preactions=[preaction_1,preaction_4,preaction_4a] # endif DAQ_XMAP = 0 # add shutter auto opening if chosen if get_epicsPV('X07MB-PC-PSCAN:MBWV1_OPEN') == 1: preactions.append(preaction_6) # endif # NOw add ccd detectort id needed # Case 1 Moenche deetctor if 'MOENCH' in detectors: print(' no Moench preaction for now...') preactions.append(preaction_Moench_1) #preactions.append(preaction_Moench_2) THESE DO NOT WORK WOTH FDA FDA CANNOT WRITE A STRING #preactions.append(preaction_Moench_3) #endif # ... preactions for DAQ without XMAP ................ # Define actions to be taken for each measurement detector_action_1 = { 'Channel' : 'X07MB-XMAP:EraseStart' ,'Value' : '1' ,'Operation' : 'putq' ,'Data_type' : 'String' ,'Delay' : '0.075' } detector_action_2 = { 'Channel' : 'X07MB-OP2:SMPL' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.075' } detector_action_3 = { 'Channel' : 'X07MB-OP2:SMPL-DONE' ,'Value' : '1' ,'Operation' : 'wait' ,'Data_type' : 'Integer' ,'Delay' : '0.03' } detector_action_4 = { 'Channel' : 'X07MB-XMAP:StopAll' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.05' } detector_action_moench_aquire = { 'Channel' : 'X07MB-ES1-SD1:cam1:Acquire' ,'Value' : '1' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.05' } detector_action_moench_wait = { 'Channel' : 'X07MB-ES1-SD1:cam1:Acquire' ,'Value' : '0' ,'Operation' : 'wait' ,'Data_type' : 'Integer' ,'Delay' : '0.03' } detector_action_MO_ID_Off={'Channel' : 'X07MB-OP-MO:E-SET.OUT' ,'Value' : ' ' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.1'} detector_action_MO_ID_on={'Channel' : 'X07MB-OP-MO:E-SET.OUT' ,'Value' : 'X07MA-ID:ENERGY NPP NMS' ,'Operation' : 'put' ,'Data_type' : 'String' ,'Delay' : '0.1'} # now walk through different cases if DAQ_XMAP == 1: # IDCOUPLING detector_actions=[detector_action_1 ,detector_action_2 ,detector_action_3 ,detector_action_4 # ,detector_action_MO_ID_Off # ,detector_action_MO_ID_on ] print detector_actions # endif DAQ_XMAP = 1 if DAQ_XMAP == 0: detector_actions=[detector_action_2 ,detector_action_3] print detectors if (DAQ_XMAP == 1) and ('MOENCH' in detectors): detector_actions=[detector_action_1 ,detector_action_2 ,detector_action_moench_aquire ,detector_action_3 ,detector_action_moench_wait ,detector_action_4] # establish predefined detector groups.... # group 1 beamline pressures... CH_BL_PRESS = ['X07MA-FE-CH2MP1:PRESSURE' ,'X07MB-OP-MI1MP1:PRESSURE' ,'X07MA-OP-CMMP:PRESSURE' ,'X07MA-OP-SCMP:PRESSURE' ,'X07MB-OP-IP1MP1:PRESSURE' ,'X07MB-OP-SL1MP1:PRESSURE' ,'X07MB-OP-FI1MP1:PRESSURE' ,'X07MB-OP-BM1MP1:PRESSURE' ,'X07MB-OP-IP2MP1:PRESSURE' ,'X07MB-OP-BM2MF1:PRESSURE' ,'X07MB-OP-MOMF1:PRESSURE' ] ID_BL_PRESS = ['CH2MP1' ,'MI1MP' ,'CMMP' ,'SCMP' ,'IP1MP1' ,'SL1MP1' ,'FI1MP1' ,'BM1MP1' ,'IP2MP1' ,'BM2MF1' ,'MOMF1'] # group BL temperatures temperatures... CH_BL_TEMP=['X07MB-OP-MI1:TC1' ,'X07MB-OP-MI1:TC3' ,'X07MA-OP-CMMI:TC1' ,'X07MA-OP-CMB:TC1' ,'X07MA-OP-SC:TC1' ,'X07MA-FE-SH1:TC1' ,'X07MA-FE-SH1:TC2' ,'X07MA-FE-SH1:TC3' ,'X07MA-FE-SH1:TC4' ,'X07MA-FE-SV1:TC1' ,'X07MA-FE-SV1:TC2' ,'X07MA-FE-SV1:TC3' ,'X07MA-FE-SV1:TC4' ,'X07MB-OP-SH1:TC_X1' ,'X07MB-OP-SH1:TC_X2' ,'X07MB-OP-SV1:TC_Y1' ,'X07MB-OP-SV1:TC_Y2' ] ID_BL_TEMP=['MI1TC1' ,'MI1TC3' ,'CMMITC1' ,'CMBTC1' ,'SCTC1' ,'FE_SH1TC1' ,'FE_SH1TC2' ,'FE_SH1TC3' ,'FE_SH1TC4' ,'FE_SV1TC1' ,'FE_SV1TC2' ,'FE_SV1TC3' ,'FE_SV1TC4' ,'SL1_SH1TC_X1' ,'SL1_SH1TC_X2' ,'SL1_SV1TC_Y1' ,'SL1_SV1TC_Y2' ] # DETECTOR GROUP .......... Mono temperatures CH_MONO_TEMP=['X07MB-OP-MOTHETA:TC1' ,'X07MB-OP-MOTRX:TC1' ,'X07MB-OP-MOC2:TC_Z' ,'X07MB-OP-MOC2:TC_Y'] ID_MONO_TEMP=['MONO_THETA_TC1' ,'MONO_TRX_TC1' ,'MONO_C2_TC_Z' ,'MONO_C2_TC_Y'] for i in range(16): CH_MONO_TEMP.append('X07MB-OP-MO:TC'+str(i+1)) ID_MONO_TEMP.append('MONO_TC'+str(i+1)) #endfor # ............DETECTOR GROUP MONO ENCODERS ... CH_MONO_ENC = [ 'X07MB-OP-MO:C1-EC_ROZ' , 'X07MB-OP-MO:C2-EC_ROX' , 'X07MB-OP-MO:C2-EC_ROZ' ,'X07MB-OP-MO:C1-ROZ.DRBV','X07MB-OP-MO:C2-ROX.DRBV','X07MB-OP-MO:C2-ROZ.DRBV' ,'X07MB-OP-MO:C1-ROZ.DIFF','X07MB-OP-MO:C2-ROX.DIFF','X07MB-OP-MO:C2-ROZ.DIFF' ,'X07MB-OP-MO:C1-EC_ROZ.VAL','X07MB-OP-MO:C2-EC_ROX.VAL','X07MB-OP-MO:C2-EC_ROZ.VAL' ,'X07MB-OP-MO:C2-TRZ.VAL' ,'X07MB-OP-MO:C2-TRZ.RBV' ,'X07MB-OP-MO:C2-TRZ.DIFF' ,'X07MB-OP-MO:C2-TRZ.REP' ,'X07MB-OP-MO:C2-TRY.VAL' ,'X07MB-OP-MO:C2-TRY.RBV' ,'X07MB-OP-MO:C2-TRY.DIFF' ,'X07MB-OP-MO:C2-TRY.REP' ,'X07MB-OP-MO:THETA.VAL' ,'X07MB-OP-MO:THETA.RBV' ,'X07MB-OP-MO:THETA.DIFF' ,'X07MB-OP-MO:THETA.REP'] ID_MONO_ENC = [ 'ROLL1_V' , 'PITCH2_V' , 'ROLL2_V' ,'ROLL1_MUR' , 'PITCH2_MUR' , 'ROLL2_MUR' ,'ROLL1_DIFF','PITCH2_DIFF','ROLL2_DIFF' ,'ROLL1_VOLT','PITCH2_VOLT','ROLL2_VOLT' ,'T1_VAL' ,'T1_RBV' ,'T1_DIFF' ,'T1_REP' ,'T2_VAL' ,'T2_RBV' ,'T2_DIFF' ,'T2_REP' ,'THETA_VAL' ,'THETA_RBV' ,'THETA_DIFF' ,'THETA_REP'] # .................... Detector group Pressures endstation ............................. CH_ES1_PRESS=['X07MB-ES1-MF1:PRESSURE' ,'X07MB-ES1-MC1:PRESSURE' ,'X07MB-OP-KBMF1:PRESSURE' ,'X07MB-OP-SL2MF1:PRESSURE' ] ID_ES1_PRESS=['ES1MF1' ,'ES1MC1' ,'OPKBMF1' ,'OPSL2MF1' ] # .................... Detector group XBPM and microscope missing ............................. # ........................................... XBPM 3 CH_XBPM4=['X07MB-OP2-SAI_19:CUR-MEAN' ,'X07MB-OP2-SAI_20:CUR-MEAN' ,'X07MB-OP2-SAI_21:CUR-MEAN' ,'X07MB-OP2-SAI_22:CUR-MEAN'] ID_XBPM4=['XBPM4_SAI19_CUR_MEAN' ,'XBPM4_SAI20_CUR_MEAN' ,'XBPM4_SAI21_CUR_MEAN' ,'XBPM4_SAI22_CUR_MEAN'] CH_XBPM4_POS=['X07MB-OP-BPM4:POSX' ,'X07MB-OP-BPM4:POSY'] ID_XBPM4_POS=['XBPM4_POSX' ,'XBPM4_POSY'] # ........................................... XBPM 4 CH_XBPM3=['X07MB-OP2-SAI_14:CUR-MEAN' ,'X07MB-OP2-SAI_15:CUR-MEAN' ,'X07MB-OP2-SAI_16:CUR-MEAN' ,'X07MB-OP2-SAI_17:CUR-MEAN'] ID_XBPM3=['XBPM3_SAI14_CUR_MEAN' ,'XBPM3_SAI15_CUR_MEAN' ,'XBPM3_SAI16_CUR_MEAN' ,'XBPM3_SAI17_CUR_MEAN'] CH_XBPM3_POS=['X07MB-OP-BPM3:POSX' ,'X07MB-OP-BPM3:POSY'] ID_XBPM3_POS=['XBPM3_POSX' ,'XBPM3_POSY'] # ........................................... XBPM 3 CH_CAM1_POS=['X07MB-PS1:Stats1:CentroidX_RBV' ,'X07MB-PS1:Stats1:CentroidY_RBV' ,'X07MB-PS1:Stats1:SigmaX_RBV' ,'X07MB-PS1:Stats1:SigmaY_RBV' ,'X07MB-PS1:Stats1:SigmaXY_RBV' ] ID_CAM1_POS=['CentroidX_RBV' ,'CentroidY_RBV' ,'SigmaX_RBV' ,'SigmaY_RBV' ,'SigmaXY_RBV' ] # read channel and initial values for ch_ini_base=beamline+'-PC-PSCAN:' N_initial=6 # for now limit to 5 initial channels i_0 = 0 for i in range(N_initial): print 'read initial value ' + str(i) #print ch_ini_base+'ChInit'+str(i)+'-ACT' this_active = get_epicsPV(ch_ini_base+'ChInit'+str(i)+'-ACT') time.sleep(0.05) #print this_active if (i_0 ==0 ) and ( this_active== 1) : #print ' first region active' CH_INITIAL = [get_epicsPV(ch_ini_base+'ChInit'+str(i))] time.sleep(0.05) CH_INITIAL_V = [get_epicsPV(ch_ini_base+'VChInit'+str(i))] time.sleep(0.05) i_0=i_0+1 else: if ( this_active== 1): #print 'next found ' time.sleep(0.05) CH_INITIAL.append(get_epicsPV(ch_ini_base+'ChInit'+str(i))) time.sleep(0.05) CH_INITIAL_V.append(get_epicsPV(ch_ini_base+'VChInit'+str(i))) # endif # endelse # endfor if (i_0 == 0 ): CH_INITIAL = ['NO_INITIAL_VALUES'] CH_INITIAL_V = [0] #print CH_INITIAL #print CH_INITIAL_V # ________________ finally do consistency checks on the input data # CASE 1 emergengy stop if number of choosen roi is larger that the number of available rois if ((n_roi_for_xas >= n_roi) and (n_roi <> -1) and (n_roi_for_xas <> -1)) and (XMAP_save_only_xas_roi <> 1 ) : # if values are negative, XMAP is not used.. error_stop('!!!!! INCONSISTENT INPUT: Number of Roi for XAS larger than choosen roi !!!') # endif # CASE 2 emergengy stop if there are no active regions # finally collect all read data into one structure, which completely defines the scan. # This structure is returned as result of thie routine. # All all readouts of this structure are adressed by the structure names, and never by indices, # the structure can be extendened in a very general way # on the longterm one could envision that the python routine just monitors all chanels, and # creates a regular update... this would avoid the -time consuming- rereading of all # chanels for every creation # of the measurements scripts. box={ 'filename' : filename , 'beamline' : beamline , 'preactions' : preactions , 'detector_actions' : detector_actions , 'scan_type' : scan_type , 'n_roi_for_xas' : n_roi_for_xas , 'n_roi_for_xas_index' : n_roi_for_xas_index , 'n_roi' : n_roi , 'n_det_fluo' : n_det_fluo , 'd_list_fluo' : d_list_fluo , 'Id_XMAP_roi_by_name' : Id_XMAP_roi_by_name , 'XMAP_roi_numbers' : XMAP_roi_numbers , 'XMAP_name_convention' : XMAP_name_convention , 'XMAP_save_only_xas_roi' : XMAP_save_only_xas_roi , 'XMAP_save_spectra' : XMAP_save_spectra , 'number_of_executions' : number_of_executions , 'detectors' : detectors , 'detectors_to_plot' : detectors_to_plot , 'n_e' : n_e , 'e_active' : e_active , 'e_i' : e_i , 'e_f' : e_f , 'e_delta' : e_delta , 'e_n_cycles' : e_n_cycles , 'n_exafs' : n_exafs , 'e_ex_E_edge' : e_ex_E_edge , 'e_ex_active' : e_ex_active , 'e_ex_e_i' : e_ex_e_i , 'e_ex_e_f' : e_ex_e_f , 'e_ex_k_i' : e_ex_k_i , 'e_ex_k_f' : e_ex_k_f , 'e_ex_d_i' : e_ex_d_i , 'e_ex_ncy' : e_ex_ncy , 'e_ex_ncy_f' : e_ex_ncy_f , 'e_ex_icy' : e_ex_icy , 'e_ex_nst' : e_ex_nst , 'e_ex_t' : e_ex_t # , 'e_channel' : 'X07MB-OP-MO:E-SET' # PHOENIX I NEED A CHECK that we canonly run the right mono in the script! # , 'e_channel_rbv' : 'X07MB-OP-MO:E-GET' #, 'e_channel' : 'X07MA-PHS-E:GO.A' # XTREME #, 'e_channel_rbv' : 'X07MA-PGM:CERBK' , 'e_channel' : 'X07MB-OP:userCalc1.L' # test write energy in calc record , 'e_channel_rbv' : 'X07MB-OP:userCalc1.L' , 'n_p' : n_p , 'p_channel' : p_channel , 'p_channel_rbv' : p_channel_rbv , 'p_id' : p_id , 'p_positioner_active': p_positioner_active , 'p_label' : p_label , 'p_data' : p_data , 'p_done' : p_done , 'p_done_switch' : p_done_switch , 'r_energy_cycles' : r_energy_cycles , 'r_energies' : r_energies , 'r_energies_active' : r_energies_active , 'r_channel' : r_channel , 'r_channel_rbv' : r_channel_rbv , 'r_indices' : r_indices , 'r_id' : r_id , 'r_active' : r_active , 'r_ll_x' : r_ll_x , 'r_ll_y' : r_ll_y , 'r_ur_x' : r_ur_x , 'r_ur_y' : r_ur_y , 'r_delta_x' : r_delta_x , 'r_delta_y' : r_delta_y , 'r_num' : r_num , 'r_done' : r_done , 'r_done_switch' : r_done_switch , 'CH_CAM1_POS' : CH_CAM1_POS , 'ID_CAM1_POS' : ID_CAM1_POS , 'CH_BL_PRESS' : CH_BL_PRESS , 'ID_BL_PRESS' : ID_BL_PRESS , 'CH_BL_TEMP' : CH_BL_TEMP , 'ID_BL_TEMP' : ID_BL_TEMP , 'CH_MONO_TEMP' : CH_MONO_TEMP , 'ID_MONO_TEMP' : ID_MONO_TEMP , 'CH_MONO_ENC' : CH_MONO_ENC , 'ID_MONO_ENC' : ID_MONO_ENC , 'CH_ES1_PRESS' : CH_ES1_PRESS , 'ID_ES1_PRESS' : ID_ES1_PRESS , 'CH_XBPM3' : CH_XBPM3 , 'ID_XBPM3' : ID_XBPM3 , 'CH_XBPM3_POS' : CH_XBPM3_POS , 'ID_XBPM3_POS' : ID_XBPM3_POS , 'CH_XBPM4' : CH_XBPM4 , 'ID_XBPM4' : ID_XBPM4 , 'CH_XBPM4_POS' : CH_XBPM4_POS , 'ID_XBPM4_POS' : ID_XBPM4_POS , 'DAQ_XMAP' : DAQ_XMAP , 'CH_INITIAL' : CH_INITIAL , 'CH_INITIAL_V' : CH_INITIAL_V , 'CH_User_detector' : CH_User_detector , 'User_detector_fda_id' : User_detector_fda_id } print box print detectors print('preactions') print preactions return box d=get_channels('SPECTRA')