From 8c7a2907b1d723380ba87567c2714cb92301b99a Mon Sep 17 00:00:00 2001 From: "FR@29iduser" <rodolakis@anl.gov> Date: Wed, 5 Oct 2022 14:42:26 -0500 Subject: [PATCH] made scanRecord importable functions --- iexcode/instruments/AD_utilities.py | 9 +++-- iexcode/instruments/ARPES.py | 10 ++--- iexcode/instruments/FMB_mirrors.py | 3 +- iexcode/instruments/IEX_VPU.py | 5 ++- iexcode/instruments/Kappa.py | 47 +++++++++++------------- iexcode/instruments/Logfile.py | 12 +++--- iexcode/instruments/Motors.py | 11 +++--- iexcode/instruments/Octupole.py | 8 ++-- iexcode/instruments/VLS_PGM.py | 14 +++---- iexcode/instruments/electron_analyzer.py | 32 ++++++++-------- iexcode/instruments/m3r.py | 2 +- iexcode/instruments/scanRecord.py | 42 +++++++++++++++++++++ iexcode/instruments/slits.py | 10 ++--- iexcode/instruments/vortex.py | 15 ++++---- 14 files changed, 128 insertions(+), 92 deletions(-) diff --git a/iexcode/instruments/AD_utilities.py b/iexcode/instruments/AD_utilities.py index ae1f364..89ca8e7 100644 --- a/iexcode/instruments/AD_utilities.py +++ b/iexcode/instruments/AD_utilities.py @@ -16,6 +16,7 @@ from epics import caget, caput import iexcode.instruments.cfg as iex from iexcode.instruments.files_and_folders import get_next_fileNumber +from iexcode.instruments.scanRecord import mda_filepath, mda_ioc def AD_exposure_time(ADplugin,exp_time,**kwargs): """ @@ -95,7 +96,7 @@ def AD_SaveFileSetup(ADplugin,**kwargs): FileTemplate="%s%s_%4.4d."+ext; format for filename first %s = filepath, second %s = prefix """ - kwargs.setdefault("userpath",os.path.dirname(iex.BL.mda.filepath())) + kwargs.setdefault("userpath",os.path.dirname(mda_filepath())) kwargs.setdefault("subfolder",ADplugin.split(":")[-2][:-1]) kwargs.setdefault("prefix",ADplugin.split(":")[-2][:-1]) @@ -267,7 +268,7 @@ def AD_ScanTrigger(ADplugin,**kwargs): kwargs.setdefault("R","cam1:") kwargs.setdefault("detTrig",2) - scanPV=iex.BL.mda.ioc+"scan"+str(kwargs["scanDIM"]) + scanPV=mda_ioc()+"scan"+str(kwargs["scanDIM"]) trigger=".T"+str(kwargs["detTrig"])+"PV" caput(scanPV+trigger,kwargs["P"]+kwargs["R"]+"Acquire",wait=True,timeout=5*60) @@ -306,8 +307,8 @@ def ADplugin_ScanSetup(ADplugin, **kwargs): AD_SaveFileSetup(ADplugin,**kwargs) AD_ScanTrigger(ADplugin, **kwargs) - trigger=".T"+str(kwargs["detTrig"])+"PV" - scanPV=iex.BL.mda.ioc+"scan"+str(kwargs["scanDIM"]) + trigger = ".T"+str(kwargs["detTrig"])+"PV" + scanPV = mda_ioc()+"scan"+str(kwargs["scanDIM"]) print("WARNING: you need to need to disable saving and clear the trigger by hand after the scan") print("\tAD_FreeRun("+ADplugin+"); caput("+scanPV+trigger+",'')") diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index 660aef8..a27223b 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -11,7 +11,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv -from iexcode.instruments.Logfile import Logfile +from iexcode.instruments.Logfile import Logfile, log_name_set from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary @@ -85,7 +85,7 @@ def ARPES_init(*userName,**kwargs): #logging iex.BL.mda.log=Logfile('ARPES',user_name,_ARPES_log_dictionary,set_file=False) if kwargs['set_folders']: - iex.BL.mda.log.name_set() + log_name_set() #EA if EA.connected: @@ -253,8 +253,6 @@ def ARPES_default_scan_settings(): iex.BL.mda.after_scan_pv = _ARPES_scan_after_sequence() iex.BL.mda.snake_set = ARPES_snake_set #sending the function, no parenthesis - #set the logfile name - iex.BL.mda.log.name_set() def ARPES_reset(): """ @@ -498,7 +496,7 @@ def _ARPES_snake_userCalc(**kwargs): kwargs.setdefault('scan_dim',1) seq_num=kwargs['seq_num'] - scan_ioc = iex.BL.ioc + scan_ioc = mda_ioc() userCalc_clear(scan_ioc,seq_num) snake_userCalc_pv,snake_userCalc_proc = userCalcs_pvs(scan_ioc, seq_num) @@ -518,7 +516,7 @@ def ARPES_snake_set(snake,**kwargs): used for snake scanning """ kwargs.setdefault('scan_dim',1) - scan_ioc = iex.BL.mda.ioc + scan_ioc = mda_ioc() after_scan_pv,after_scan_proc = _ARPES_scan_after_pvs() scan_step_pv = scan_ioc+'scan'+str(kwargs['scan_dim'])+'.P1SI NP NMS' diff --git a/iexcode/instruments/FMB_mirrors.py b/iexcode/instruments/FMB_mirrors.py index 5af1070..a34e03d 100644 --- a/iexcode/instruments/FMB_mirrors.py +++ b/iexcode/instruments/FMB_mirrors.py @@ -4,6 +4,7 @@ from epics import caget, caput import iexcode.instruments.cfg as iex from iexcode.instruments.utilities import read_dict, print_warning_message +from iexcode.instruments.scanRecord import scan_fillin M0M1_fpath="/home/beams22/29IDUSER/Documents/User_Macros/Macros_29id/IEX_Dictionaries/Dict_IDCal.txt" @@ -136,7 +137,7 @@ def FMB_mirror_scan(mirror_num,start,stop,step): # database sets .PREC==0. We want more digits than that. caput(pv+"_SP.PREC",3) - iex.BL.mda.fillin(pv+"_SP",pv+"_MON",start,stop,step) + scan_fillin(pv+"_SP",pv+"_MON",start,stop,step) diff --git a/iexcode/instruments/IEX_VPU.py b/iexcode/instruments/IEX_VPU.py index 642e0e8..142091a 100644 --- a/iexcode/instruments/IEX_VPU.py +++ b/iexcode/instruments/IEX_VPU.py @@ -6,6 +6,7 @@ import numpy.polynomial.polynomial as poly from epics import caget, caput import iexcode.instruments.cfg as iex +from iexcode.instruments.scanRecord import scan_fillin, scan_fillin_table from iexcode.instruments.userCalcs import userCalcOut_clear from iexcode.instruments.utilities import dateandtime, print_warning_message, read_dict from iexcode.instruments.VLS_PGM import mono_grating_get @@ -533,7 +534,7 @@ def ID_scan_fillin(start,stop,step,**kwargs): """ #Setting up the ScanRecord for ID in Table mode val_pv, rbv_pv = ID_scan_pvs() - iex.BL.mda.fillin(val_pv,rbv_pv,start,stop,step,**kwargs) + scan_fillin(val_pv,rbv_pv,start,stop,step,**kwargs) def ID_scan_fillin_table(ID_array,**kwargs): @@ -544,7 +545,7 @@ def ID_scan_fillin_table(ID_array,**kwargs): """ #Setting up the ScanRecord for ID in Table mode val_pv, rbv_pv = ID_scan_pvs() - iex.BL.mda.fillin_table(val_pv,rbv_pv,ID_array,**kwargs) + scan_fillin_table(val_pv,rbv_pv,ID_array,**kwargs) ############################################################################################################## ############################## ID direction table ############################## diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index 60ef810..73bac38 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -11,7 +11,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv -from iexcode.instruments.Logfile import Logfile +from iexcode.instruments.Logfile import Logfile,log_name_set from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all @@ -91,9 +91,9 @@ def kappa_init(*userName,**kwargs): print('user_name:',user_name) #logging - iex.BL.mda.log('kappa',user_name,_kappa_log_dictionary,set_file=False) + iex.BL.mda.log=Logfile('kappa',user_name,_kappa_log_dictionary,set_file=False) if kwargs['set_folders']: - iex.BL.mda.log.name_set() + log_name_set() #MPA iex.mpa = MPA() @@ -327,9 +327,7 @@ def kappa_default_scan_settings(**kwargs): iex.BL.mda.scan_before_sequence = _kappa_scan_before_sequence() iex.BL.mda.scan_after_sequence = _kappa_scan_after_sequence() iex.BL.mda.snake_set = kappa_snake_set #sending the function, no parenthesis - - #set the logfile name - iex.BL.mda.log.name_set() + def kappa_reset(**kwargs): """ @@ -342,7 +340,7 @@ def kappa_reset(**kwargs): #resetting the scanRecord print("resetting the scanRecord - "+iex.BL.ioc) - iex.BL.mda.reset_all() + mda_reset() #resetting the MPA ROIs if kwargs['reset_MPA_ROIs']: @@ -578,7 +576,7 @@ def kappa_snake_set(snake,**kwargs): used for snake scanning """ kwargs.setdefault('scan_dim',1) - scan_ioc = iex.BL.mda.ioc + scan_ioc = mda_ioc() after_scan_pv,after_scan_proc = _kappa_scan_after_pvs() scan_step_pv = scan_ioc+'scan'+str(kwargs['scan_dim'])+'.P1SI NP NMS' @@ -757,26 +755,26 @@ def th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,**kwargs): tth_table = 2*th_table kwargs.update("positioner_num",1) - iex.BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) + scan_fillin_table(kth_val,kth_rbv,kth_table,**kwargs) kwargs.update("positioner_num",2) - iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + scan_fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",3) - iex.BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) + scan_fillin_table(gain_num_pv,"",gain_num_table,**kwargs) kwargs.update("positioner_num",4) - iex.BL.mda.fillin_table(gain_unit_pv,"",gain_unit_table,**kwargs) + scan_fillin_table(gain_unit_pv,"",gain_unit_table,**kwargs) print("\nDon't forget to clear extra positionners at the end of the scan if you were to abort the script using the function:") print(" Clear_Scan_Positioners('kappa',1)") scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) #clean up after scan - iex.BL.mda.table_reset_after(**kwargs) + scan_after_table_reset(**kwargs) scaler_cts(verbose=False) def scanth2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): @@ -806,14 +804,14 @@ def scanth2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): kwargs.update("positioner_num",2) - iex.BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) + scan_fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) kwargs.update("positioner_num",1) - iex.BL.mda.fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) + scan_fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) #clean up after scan scaler_cts(verbose=False) @@ -857,21 +855,20 @@ def scanth2th_table(tth_table,th_offset, **kwargs): tth_val,tth_rbv,tth_spmg,tth_pv = _kappa_motor_dictionary['tth'] kwargs.update("positioner_num",1) - iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + scan_fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",2) - iex.BL.mda.fillin_table(th_val,th_rbv,th_table,**kwargs) - iex.BL.mda.positioner_after_scan(after="STAY") - + scan_fillin_table(th_val,th_rbv,th_table,**kwargs) + scan_positioner_after_set(after="STAY") scaler_cts(kwargs['cts'],verbose=False,**kwargs) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) #clean up after scan - iex.BL.mda.table_reset_after() + scan_after_table_reset() scaler_cts(verbose=False) - iex.BL.mda.positioner_after_scan(after="PRIOR POS",**kwargs) + scan_positioner_after_set(after="PRIOR POS") #JM here @@ -931,7 +928,7 @@ def kappa_temperature_pressure_scan(scan_dim=1): Previously: kappa_ScanTempPres """ - pv="29id"+iex.BL.mda.ioc+":scan"+str(scan_dim) + pv=mda_ioc()+":scan"+str(scan_dim) #Clear all scan pvs caput(pv+".CMND",6) #Set detectors diff --git a/iexcode/instruments/Logfile.py b/iexcode/instruments/Logfile.py index 7f992a5..509afc2 100644 --- a/iexcode/instruments/Logfile.py +++ b/iexcode/instruments/Logfile.py @@ -26,16 +26,16 @@ def log_update(d=None,**kwargs): updates the log file with the last scan info d = dictionary of {header:[data,format]} """ - #try: - iex.BL.mda.log.update(d,**kwargs) + try: + iex.BL.mda.log.update(d,**kwargs) - #except: - # print('No logfile written') + except: + print('No logfile written') def log_name_set(file_name): try: iex.BL.mda.log.name_set(filename=file_name) - iex.BL.mda.filename = filename + iex.BL.mda.filename = file_name except: print('No logfile name change') @@ -183,7 +183,7 @@ class Logfile: header_list.append(key) data_list.append(val[0]) format_list.append(val[1]) - print(data_list) + return header_list,data_list,format_list def _intit_log(self,header_list): diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index 7174ebf..5ab6f57 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -2,8 +2,7 @@ import time from epics import caget, caput -import iexcode.instruments.cfg as iex - +from iexcode.instruments.scanRecord import * from iexcode.instruments.utilities import print_warning_message from iexcode.instruments.scalers import scaler_cts @@ -183,10 +182,10 @@ class Motors: abs_start = start abs_stop = stop - iex.BL.mda.fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) + scan_fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) def scan_2D(self,inner_loop_list,outer_loop_list,**kwargs): @@ -241,11 +240,11 @@ class Motors: outer_loop_list[2]=round(current_value1+outer_loop_list[2],3) outer_loop_list[3]=round(current_value1+outer_loop_list[3],3) - iex.BL.mda.fillin_2D(inner_loop_list,outer_loop_list,**kwargs) + scan_fillin_2D(inner_loop_list,outer_loop_list,**kwargs) if kwargs['execute']: kwargs.update({'scan_dim':kwargs['outer_scan_dim']}) - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) diff --git a/iexcode/instruments/Octupole.py b/iexcode/instruments/Octupole.py index f2383d7..6bd3837 100644 --- a/iexcode/instruments/Octupole.py +++ b/iexcode/instruments/Octupole.py @@ -10,7 +10,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv -from iexcode.instruments.Logfile import Logfile +from iexcode.instruments.Logfile import Logfile,log_name_set from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all @@ -88,7 +88,7 @@ def Octupole_init(*userName,**kwargs): #logging iex.BL.mda.log=Logfile('Octupole',user_name,_Octupole_log_dictionary) if kwargs['set_folders']: - iex.BL.mda.log.name_set() + log_name_set() #global detectors @@ -299,7 +299,7 @@ def Octupole_reset(**kwargs): """ #resetting the scanRecord print("resetting the scanRecord - "+iex.BL.ioc) - iex.BL.mda.reset_all() + mda_reset() #resetting mono and anyother beamline stuff if iex.BL.xrays: @@ -523,7 +523,7 @@ def Octupole_snake_set(snake,**kwargs): used for snake scanning """ kwargs.setdefault('scan_dim',1) - scan_ioc = iex.BL.mda.ioc + scan_ioc = mda_ioc() after_scan_pv,after_scan_proc = _Octupole_scan_after_pvs() scan_step_pv = scan_ioc+'scan'+str(kwargs['scan_dim'])+'.P1SI NP NMS' diff --git a/iexcode/instruments/VLS_PGM.py b/iexcode/instruments/VLS_PGM.py index af8bd59..0481388 100644 --- a/iexcode/instruments/VLS_PGM.py +++ b/iexcode/instruments/VLS_PGM.py @@ -525,10 +525,10 @@ def mono_scan(hv_start,hv_stop,hv_step,**kwargs): #Setting up the ScanRecord for Mono in Table mode val_pv, rbv_pv = mono_scan_pvs() - iex.BL.mda.fillin(val_pv,rbv_pv,hv_start,hv_stop,hv_step,**kwargs) + scan_fillin(val_pv,rbv_pv,hv_start,hv_stop,hv_step,**kwargs) #mono needs to stay and have a longer settling time - iex.BL.mda.positioner_after_scan("STAY") + scan_positioner_after_set(positioner_after_scan="STAY") def mono_scan_table(hv_array,**kwargs): @@ -549,17 +549,15 @@ def mono_scan_table(hv_array,**kwargs): scan_fillin_table(val_pv,rbv_pv,hv_array,**kwargs) #mono needs to stay and have a longer settling time - iex.BL.mda.positioner_settling_time_set(**kwargs) - iex.BL.mda.positioner_after_scan_set() + scan_positioner_settling_time_set(**kwargs) + scan_positioner_after_set() def mono_scan_after(**kwargs): """ resets mda after scanning the mono """ kwargs.setdefault('positioner_after_scan',"PRIOR POS") - after_scan_pv = iex.BL.mda.default_after_scan_seq() - caput(after_scan_pv+".PROC",1) - iex.BL.mda.positioner_after_scan_set(**kwargs) + scan_positioner_after_set(**kwargs) ############################################################################################################## @@ -594,7 +592,7 @@ def mono_motor_scan(motor,start,stop,step,**kwargs): val_pv,rbv_pv = mono_motor_scan_pvs(motor) caput(val_pv+".PREC",3) # database sets .PREC==0. We want more digits than that. - iex.BL.mda.fillin(val_pv,rbv_pv,start,stop,step,**kwargs) + scan_fillin(val_pv,rbv_pv,start,stop,step,**kwargs) def mono_zero_order(angle): """ diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py index 028f506..14bfa5a 100644 --- a/iexcode/instruments/electron_analyzer.py +++ b/iexcode/instruments/electron_analyzer.py @@ -171,7 +171,7 @@ def EA_log_dictionary(): 'lens_mode':[EA.LensMode,"s"], 'PE':[EA.PassEnergy,".0f"], "KE":[EA.KineticEnergy,".0f"], - "sweeps":[caget(iex.BL.mda.ioc+'scan1.NPTS'),".0f"], + "sweeps":[caget(mda_ioc()+'scan1.NPTS'),".0f"], "frames":[EA.Frames,".0f"] } return d @@ -261,9 +261,9 @@ def _scanEATrigger(EAlist,before_after,**kwargs): _scanEAPrefix(kwargs["prefix"],**kwargs) #set det trigger mda_kwargs={'scan_dim':kwargs['scan_dim'],'trigger_dictionary':{kwargs['detTrig']:''}} - iex.BL.mda.trigger_set(mda_kwargs) + scan_triggers_set(mda_kwargs) #remove scanNum as detector - iex.BL.mda.detectors_set(detector_dictionary={20:''}) + scan_detectors_set(detector_dictionary={20:''}) if kwargs["debug"]: print("mda_kwargs",mda_kwargs) @@ -288,8 +288,8 @@ def _scanEAPrefix(ptype,**kwargs): print(ptype) if ptype == "mda": - fpath = iex.BL.mda.filepath()[0:-3]+EA.dtype - nextMDA = iex.BL.mda.fileNum() + fpath = mda_filepath()[0:-3]+EA.dtype + nextMDA = mda_fileNum() prefix = "MDAscan"+str.zfill(str(nextMDA),kwargs["nzeros"]) else: prefix = ptype @@ -332,7 +332,7 @@ def scanEA_reset(**kwargs): kwargs.setdefault("scan_dim",1) _scanEATrigger([],"after",**kwargs) - iex.BL.mda.positioners_clear(kwargs["scan_dim"]) + scan_positioners_clear(kwargs["scan_dim"]) def scanEA(EAlist,**kwargs): """ @@ -416,7 +416,7 @@ def scanEA(EAlist,**kwargs): if kwargs['debug']: print("Clearing scan positioners and filling in sweeps") #Fill in Sweeps scan - iex.BL.mda.positioners_clear(**kwargs) + scan_positioners_clear(**kwargs) VAL="" RBV="" scan_fillin(VAL,RBV,1,sweeps,1,**kwargs) @@ -441,7 +441,7 @@ def scanEA(EAlist,**kwargs): #After scan EAlog_update() scanEA_reset(**kwargs) - iex.BL.mda.table_reset_after(**kwargs) + scan_after_table_reset(**kwargs) else: return EAparms @@ -468,10 +468,10 @@ def scanFM(RoughPositions,thList,EAlist,**kwargs): if kwargs['debug']: print(x,y,z,th,chi,phi) - iex.BL.mda.fillin_table(EA.Motors._motor_dictionary["th"][1],EA.Motors._motor_dictionary["th"][0],th,positioner_num=1) - iex.BL.mda.fillin_table(EA.Motors._motor_dictionary["x"][1],EA.Motors._motor_dictionary["x"][0],x,positioner_num=2) - iex.BL.mda.fillin_table(EA.Motors._motor_dictionary["y"][1],EA.Motors._motor_dictionary["y"][0],y,positioner_num=3) - iex.BL.mda.fillin_table(EA.Motors._motor_dictionary["z"][1],EA.Motors._motor_dictionary["z"][0],z,positioner_num=4) + scan_fillin_table(EA.Motors._motor_dictionary["th"][1],EA.Motors._motor_dictionary["th"][0],th,positioner_num=1) + scan_fillin_table(EA.Motors._motor_dictionary["x"][1],EA.Motors._motor_dictionary["x"][0],x,positioner_num=2) + scan_fillin_table(EA.Motors._motor_dictionary["y"][1],EA.Motors._motor_dictionary["y"][0],y,positioner_num=3) + scan_fillin_table(EA.Motors._motor_dictionary["z"][1],EA.Motors._motor_dictionary["z"][0],z,positioner_num=4) #setting up EA EAkwargs={ @@ -599,10 +599,10 @@ def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs): energy(mono_array[0]) #Scanning EA.put(mono_array[0]-EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) #After scan scanEA_reset(**kwargs) - iex.BL.mda.table_reset_after(**kwargs) + scan_after_table_reset(**kwargs) def scanEA_y(EAlist, start,stop,step,mode='absolute',**kwargs): scanEA_motor(EAlist,'y',start,stop,step,mode=mode,**kwargs) @@ -650,7 +650,7 @@ def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs): if kwargs["execute"]==True: #Scanning EA.put(EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - iex.BL.mda.go(kwargs["scanIOC"],scan_dim) + scan_go(kwargs["scanIOC"],scan_dim) EAlog_update() #After scan scanEA_reset(**kwargs) @@ -697,7 +697,7 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs): if kwargs['execute']: #Scanning EA.put(EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - iex.BL.mda.go(scan_dim=outer_scan_dim) + scan_go(scan_dim=outer_scan_dim) EAlog_update() #After scan diff --git a/iexcode/instruments/m3r.py b/iexcode/instruments/m3r.py index 5de10c0..4f3cb02 100644 --- a/iexcode/instruments/m3r.py +++ b/iexcode/instruments/m3r.py @@ -151,6 +151,6 @@ def m3r_align(pxl=None): sleep(1) min_m3r=caget(M3R_align_pv+'motor_min') if m3r_RY_pos_sp_get() == min_m3r: - align_m3r_epics() + _m3r_align_start() except: print('Unable to align; check camera settings.') \ No newline at end of file diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py index f0b2d4b..f6942ea 100644 --- a/iexcode/instruments/scanRecord.py +++ b/iexcode/instruments/scanRecord.py @@ -20,6 +20,9 @@ def scan_fillin(VAL,RBV,start,stop,steps_points,**kwargs): except: print("IEX_endstations has not been initialized") +def scan_fillin_2D(inner_loop_list,outer_loop_list,**kwargs): + iex.mda.scan_fillin_2D(inner_loop_list,outer_loop_list,**kwargs) + def scan_fillin_table(VAL,RBV,my_table,**kwargs): """ fills in the scan record for the curretn beamline ioc @@ -29,6 +32,33 @@ def scan_fillin_table(VAL,RBV,my_table,**kwargs): except: print("IEX_endstations has not been initialized") +def scan_after_table_reset(**kwargs): + """ + resets the scanRecord after a table scan + """ + iex.BL.mda.table_reset_after(**kwargs) + +def scan_positioners_clear(**kwargs): + iex.BL.mda.positioners_clear(**kwargs) + +def scan_positioner_after_set(**kwargs): + iex.BL.mda.positioner_after_scan_set(**kwargs) + +def scan_positioner_settling_time_set(**kwargs): + iex.BL.mda.positioner_settling_time_set(**kwargs) + +def scan_triggers_set(**kwargs): + iex.BL.mda.trigger_set(**kwargs) + +def scan_triggers_clear(**kwargs): + iex.BL.mda.triggers_clear(**kwargs) + +def scan_detectors_set(**kwargs): + iex.BL.mda.detectors_set(**kwargs) + + + + def scan_go(**kwargs): """ Starts a scan @@ -43,6 +73,11 @@ def scan_go(**kwargs): except: print("IEX_endstations has not been initialized") +def mda_fileNum(): + """ + returns the next fileNum + """ + return iex.BL.mda.fileNum() def last_mda(): """ @@ -79,12 +114,19 @@ def mda_run_cycle(): """ return iex.BL.mda.run_cycle() +def mda_ioc(): + """ + returns the ioc for the current mda ioc + """ + return iex.BL.mda.ioc + def mda_reset(): """ resets the scanRecord to the default settings """ iex.BL.mda.reset_all() + def saveData_get_all(ioc_pv): """ returns saveData info: diff --git a/iexcode/instruments/slits.py b/iexcode/instruments/slits.py index 1b8da87..e4e394c 100644 --- a/iexcode/instruments/slits.py +++ b/iexcode/instruments/slits.py @@ -2,7 +2,7 @@ from numpy import inf,nan from epics import caget, caput -import iexcode.instruments.cfg as iex +from iexcode.instruments.scanRecord import * from iexcode.instruments.shutters import main_shutter_close from iexcode.instruments.utilities import print_warning_message from iexcode.instruments.encoders import encoders_reset_zero, _encoder_dictionary,encoder_sync @@ -234,9 +234,9 @@ def slits_scan_size(slit_name,direction,start,stop,step,**kwargs): #set slit center slits_set_center(slit_name,kwargs['center']) #scan - iex.BL.mda.fillin(size_rbv,size_val,start,stop,step,**kwargs) + scan_fillin(size_rbv,size_val,start,stop,step,**kwargs) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) def slits_scan_center(slit_name,direction,start,stop,step,**kwargs): """ @@ -261,9 +261,9 @@ def slits_scan_center(slit_name,direction,start,stop,step,**kwargs): #set slit center slits_set_size(slit_name,kwargs['size']) #scan - iex.BL.mda.fillin(center_rbv,center_val,start,stop,step,**kwargs) + scan_fillin(center_rbv,center_val,start,stop,step,**kwargs) if kwargs['execute']: - iex.BL.mda.go(**kwargs) + scan_go(**kwargs) def slit1A_scribe_marks(): diff --git a/iexcode/instruments/vortex.py b/iexcode/instruments/vortex.py index aa71435..cc34eb8 100644 --- a/iexcode/instruments/vortex.py +++ b/iexcode/instruments/vortex.py @@ -1,8 +1,7 @@ from time import sleep from epics import caput, caget -import iexcode.instruments.cfg as iex -from iexcode.instruments.scanRecord import saveData_get_all +from iexcode.instruments.scanRecord import * vortex_pv = "29idVORTEX:" scaler_pv = '29idMZ0:scaler1.TP' @@ -53,7 +52,7 @@ def mca_on(): print('Vortex power ON') def _mca_file_setup(): - mda_saveData=saveData_get_all(iex.BL.mda.ioc) + mda_saveData=saveData_get_all(mda_ioc()) caput(vortex_pv+'saveData_fileSystem',mda_saveData['fileSystem']) caput(vortex_pv+'saveData_subDir', '/'+ mda_saveData['subDir']+'/S'+str(mda_saveData['scanNumber'])) caput(vortex_pv+'saveData_scanNumber',1) @@ -92,16 +91,16 @@ def scanmca(add_mca=True,save_image=False,**kwargs): trig_num = 2 if add_mca: #add trigger and detectors - iex.BL.mda.triggers_set(_vortex_trigger_dictionary(save_image,trig_num)) - iex.BL.mda.detectors_set(_vortex_detector_dictionary(add_mca)) + scan_triggers_set(_vortex_trigger_dictionary(save_image,trig_num)) + scan_detectors_set(_vortex_detector_dictionary(add_mca)) sleep(1) if save_image: _mca_file_setup() mca_check_save() else: #remove vortex trigger and detectors - iex.BL.mda.triggers_clear() - iex.BL.mda.detectors_set(_vortex_detector_dictionary(add_mca)) + scan_triggers_clear() + scan_detectors_set(_vortex_detector_dictionary(add_mca)) sleep(1) def mca_check_save(**kwargs): @@ -113,7 +112,7 @@ def mca_check_save(**kwargs): """ kwargs.setdefault('scan_dim',1) kwargs.setdefault('trig_num',2) - d=iex.BL.mda.triggers_get(kwargs['scan_dim']) + d=scan_triggers_set(kwargs['scan_dim']) if d[kwargs['trig_num']] == vortex_pv+'scanH.EXSC': print('Saving mca files') _mca_file_setup() -- GitLab