diff --git a/build/lib/iexcode/instruments/IEX_VPU.py b/build/lib/iexcode/instruments/IEX_VPU.py index fa624a1e415dbbe237281200f845f2dc3bfcdf12..e23ccef3470e5e2a9283ec41791640872cbcf49a 100644 --- a/build/lib/iexcode/instruments/IEX_VPU.py +++ b/build/lib/iexcode/instruments/IEX_VPU.py @@ -211,18 +211,15 @@ def ID_power_status(): """ gets if the ID power supplies are On or Off """ - ID_OnOff=caget(ID_pvs()['main_power']) - if ID_OnOff == 1: - return 'Off' - elif ID_OnOff == 0: - return 'On' + ID_OnOff=caget(ID_pvs()['main_power'],as_string=True) + return ID_OnOff def ID_off(verbose=True): """ waits for permission then turns on the main coils OFF """ ID_wait_for_permission(verbose=False) - caput(ID_pvs()['main_power'],1,wait=True,timeout=18000) + caput(ID_pvs()['main_power'],'Off',wait=True,timeout=18000) sleep(5) if verbose: print("ID is now off") @@ -238,7 +235,7 @@ def ID_on(verbose=True): print("Starting ID - "+dateandtime()) #caput(ID_pvs()['energy_sp'],3.8) - caput(ID_pvs()['main_power'],0,wait=True,timeout=18000) + caput(ID_pvs()['main_power'],'On',wait=True,timeout=18000) sleep(5) def ID_start(ID_mode='RCP',QP_ratio=None, verbose=True): @@ -308,10 +305,14 @@ def ID_get_eV(verbose=False): return ID_RBV def _ID_write_SP_proc(keV): - ramp_delay=5 - caput(ID_pvs()['energy_sp'],keV,wait=True,timeout=18000) - sleep(ramp_delay) - caput(ID_pvs()['start_ramp'],1,wait=True,timeout=18000) + # pressing ramp button doesn't work + # ramp_delay=5 + # caput(ID_pvs()['energy_sp'],keV,wait=True,timeout=18000) + # sleep(ramp_delay) + # caput(ID_pvs()['start_ramp'],1,wait=True,timeout=18000) + caput(ID_pvs()['energy_eV_sp'],keV,wait=True,timeout=18000) + sleep(1) + def _ID_bw_ok(keV): ID_SP = caget(ID_pvs()['energy_sp']) @@ -355,7 +356,7 @@ def ID_set(keV,verbose=True): ID_ready(verbose=False) #check if ID within some bandwidth - if _ID_bw_ok(ID_SP): + if _ID_bw_ok(keV): if verbose: ID_SP = caget(ID_pvs()['energy_sp']) ID_RBV = ID_get() diff --git a/build/lib/iexcode/instruments/current_amplifiers.py b/build/lib/iexcode/instruments/current_amplifiers.py index c9374e5c1eabd29f87b0bedc128c0f370cec6352..5d51e8ae644433ab84fe1d8854ff304ef5217502 100644 --- a/build/lib/iexcode/instruments/current_amplifiers.py +++ b/build/lib/iexcode/instruments/current_amplifiers.py @@ -71,9 +71,9 @@ class Keithley: self.filter_num = None self.range = None - self.get(verbose=False) + self.get_all(verbose=False) - def get(self,verbose=True): + def get_all(self,verbose=False): """ reads the current SRS and corresponding scaler values verbose: prints current values True/False @@ -82,13 +82,22 @@ class Keithley: self.range = 'Autoscale' if caget(self._pv+"rangeAuto",as_string=True)=='On' else caget(self._pv+"range",as_string=True) self.rate = caget(self._pv+"rate") digital_filter = caget(self._pv+'digitalFilter',as_string=True) - self.filter_num = 1 if digital_filter == 'On' else (self._pv+'digitalFilterCount') + self.filter_num = 1 if digital_filter == 'On' else caget(self._pv+'digitalFilterCount') if verbose: for key, value in vars(self).items(): if key[0] != '_': print(key, ' = ', value) + def get(self,verbose=True): + """ + returns the current in Amps + """ + self.get_all(verbose=False) + current = self.current + if verbose: + print(format(current,'.3E')) + return current def reset(self,rate="Slow"): """ @@ -337,30 +346,38 @@ class SRS: self.current_Amp = None self.current_unit = None self.invert = None - self.baseline = None self.offset_value = None self.offset_unit = None self.offset_sign = None self.offset_factor = None - self.get(verbose=False) + self.get_all(verbose=False) - def get(self,extended=False,verbose=False): + def get_all(self,verbose): """ reads the current SRS and corresponding scaler values """ self.scaler_value = caget(self._scaler_pv) - self.gain = caget(self._srs_pv+'sens_num.VAL',as_string=True) + self.gain = float(caget(self._srs_pv+'sens_num.VAL',as_string=True)) self.current_unit = caget(self._srs_pv+'sens_unit.VAL',as_string=True) self.invert = caget(self._srs_pv+'invert_on.VAL',as_string=True) unit_sciNote = {'pA':1e-12, 'nA':1e-9, 'uA':1e-6, 'mA':1e-3} - #self.current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit] - - self.offset_value=caget(self._srs_pv+"offset_num.VAL",as_string=True) + + self.offset_value=float(caget(self._srs_pv+"offset_num.VAL",as_string=True)) self.offset_unit=caget(self._srs_pv+"offset_unit.VAL",as_string=True) self.offset_sign=caget(self._srs_pv+"offset_sign.VAL",as_string=True) - self.offset_factor=caget(self._srs_pv+"off_u_put.VAL",as_string=True) - #self.baseline = self.offset_factor * self.offset_value * unit_sciNote[self.offset_unit] + self.offset_factor=float(caget(self._srs_pv+"off_u_put.VAL",as_string=True)) + + current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit[:-2]] + baseline = self.offset_value * self.offset_factor * unit_sciNote[self.offset_unit] + + if self.invert == 1: + current_Amp *= -1 + if self.offset_sign == '+': + self.current_Amp = current_Amp + baseline + elif self.offset_sign == '-': + self.current_Amp = current_Amp - baseline + self.filter_type=caget(self._srs_pv+'filter_type.VAL',as_string=True) self.filter_low=caget(self._srs_pv+'low_freq.VAL',as_string=True) self.filter_high=caget(self._srs_pv+'high_freq.VAL',as_string=True) @@ -369,7 +386,16 @@ class SRS: self.bias_value=caget(self._srs_pv+'bias_put.VAL',as_string=True) if verbose: - self.srs_print_all(extended) + self.print_all(extended=True) + + def get(self,verbose=True): + """ + returns the current in Amps with offset removed + """ + current = self.current_Amp + if verbose: + print(format(current,'.3E')) + return current def setgain(self,gain,unit): """ diff --git a/build/lib/iexcode/instruments/diagnostics.py b/build/lib/iexcode/instruments/diagnostics.py index b72d31b32ccfc60a03203c2ba40f498d394762d5..1c970b7138b4c2713937a20d2bc5ef2b01568ece 100644 --- a/build/lib/iexcode/instruments/diagnostics.py +++ b/build/lib/iexcode/instruments/diagnostics.py @@ -8,6 +8,7 @@ from iexcode.instruments.utilities import print_warning_message ############################################################################################################## ################################ default positions ############################## ############################################################################################################## +#For new endstation modify here: def _diagnostics_presets(): presets={ 'H-wire':['OUT','Start'], @@ -41,12 +42,12 @@ def _diagnostics_inout_dict(): return d #For new endstation modify here: -def _diagnostic_CA_dict(): - CA_dict={ +def _diagnostic_read_dict(): + read_dict={ 'diode_c':Keithley('b',15), 'mesh_d':SRS("29idMZ0:scaler1.S14", '29idd:A4'), } - return CA_dict + return read_dict ############################################################################################################## ################################ access presets ############################## @@ -78,9 +79,9 @@ def _diagnostics_preset_pv(diag_name,preset_name): return pv -def diagnostics_go2(diag_name,preset_name): +def diagnostics_presets_go(diag_name,preset_name,wait=False): pv = _diagnostics_preset_pv(diag_name,preset_name) - caput(pv+'_Trigger.PROC',1) + caput(pv+'_Trigger.PROC',1,wait=wait,timeout=180) def diagnostics_sp_read(diag_name,preset_name): pv = _diagnostics_preset_pv(diag_name,preset_name) @@ -94,17 +95,21 @@ def _diagnostics_sp_write(diag_name,preset_name): ############################################################################################################## ################################ quick names ############################## ############################################################################################################## -def diagnostics_list_all(verbose=True): +def diagnostic_name_list(verbose=True): """ lists all diagnostics """ - d = _diagnostics_presets() + d = _diagnostics_inout_dict() if verbose: for key in d.keys(): print(key) return list(d.keys()) def diagnostic(name,in_out): + """ + inserts/removes a diagnostic + use + """ ''' Inserts/retracts a diagnostic(motor number or name) either = "In" or "Out" @@ -116,11 +121,11 @@ def diagnostic(name,in_out): preset_name = preset_in elif in_out.lower() == "out": preset_name = preset_in - diagnostics_go2(diag_name,preset_name) + diagnostics_presets_go(diag_name,preset_name) print("\n"+name+": "+ in_out) else: message = 'name = '+name+' is not a valid diagnostic name' - message +='\n valid names are '+diagnostics_list_all(verbose=False) + message +='\n valid names are '+str(diagnostics_list_all(verbose=False)) print_warning_message(message) def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): @@ -132,7 +137,7 @@ def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): Previously: AllDiagOut """ message = "All diagnostics out" - d_quick = _diagnostics_inout_dict() + d_names = _diagnostics_inout_dict() diag_list = list(_diagnostics_presets().keys()) @@ -140,100 +145,109 @@ def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): if diode_stay_in: branch = iex.BL.branch if branch == 'c': - diode_stay_name = d_quick['diode_c'][0] + diode_stay_name = d_names['diode_c'][0] message += '\ndiode_c => In' elif branch == 'd': - diode_stay_name = d_quick['diode_d'][0] + diode_stay_name = d_names['diode_d'][0] message += '\ndiode_d => In' diag_list.pop(diode_stay_name) if mesh_stay_in: branch = iex.BL.branch if branch == 'c': - mesh_stay_name = d_quick['mesh_c'][0] + mesh_stay_name = d_names['mesh_c'][0] message += '\nmesh_c => In' elif branch == 'd': - mesh_stay_name = d_quick['mesh_d'][0] + mesh_stay_name = d_names['mesh_d'][0] message += '\nmesh_d => In' diag_list.pop(mesh_stay_name) #moving the diagnostics in list for diag_name in diag_list: - diagnostics_go2(diag_name,'OUT') + diagnostics_presets_go(diag_name,'OUT') #putting stays in if not already in if diode_stay_in: - diagnostics_go2(diode_stay_name,'Diode') + diagnostics_presets_go(diode_stay_name,'Diode') if mesh_stay_name: - diagnostics_go2(mesh_stay_name,'Mesh') + diagnostics_presets_go(mesh_stay_name,'Mesh') print("\n",message) +def diagnostics_all_in(): + print("The follow diagnostics are in ") + d_names = _diagnostics_inout_dict() + for i,name in enumerate(d_names.keys()): + diag_name,preset_in,preset_out = d_names[name] + if i == len(d_names.keys())-1: + diagnostics_presets_go(diag_name,preset_in,wait=True) + else: + diagnostics_presets_go(diag_name,preset_in,wait=False) + print("\t"+name) + +def diagnostic_InOut(name,In_Out): + d_names = _diagnostics_inout_dict() + try: + diag_name,preset_in,preset_out = d_names[name] + if In_Out.lower() == 'in': + preset = preset_in + elif In_Out.lower() == 'out': + preset = preset_out + else: + print('\nIn_Out = '+In_Out+' not a valid option, must be "in" or "out"') + return + + diagnostics_presets_go(diag_name,preset_in,wait=True) + print("\n"+diag_name+" = "+preset) + except: + message = name+"not a valid diagnostic \n choose one of: " + message += list(d_names.keys()) + def mesh_W(In_Out): """ - Inserts/retracts RSXS mesh (post-slit); arg = \"In\" or \"Out\" + Inserts/retracts the mesh in the A-hutch Previously MeshW """ - diag=_diagnostics_dict() - motor=5; position=diag[In_Out][motor] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nD1A mesh_W: "+ In_Out) + diagnostic_InOut('mesh_W',In_Out) def diode_c(In_Out): """ - Inserts/retracts ARPES (gas-cell) diode; arg = \"In\" or \"Out\" - + Inserts/retracts ARPES (gas-cell) diode + Previously: DiodeC """ - diag=_diagnostics_dict() - motor=20; position=diag[In_Out][motor] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nARPES Diode: "+ In_Out) + diagnostic_InOut('diode_c',In_Out) def diode_d(In_Out): """ - Inserts/retracts RSXS diode; arg = \"In\" or \"Out\" + Inserts/retracts RSXS diode just before the endstation Previously:DiodeD """ - diag=_diagnostics_dict() - motor=28; position=position=diag[In_Out][motor] - if type(position) == list: - position=position[1] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nRSXS Diode: "+ In_Out) + diagnostic_InOut('diode_d',In_Out) def mesh_d(In_Out): """ - Inserts/retracts RSXS mesh (post-slit); arg = \"In\" or \"Out\" + Inserts/retracts RSXS mesh (post-slit) Previoulsy: MeshD """ - diag=_diagnostics_dict() - motor=28; position=position=diag[In_Out][motor] - if type(position) == list: - position=position[0] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nD5D Au-Mesh: "+ In_Out) - -def diagnostic_read(diode_name, verbose=True): + diagnostic_InOut('mesh_d',In_Out) + +def diagnostic_read(name, verbose=True): """ reads the current amplifier and returns the value """ try: - det = _diagnostic_CA_dict[diode_name] + det = _diagnostic_read_dict()[name] val=det.get(verbose) except: - diode_pv="not connected" - val = nan - print('pv not defined') - - if verbose: - print(diode_name,val, "(pv = "+diode_pv+")") + print_warning_message(name+" not in "+str(list(_diagnostic_read_dict().keys()))) + return return val def diode_c_read(verbose=True): @@ -241,15 +255,7 @@ def diode_c_read(verbose=True): reads the current amplifier and returns the value quiet = False to pring """ - val = diagnostic_read('diode_d',verbose) - return val - -def diode_d_read(verbose=True): - """ - reads the current amplifier and returns the value - quiet = False to pring - """ - val = diagnostic_read('diode_d',verbose) + val = diagnostic_read('diode_c',verbose) return val def mesh_d_read(verbose=True): @@ -257,7 +263,7 @@ def mesh_d_read(verbose=True): reads the current amplifier and returns the value quiet = False to pring """ - val = diagnostic_read('diode_d',verbose) + val = diagnostic_read('mesh_d',verbose) return val diff --git a/build/lib/iexcode/instruments/shutters.py b/build/lib/iexcode/instruments/shutters.py index 0ac7e1143db1c9911a8d2667da4aa0294bf561ca..01e5a9de1723f63d4200d2e1618d5a832c35f8dd 100644 --- a/build/lib/iexcode/instruments/shutters.py +++ b/build/lib/iexcode/instruments/shutters.py @@ -84,11 +84,11 @@ def branch_shutter_status(branch=None,verbose=False): """ if branch == None: branch = iex.BL.branch - pvA="PA:29ID:S"+branch.upper()+"S_BLOCKING_BEAM.VAL" - pvB="PB:29ID:S"+branch.upper()+"S_BLOCKING_BEAM.VAL" - #"ON" = 1 => shutter open + pvA = "PA:29ID:S"+branch.upper()+"S_BLOCKING_BEAM.VAL" + pvB = "PB:29ID:S"+branch.upper()+"S_BLOCKING_BEAM.VAL" + #"ON" = 1 => shutter blocking status=caget(pvA)+caget(pvB) - if status == 2: + if status == 0: shutter_open=True else: shutter_open=False diff --git a/iexcode/cheatsheet.txt b/iexcode/cheatsheet.txt index cc825ed4950f043e0fb4889f539ce8c236d3e7be..6a0b6230b3d5bb01d8a347b3e2a80a741f37dc9d 100644 --- a/iexcode/cheatsheet.txt +++ b/iexcode/cheatsheet.txt @@ -35,7 +35,7 @@ current2flux => calculates the flux based on the current reading in an AUX100 ph flux2current => calculates the current reading for a given flux for and AUX100 photodiode #diagnostics: bemaline diagnostics -diagnostics_list_all => prints the name of all the diagnostics_all_in +diagnostic_name_list => prints the name of all the diagnostics_all_in diagnostic => moves the specified diagnostic in/out diagnostics_all_out => moves all beamline diagnostics out diagnostics_all_in => moves all beamline diagnostics in; Note that they can shadow/block downstream diagnostics @@ -46,6 +46,9 @@ diode_d => moves diode in c-branch in/out; located just before the kappa endstat mesh_d => moves mesh in d-branch in/out; used for normalization mesh_d_read => reads the current amplifier for the d-branch mesh +diagnostics_preset_list => returns the dictionary with all preset positions +diagnostics_presets_go => goes to preset value + #electron_analyzer: beamline specific calls to Scienta EA => electron analyzer class diff --git a/iexcode/instruments/current_amplifiers.py b/iexcode/instruments/current_amplifiers.py index c9374e5c1eabd29f87b0bedc128c0f370cec6352..5d51e8ae644433ab84fe1d8854ff304ef5217502 100644 --- a/iexcode/instruments/current_amplifiers.py +++ b/iexcode/instruments/current_amplifiers.py @@ -71,9 +71,9 @@ class Keithley: self.filter_num = None self.range = None - self.get(verbose=False) + self.get_all(verbose=False) - def get(self,verbose=True): + def get_all(self,verbose=False): """ reads the current SRS and corresponding scaler values verbose: prints current values True/False @@ -82,13 +82,22 @@ class Keithley: self.range = 'Autoscale' if caget(self._pv+"rangeAuto",as_string=True)=='On' else caget(self._pv+"range",as_string=True) self.rate = caget(self._pv+"rate") digital_filter = caget(self._pv+'digitalFilter',as_string=True) - self.filter_num = 1 if digital_filter == 'On' else (self._pv+'digitalFilterCount') + self.filter_num = 1 if digital_filter == 'On' else caget(self._pv+'digitalFilterCount') if verbose: for key, value in vars(self).items(): if key[0] != '_': print(key, ' = ', value) + def get(self,verbose=True): + """ + returns the current in Amps + """ + self.get_all(verbose=False) + current = self.current + if verbose: + print(format(current,'.3E')) + return current def reset(self,rate="Slow"): """ @@ -337,30 +346,38 @@ class SRS: self.current_Amp = None self.current_unit = None self.invert = None - self.baseline = None self.offset_value = None self.offset_unit = None self.offset_sign = None self.offset_factor = None - self.get(verbose=False) + self.get_all(verbose=False) - def get(self,extended=False,verbose=False): + def get_all(self,verbose): """ reads the current SRS and corresponding scaler values """ self.scaler_value = caget(self._scaler_pv) - self.gain = caget(self._srs_pv+'sens_num.VAL',as_string=True) + self.gain = float(caget(self._srs_pv+'sens_num.VAL',as_string=True)) self.current_unit = caget(self._srs_pv+'sens_unit.VAL',as_string=True) self.invert = caget(self._srs_pv+'invert_on.VAL',as_string=True) unit_sciNote = {'pA':1e-12, 'nA':1e-9, 'uA':1e-6, 'mA':1e-3} - #self.current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit] - - self.offset_value=caget(self._srs_pv+"offset_num.VAL",as_string=True) + + self.offset_value=float(caget(self._srs_pv+"offset_num.VAL",as_string=True)) self.offset_unit=caget(self._srs_pv+"offset_unit.VAL",as_string=True) self.offset_sign=caget(self._srs_pv+"offset_sign.VAL",as_string=True) - self.offset_factor=caget(self._srs_pv+"off_u_put.VAL",as_string=True) - #self.baseline = self.offset_factor * self.offset_value * unit_sciNote[self.offset_unit] + self.offset_factor=float(caget(self._srs_pv+"off_u_put.VAL",as_string=True)) + + current_Amp = self.scaler_value * self.gain * unit_sciNote[self.current_unit[:-2]] + baseline = self.offset_value * self.offset_factor * unit_sciNote[self.offset_unit] + + if self.invert == 1: + current_Amp *= -1 + if self.offset_sign == '+': + self.current_Amp = current_Amp + baseline + elif self.offset_sign == '-': + self.current_Amp = current_Amp - baseline + self.filter_type=caget(self._srs_pv+'filter_type.VAL',as_string=True) self.filter_low=caget(self._srs_pv+'low_freq.VAL',as_string=True) self.filter_high=caget(self._srs_pv+'high_freq.VAL',as_string=True) @@ -369,7 +386,16 @@ class SRS: self.bias_value=caget(self._srs_pv+'bias_put.VAL',as_string=True) if verbose: - self.srs_print_all(extended) + self.print_all(extended=True) + + def get(self,verbose=True): + """ + returns the current in Amps with offset removed + """ + current = self.current_Amp + if verbose: + print(format(current,'.3E')) + return current def setgain(self,gain,unit): """ diff --git a/iexcode/instruments/diagnostics.py b/iexcode/instruments/diagnostics.py index b72d31b32ccfc60a03203c2ba40f498d394762d5..1c970b7138b4c2713937a20d2bc5ef2b01568ece 100644 --- a/iexcode/instruments/diagnostics.py +++ b/iexcode/instruments/diagnostics.py @@ -8,6 +8,7 @@ from iexcode.instruments.utilities import print_warning_message ############################################################################################################## ################################ default positions ############################## ############################################################################################################## +#For new endstation modify here: def _diagnostics_presets(): presets={ 'H-wire':['OUT','Start'], @@ -41,12 +42,12 @@ def _diagnostics_inout_dict(): return d #For new endstation modify here: -def _diagnostic_CA_dict(): - CA_dict={ +def _diagnostic_read_dict(): + read_dict={ 'diode_c':Keithley('b',15), 'mesh_d':SRS("29idMZ0:scaler1.S14", '29idd:A4'), } - return CA_dict + return read_dict ############################################################################################################## ################################ access presets ############################## @@ -78,9 +79,9 @@ def _diagnostics_preset_pv(diag_name,preset_name): return pv -def diagnostics_go2(diag_name,preset_name): +def diagnostics_presets_go(diag_name,preset_name,wait=False): pv = _diagnostics_preset_pv(diag_name,preset_name) - caput(pv+'_Trigger.PROC',1) + caput(pv+'_Trigger.PROC',1,wait=wait,timeout=180) def diagnostics_sp_read(diag_name,preset_name): pv = _diagnostics_preset_pv(diag_name,preset_name) @@ -94,17 +95,21 @@ def _diagnostics_sp_write(diag_name,preset_name): ############################################################################################################## ################################ quick names ############################## ############################################################################################################## -def diagnostics_list_all(verbose=True): +def diagnostic_name_list(verbose=True): """ lists all diagnostics """ - d = _diagnostics_presets() + d = _diagnostics_inout_dict() if verbose: for key in d.keys(): print(key) return list(d.keys()) def diagnostic(name,in_out): + """ + inserts/removes a diagnostic + use + """ ''' Inserts/retracts a diagnostic(motor number or name) either = "In" or "Out" @@ -116,11 +121,11 @@ def diagnostic(name,in_out): preset_name = preset_in elif in_out.lower() == "out": preset_name = preset_in - diagnostics_go2(diag_name,preset_name) + diagnostics_presets_go(diag_name,preset_name) print("\n"+name+": "+ in_out) else: message = 'name = '+name+' is not a valid diagnostic name' - message +='\n valid names are '+diagnostics_list_all(verbose=False) + message +='\n valid names are '+str(diagnostics_list_all(verbose=False)) print_warning_message(message) def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): @@ -132,7 +137,7 @@ def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): Previously: AllDiagOut """ message = "All diagnostics out" - d_quick = _diagnostics_inout_dict() + d_names = _diagnostics_inout_dict() diag_list = list(_diagnostics_presets().keys()) @@ -140,100 +145,109 @@ def diagnostics_all_out(diode_stay_in=False,mesh_stay_in=False): if diode_stay_in: branch = iex.BL.branch if branch == 'c': - diode_stay_name = d_quick['diode_c'][0] + diode_stay_name = d_names['diode_c'][0] message += '\ndiode_c => In' elif branch == 'd': - diode_stay_name = d_quick['diode_d'][0] + diode_stay_name = d_names['diode_d'][0] message += '\ndiode_d => In' diag_list.pop(diode_stay_name) if mesh_stay_in: branch = iex.BL.branch if branch == 'c': - mesh_stay_name = d_quick['mesh_c'][0] + mesh_stay_name = d_names['mesh_c'][0] message += '\nmesh_c => In' elif branch == 'd': - mesh_stay_name = d_quick['mesh_d'][0] + mesh_stay_name = d_names['mesh_d'][0] message += '\nmesh_d => In' diag_list.pop(mesh_stay_name) #moving the diagnostics in list for diag_name in diag_list: - diagnostics_go2(diag_name,'OUT') + diagnostics_presets_go(diag_name,'OUT') #putting stays in if not already in if diode_stay_in: - diagnostics_go2(diode_stay_name,'Diode') + diagnostics_presets_go(diode_stay_name,'Diode') if mesh_stay_name: - diagnostics_go2(mesh_stay_name,'Mesh') + diagnostics_presets_go(mesh_stay_name,'Mesh') print("\n",message) +def diagnostics_all_in(): + print("The follow diagnostics are in ") + d_names = _diagnostics_inout_dict() + for i,name in enumerate(d_names.keys()): + diag_name,preset_in,preset_out = d_names[name] + if i == len(d_names.keys())-1: + diagnostics_presets_go(diag_name,preset_in,wait=True) + else: + diagnostics_presets_go(diag_name,preset_in,wait=False) + print("\t"+name) + +def diagnostic_InOut(name,In_Out): + d_names = _diagnostics_inout_dict() + try: + diag_name,preset_in,preset_out = d_names[name] + if In_Out.lower() == 'in': + preset = preset_in + elif In_Out.lower() == 'out': + preset = preset_out + else: + print('\nIn_Out = '+In_Out+' not a valid option, must be "in" or "out"') + return + + diagnostics_presets_go(diag_name,preset_in,wait=True) + print("\n"+diag_name+" = "+preset) + except: + message = name+"not a valid diagnostic \n choose one of: " + message += list(d_names.keys()) + def mesh_W(In_Out): """ - Inserts/retracts RSXS mesh (post-slit); arg = \"In\" or \"Out\" + Inserts/retracts the mesh in the A-hutch Previously MeshW """ - diag=_diagnostics_dict() - motor=5; position=diag[In_Out][motor] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nD1A mesh_W: "+ In_Out) + diagnostic_InOut('mesh_W',In_Out) def diode_c(In_Out): """ - Inserts/retracts ARPES (gas-cell) diode; arg = \"In\" or \"Out\" - + Inserts/retracts ARPES (gas-cell) diode + Previously: DiodeC """ - diag=_diagnostics_dict() - motor=20; position=diag[In_Out][motor] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nARPES Diode: "+ In_Out) + diagnostic_InOut('diode_c',In_Out) def diode_d(In_Out): """ - Inserts/retracts RSXS diode; arg = \"In\" or \"Out\" + Inserts/retracts RSXS diode just before the endstation Previously:DiodeD """ - diag=_diagnostics_dict() - motor=28; position=position=diag[In_Out][motor] - if type(position) == list: - position=position[1] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nRSXS Diode: "+ In_Out) + diagnostic_InOut('diode_d',In_Out) def mesh_d(In_Out): """ - Inserts/retracts RSXS mesh (post-slit); arg = \"In\" or \"Out\" + Inserts/retracts RSXS mesh (post-slit) Previoulsy: MeshD """ - diag=_diagnostics_dict() - motor=28; position=position=diag[In_Out][motor] - if type(position) == list: - position=position[0] - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nD5D Au-Mesh: "+ In_Out) - -def diagnostic_read(diode_name, verbose=True): + diagnostic_InOut('mesh_d',In_Out) + +def diagnostic_read(name, verbose=True): """ reads the current amplifier and returns the value """ try: - det = _diagnostic_CA_dict[diode_name] + det = _diagnostic_read_dict()[name] val=det.get(verbose) except: - diode_pv="not connected" - val = nan - print('pv not defined') - - if verbose: - print(diode_name,val, "(pv = "+diode_pv+")") + print_warning_message(name+" not in "+str(list(_diagnostic_read_dict().keys()))) + return return val def diode_c_read(verbose=True): @@ -241,15 +255,7 @@ def diode_c_read(verbose=True): reads the current amplifier and returns the value quiet = False to pring """ - val = diagnostic_read('diode_d',verbose) - return val - -def diode_d_read(verbose=True): - """ - reads the current amplifier and returns the value - quiet = False to pring - """ - val = diagnostic_read('diode_d',verbose) + val = diagnostic_read('diode_c',verbose) return val def mesh_d_read(verbose=True): @@ -257,7 +263,7 @@ def mesh_d_read(verbose=True): reads the current amplifier and returns the value quiet = False to pring """ - val = diagnostic_read('diode_d',verbose) + val = diagnostic_read('mesh_d',verbose) return val